Python3.x in virtualenv(pyenv) doesn't work with Python Console


i installed python3.5.1 with pyenv. Then i selected pyenv-directry-path for the interpreter, but the error occurred.
it said that
Cannot set up a python SDK at /Users/[myname]/.pyenv/versions/3.5.1/bin/python.
The SDK seems invalid.

then, after pressing `OK` and `Create` button to generate the new project files, there is another error massage in the `Python Console` window; it said,
/Users/[myname]/.pyenv/versions/3.5.1/bin/python /Applications/ 58123 58124
Failed to import the site module
Your PYTHONPATH points to a site-packages dir for Python 2.x but you are running Python 3.x!
        PYTHONPATH is currently: "/Applications/"
        You should `unset PYTHONPATH` to fix this.

Process finished with exit code 1
Couldn't connect to console process.

i don't know why it happens, but the same error message was shown when i execute python3.5.1 on the Terminal (it works.)
Does anyone have an idea to solve this problem?

Comment actions Permalink

I am stuck with this exact same issue. I have removed Python and PyCharm and stared again but I still encounter this problem


Comment actions Permalink

Hi, Djgpc27


Actually i succeeded to avoid this problem a few months ago.

The hint is given this site( ) though it is written in Japanese.

If you use Homebrew to manage the pyenv, your error may be occurred by the same reason.

Please open


Then if you have

import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")

in `homebrew.pth` file, comment out or delete the line.

My Python3.5 became to work successfully after this treatment.

Good luck!


Comment actions Permalink

Thanks Yoshihiro!!

I followed you suggestion - and even though it wasn't quite the issue I had, it got me there.


I had used brew to install python3 and then removed it (it didn't work for some reason). But seeing your suggestion I tried to trackdown the site-packages file.


Via a strange file (/usr/local/lib/python3.5/site-packages/__pycache__/sitecustomize.cpython-35.pyc) I found that brew had expected something in the Cellar/python/... dir. But since I had removed the brew Python that was gone.


lots of searching later I found this: /usr/local/lib/python3.5/site-packages/   which is a Home Brew file that is causing the issue. It is run every time Python launches and crashes out if the PYTHONPATH isn't set to the correct Python version.

I think that since I am not using brew-python this will be redundant.

Unfortunately this didn't totally clear the issue. It wasn't until I removed this (exactly the same) file as well that the issue was resolved in PyCharm: /usr/local/lib/python2.7/site-packages/



Please sign in to leave a comment.