PyCharm does not use selected virtualenv

PyCharm seems to ignore the configured virtualenv , and use the underlying interpreter instead.

In my project in /Users/janos/dev/git/github/bashoneliners , I have a virtualenv subdirectory, strictly with my project dependencies installed in it:

 $ . virtualenv/bin/activate (virtualenv)janos at kronos in ~/dev/git/github/bashoneliners on master $ pip -V pip 1.5.6 from /Users/janos/dev/git/github/bashoneliners/virtualenv/lib/python3.4/site-packages (python 3.4) (virtualenv)janos at kronos in ~/dev/git/github/bashoneliners on master $ pip freeze Django==1.9 Markdown==2.6.5 PyJWT==1.4.0 defusedxml==0.4.1 oauthlib==1.0.3 pep8==1.6.2 pyflakes==1.0.0 python-social-auth==0.2.13 python3-openid==3.0.9 requests==2.9.1 requests-oauthlib==0.6.0 six==1.10.0 tweepy==3.5.0 

But if I add this virtualenv as a Project Interpreter in PyCharm, it shows completely different packages:

enter image description here

These packages are the same as in my base interpreter /opt/local/bin/python . It drives me crazy, I really need to use packages from virtualenv , not from my system.

This is with PyCharm Community Edition 5.0.3.

I have not had this problem before with older versions of PyCharm. I tried to create a completely new virtualenv , both on the command line and using PyCharm, and with invalid caches and restarts, but nothing works. PyCharm always shows the same list of packages and virtualenv packages. Even if I create an empty virtualenv in PyCharm, it does not start empty, but is populated with the same package list.

My project works great when I run things on the command line, such as managing Django management commands, unit tests, that's all. I only have problems in PyCharm.

If I try to install packages like Django using PyCharm, I get this error:

enter image description here

Of course, permission is denied to /opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages , which is the system interpreter. He should try to install the package there, but in /Users/janos/dev/git/github/bashoneliners/virtualenv .

Obviously, it does not use pip from virtualenv , but from the system. I need to do to use one of virtualenv .

+6
source share
1 answer

This is reported as a bug in the JetBrains problem tracking system, so hopefully it will be clarified soon.

https://youtrack.jetbrains.com/issue/PY-18074

A possible workaround is to revert to a previous version of PyCharm:

https://confluence.jetbrains.com/display/PYH/Previous+PyCharm+Releases

Since January 6th, 2016, virtualenv has been working fine for me in PyCharm 4.5.4. Some of the virtualenv previously registered using PyCharm 5.0.3 seem invalid, but this is normal. I actually deleted all registered interpreters and again added only those virtualenv that I need.

The strange thing with this older version is that sometimes PyCharm shows the wrong version of Python (2.7 instead of 3.5), but shows the correct list of modules according to virtualenv , and the editor does not show build errors, so mixing Python versions does not seem to cause problems (just a little scary).

+2
source

All Articles