Vlamir Vlamir - 1 month ago 20
Python Question

pycharm error while importing, even though it works in the terminal

I have installed the packages TensorFlow and scikit_learn and all its dependencies. When I try importing them using python 2.7.6 or 2.7.10 (I have tried both) in the terminal, it works fine. However, when I do it using pycharm it gives an error.

In the case of scikit_learn with the launcher 2.7.6 says:
ImportError: dynamic module does not define init function (init_check_build)

In the case of scikit_learn with the launcher 2.7.10 says:
ValueError: numpy.dtype has the wrong size, try recompiling

In the case of TensorFlow with the launcher 2.7.6 says:
ImportError: dlopen(/Library/Python/2.7/site-packages/tensorflow/python/_pywrap_tensorflow.so, 2): no suitable image found. Did find:
/Library/Python/2.7/site-packages/tensorflow/python/_pywrap_tensorflow.so: mach-o, but wrong architecture


In the case of TensorFlow with the launcher 2.7.10 says:
ImportError: No module named copyreg

Error importing tensorflow. Unless you are using bazel,
you should not try to import tensorflow from its source directory;
please exit the tensorflow source tree, and relaunch your python interpreter
from there.


I have tried to search in the net but the solutions did not work for me. I have tried to uninstall them and install them again with pip, conda and directly the source code and it gives always the same errors. I have even tried reinstalling pycharm with no better luck.

Other libraries, such as scilab or numpy, work fine in pycharm.

Any ideas? It is just driving me mental. By the way, I am using a Mac OS 10.10.5.

Answer

At the end, I ended up creating a virtual environment, reinstalling everything in there, and calling it through pycharm. I am not entirely sure what was the problem between conda and pycharm, I probably messed up somewhere.

I am now using a different virtual environment depending on the project and I am happier than ever :).