0

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:

  1. PYTHONPATH works by hand in the terminal when starting the same interpreter that pycharm is using to load itself in Python Console.
  2. Switching the interpreter in pycharm does not seem to help.
  3. 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.
1
  • My question now is what are you trying to achieve? Commented Jan 10, 2019 at 1:18

1 Answer 1

2

I think because Pycharm uses virtualenv you are seeing this difference. See link below how you can set your paths in Pycharms

Installing, Uninstalling and Reloading Interpreter Paths

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.