I'm still coming to terms with the Python ecosystem and PyCharm, so take the following with a grain of salt, but after reading up a bit, I thought I'd write a detailed explanation.
During installation, Anaconda changes the default Python interpreter to ~/anaconda/bin/python. This interpreter is configured with a sys.path
that defaults to the libraries in ~/anaconda/lib . Package managers like python's pip use the interpreter that's running them to determine the path in which to install packages, so after Anaconda is installed, all packages installed via pip or other methods will be placed somewhere inside ~/anaconda/lib. i.e. even without using something like virtualenv, every Python interpreter has its own ecosystem and running pip with different interpreters will install packages into different directories.
PyCharm handles all this in the Project Settings-->Project Interpreter-->Python Interpreters
screen. To make PyCharm aware of the Anaconda distribution, you need to add the Anaconda python interpreter to the Project Interpreter-->Python Interpreters
list and make it the default for the project. PyCharm will then locate all packages installed in Anaconda's interpreter ecosystem (~/anaconda/lib) and list them under packages
in the lower pane. It will also prompt you to install setup_tools and pip for that interpreter, and once you do that you'll be able to use the install
button in the lower pane to add more packages to the Anaconda ecosystem.
Once you've added the Anaconda interpreter, you can also use the virtualenv button from the toolbar on the upper pane to create a virtualenv that inherits from the Anaconda interpreter's environment. That way you can install new packages in a way that would not affect the global Anaconda distribution.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…