PyCharm doesn't list, or install, some packages unless venv was created with virtualenv
I should start with the disclaimer that I am running Snow Leopard on my Mac.
I use various scientific packages [numpy, matplotlib, scipy, sympy]. In the past, I have found I was not able to install some or all of these packages using the Install feature of PyCharm's Project Interpreter Preferences. When such problems occurred, it was a no-go whether PyCharm's PI was a virtual env or not. A workaround I discovered was, since I use a Mac and since I have Mac Ports installed, to install the Mac Ports version of whatever package I wanted to a virtual env created not by using PyCharm's Project Interpreter Preferences but by using the Mac Ports port of virtualenv instead.
My experience is that Mac Ports packages are more compatible with my Mac than the ones that PIP [which PyCharm uses I think] pulls down. It is not that big a deal to create venvs with virtualenv from a term session, and install packages with Mac Ports instead of PyCharms' Install feature, so I can live with the Way things are.
Nevertheless, since Python v3.3 now has a built-in alternative to virtualenv which PyCharm's Project Interpreter uses, I decided to revisit the problem. Alas, not only has nothing changed, but even if I create a venv using python v3.3's pyenv from a term session, and then install Mac Ports numpy and sympy packages, PyCharm still does not see those packages. PyCharm will only see those packages if the venv was created using Mac Ports' py33-virtualenv port.
And, yes, I do use the –system-site-packages switch when creating venvs from a term session.
I use various scientific packages [numpy, matplotlib, scipy, sympy]. In the past, I have found I was not able to install some or all of these packages using the Install feature of PyCharm's Project Interpreter Preferences. When such problems occurred, it was a no-go whether PyCharm's PI was a virtual env or not. A workaround I discovered was, since I use a Mac and since I have Mac Ports installed, to install the Mac Ports version of whatever package I wanted to a virtual env created not by using PyCharm's Project Interpreter Preferences but by using the Mac Ports port of virtualenv instead.
My experience is that Mac Ports packages are more compatible with my Mac than the ones that PIP [which PyCharm uses I think] pulls down. It is not that big a deal to create venvs with virtualenv from a term session, and install packages with Mac Ports instead of PyCharms' Install feature, so I can live with the Way things are.
Nevertheless, since Python v3.3 now has a built-in alternative to virtualenv which PyCharm's Project Interpreter uses, I decided to revisit the problem. Alas, not only has nothing changed, but even if I create a venv using python v3.3's pyenv from a term session, and then install Mac Ports numpy and sympy packages, PyCharm still does not see those packages. PyCharm will only see those packages if the venv was created using Mac Ports' py33-virtualenv port.
And, yes, I do use the –system-site-packages switch when creating venvs from a term session.
请先登录再写评论。
A disturbing aspect of this is that the Packages tab for the PyCharm created venv lists pip v1.1 as the one being used. Ditto for the pyenv created venv. It is only for the virtualenv created venv that Packages correctly shows the latest pip v1.2.1 as what is being used. Browsing the lib folders for the venvs using Finder confirms that Packages is reading what really was installed. So, maybe, the Mac Ports virtualenv port is smart enough to know, in the wacky world of Apple, to use the Mac Ports installed pip rather than the one from somewhere in the Apple installed framework that PyCharm and pyenv use... which would explain my problems with venvs both pre- and post python v3.3.
Admittedly, Macs are weird in that Apple installs its python framework in one place while Mac Ports installs its ports of Python elsewhere. General consensus is that you should not dork with Apple's frameworks. I have learned from painful experience to use Mac Ports distributed python packages and not the ones from Apple or even from python.org. That is precisely why I use Mac Ports and venvs – so that I do not have to play in Apple's sandbox.
Is there somewhere in PyCharm's preferences where I can specify the location of pip used when creating, and installing packages into, venvs? Specifically, I need PyCharm to use usr/local/bin/pip when creating, and installing packages into, a venv. Attempts to upgrade the version of pip in PyCharm-created venvs, using the Upgrade button in the Packages tab, fail.
Recently, I completely uninstalled MacPorts and reinstalled it, which meant I had to reconfigure PyCharm's PIs as well. As it turns out, this time around I created the PyCharm PIs before I installed any Mac Ports other than python27 and its dependencies. That revealed an intriguing anomaly. From there, when I did attempt to install the py27-numpy Mac Port, MacPorts was not able to activate it, reporting that non-MacPort versions of easyinstall amd setupinstall were already installed. easyinstall, setupinstall, pip, and distribute are all somewhat related in how packages are manipulated by venvs and PIs in general, ergo, the aforementioned conflicts.
MacPorts provides a Way to resolve the conflict, which is use the -f switch to force activation. But, among other things, that renames the non-MacPort file to something else. Which makes MacPorts happy but may create problems for other apps.
It seems to me that the best solution for everyone concerned is for all apps which use PIs [such as PyCharm and Eclipse, for instance] to provide the user with a Way to configure the location of the package manipulating files [pip, distribute, easyinstall, setupinstall].
This seems like such an obvious need that I am wondering if it already exists and I am missing it.
It's also the version that we bundle with PyCharm. If MacPorts makes some changes to pip which are not included in the officially released version, then obviously the result of those changes is a non-standard version of pip.
Admittedly, ipython and/or emacs have become sort of the de facto standards in the scientific community. But, it would be nice if PyCharm integrated more seamlessly with the aforementioned scientific computing packages.
1) Use MacPorts to port install python27 and any other packages [ergo, py27-whatever] you wish to use with python27.
2) Here is the important step I was not doing before –> use MacPorts to port install py27-pip _before_ you create a PyCharm PI for the MacPorts installed python27.
3) Use PyCharm Preferences to add a Protocol Interpreter associated with the MacPorts installed python27 [that would probably be /opt/local/bin/python2.7 unless you specified elsewhere during installation of MacPorts.]
4) PyCharm figures out that MacPorts has already installed py27-pip and associates that with this particular PI. Hence, PyCharm will list all the MacPorts packages installed in steps 1) and 2) for this particular PI.
Thank you, Istlota! This helped me get started using MacPorts with PyCharm. This should be in the HOWTOs!