Python PATH (sys.path) different in Python Console, Terminal, external shell

Hello,

I'm trying to use the "Terminal" in PyCharm Pro 2017.2 to run a Python script. My script runs with no issues if launcher from an external shell (not Terminal in PyCharm). Unfortunately, the script complains about not being able to import a module when launched from the PyCharm Terminal.

If I start up a Python REPL from PyCharm Terminal and inspect the "sys.path" variable, I can see that a module location is being injected into that list that is not present in Python instances launched from the external shell. This is the only non "site-packages" module that is in that list.

Furthermore, the sys.path values in the PyCharm Terminal do not match the values in the PyCharm Python Console either. The values in the Python Console's sys.path values appear to match the libraries of the interpreter I have set up.

Finally, in the Python Console, Terminal, and external shell, the Python version being used in Anaconda 4.4.0 (I'm using Continuums Anaconda distribution).

Any ideas on how that extra module is being injected in there?

3 comments
Comment actions Permalink

Is Python interpreter you are using in the external terminal matches the one set in for your project in PyCharm? Is it possible that one uses virtual environment and the other is not?

0
Comment actions Permalink

I checked conda info --envs and os.environ['VIRTUAL_ENV'] and both point to the same. I'm using the "root" environment of conda. Thanks for the suggestion though.

0
Comment actions Permalink

I noticed the same in my installation

0

Please sign in to leave a comment.