multical icon indicating copy to clipboard operation
multical copied to clipboard

How to setup the development environment in Pycharm on windows? (ImportError: cannot import name 'open' from 'builtins' (unknown location))

Open alexiscatnip opened this issue 2 years ago • 6 comments

In windows, In pycharm, I configured the project to run in anaconda env with python 3.7:

Error log:


C:\Users\Alexis\anaconda3\envs\multical_py37\python.exe C:/workspace/multical/multical/app/multical.py
Fatal Python error: init_sys_streams: can't initialize sys standard streams
Traceback (most recent call last):
  File "C:\workspace\multical\multical\io\__init__.py", line 1, in <module>
  File "C:\workspace\multical\multical\io\detections.py", line 3, in <module>
  File "C:\workspace\multical\multical\__init__.py", line 1, in <module>
  File "C:\workspace\multical\multical\board\__init__.py", line 1, in <module>
  File "C:\Users\Alexis\anaconda3\envs\multical_py37\lib\dataclasses.py", line 5, in <module>
  File "C:\Users\Alexis\anaconda3\envs\multical_py37\lib\inspect.py", line 40, in <module>
  File "C:\Users\Alexis\anaconda3\envs\multical_py37\lib\linecache.py", line 11, in <module>
  File "C:\Users\Alexis\anaconda3\envs\multical_py37\lib\tokenize.py", line 27, in <module>
ImportError: cannot import name 'open' from 'builtins' (unknown location)

alexiscatnip avatar Jun 24 '22 12:06 alexiscatnip

1 can be run from CMD prompt:

  1. cd to repo root: cd C:\workspace\multical
  2. call python on the main file python multical/app/multical_main.py

2 When called in such a way, this issue arises: https://stackoverflow.com/questions/54333865/python-no-module-named-error-package-is-not-a-package?answertab=trending#tab-top

To fix that, you can rename multical.py -> multical_main.py

alexiscatnip avatar Jun 24 '22 13:06 alexiscatnip

Are you solved this problem? I fixed the file name multical.py -> multical_main.py (and same environments setting with you), but its not solved.

yetniek avatar Apr 17 '23 06:04 yetniek

The easiest way to set it up for running is to install the project with pip, preferably in a virtual environment (e.g. conda), in which case an entry point will be available called 'multical'. This can be done in the root directory for example with pip install -e .

On Mon, Apr 17, 2023 at 6:57 PM yetniek @.***> wrote:

Are you solved this problem? I fixed the file name multical.py (and same setting with you), i got a same issue.

— Reply to this email directly, view it on GitHub https://github.com/oliver-batchelor/multical/issues/32#issuecomment-1510803418, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAITRZM6GTLNUUA25ZRINYTXBTSUXANCNFSM5ZXZAELQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

oliver-batchelor avatar Apr 17 '23 07:04 oliver-batchelor

In Anaconda, I created a virtual environment with Python 3.7, I used pycharm. I installed the package with pip install multical. But the error keeps popping up. Do you happen to know how?

yetniek avatar Apr 17 '23 08:04 yetniek

I think it is because I have a directory called 'io' and pycharm is running the file in the same directory which means that the standard python 'io' module is being masked. The module should probably be renamed something so that it does not conflict, however to run it it should not be run from inside the source tree which is probably what pycharm is doing. If you can make the working directory some other place that would probably fix it.

On Mon, Apr 17, 2023 at 8:16 PM yetniek @.***> wrote:

In Anaconda, I created a virtual environment with Python 3.7, I used pycharm. I installed the package with pip install multical. But the error keeps popping up. Do you happen to know how?

— Reply to this email directly, view it on GitHub https://github.com/oliver-batchelor/multical/issues/32#issuecomment-1510905828, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAITRZK4JHPG23BG7I3CXWLXBT35PANCNFSM5ZXZAELQ . You are receiving this because you commented.Message ID: @.***>

oliver-batchelor avatar Apr 17 '23 08:04 oliver-batchelor

ok i'll try. Thank you so much for the speedy reply.

yetniek avatar Apr 17 '23 08:04 yetniek