When I start a python console in PyCharm I do/see:
/usr/local/bin/python3.7 "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevconsole.py" --mode=client --port=59807
import sys; print('Python %s on %s' % (sys.version, sys.platform)) sys.path.extend(['...snip_current_project_folder...'])
...
import os
os.environ.get("PYTHONPATH")
'/Applications/PyCharm CE.app/Contents/helpers/third_party/thriftpy:/Applications/PyCharm CE.app/Contents/helpers/pydev'
Which is not the contents of my PYTHONPATH.
The PYTHONPATH in my .bash_profile is fine. For example in the terminal, "echo $PYTHONPATH" is non-empty and I have verified is working for python3 in the command line to import a module. Also I have seen Pycharm not do this to PYTHONPATH in the past.
MAC OS.
Thoughts?
I have tried deleting the .idea file and starting over for this project.
In regards to Hassan's interpreter suggestion.
It does seem like something is wrong with the environment, but that was a system installed python. I tried switching it to an virtualenv and I tried making a new virtualenv via pycharm. None of those seemed to show the PYTHONPATH in bash_profile making it to the interpreter.
Other variables in the bash_profile show up. For example, I added to .bash_profile:
export HASSAN_JAN_2019_CHECK="test"
And after restarting pycharm I get:
import os
print(os.environ.get("PYTHONPATH"))
/Applications/PyCharm CE.app/Contents/helpers/third_party/thriftpy:/Applications/PyCharm CE.app/Contents/helpers/pydev
print(os.environ.get("HASSAN_JAN_2019_CHECK"))
test
Accumulated Evidences:
- PYTHONPATH works by hand in the terminal when starting the same interpreter that pycharm is using to load itself in Python Console.
- Switching the interpreter in pycharm does not seem to help.
- Adding a test export variable to the bash_profile that has the PYTHONPATH gets all the way to the os.environ.get correctly, but the PYTHONPATH itself does not make it unmodified.