I need to install Anaconda for another project while I use Pycharm regularly. However, after I installed Anaconda, if I hit the run button on Pycharm for a python file (I'm using python 3.7.4), there is an import error. There was no problem before Anaconda was installed for the same code.
To illustrate, under the parent folder I created a folder named "io" (which is the same as built-in module) and the python file named "testandtest.py". The directory structure is like this:
- test_IO_error/
- init.py
- io/
- init.py
- testandtest.py
The code of "testandtest.py" is as below:
import csv
def foo():
print ("This is a test!")
After I hit "run" button for testandtest.py in Pycharm, there is an error message:
Fatal Python error: init_sys_streams: can't initialize sys standard streams AttributeError: module 'io' has no attribute 'OpenWrapper' Current thread 0x00046ccc (most recent call first): Process finished with exit code -1073740791 (0xC0000409)
I assume this problem is because when importing csv
, some files in csv
module needs to import the built-in module io
, but instead import the io module in the current folder, which of course does not have an attribute 'OpenWrapper'. But isn't it the case that python 3 is using absolute import always?
There is no problem if I run the function foo
in console of Pycharm.
This problem only happened when run the code using the "run" button in Pycharm software.