I’ve got Pycharm 4 running on my Linux (Ubuntu 14.04) machine. In addition to the system python, I’ve also got Anaconda installed. Getting the two to play nicely together seems to be a bit of a problem… PyCharm provides some interesting integration for
pip, but the Anaconda Python distribution seems to prefer using its own
conda tool for both activities.
Is there a relatively simple/painless way to be able to use
conda in conjunction with PyCharm? Not just as an alternative interpreter i.e. point PyCharm at the Anaconda Python binary for a project interpreter, but to be able to create, source/activate and deactivate virtual envs, add/remove packages in those virtual envs, etc.
Or am I going to have to choose between using Anaconda (and having a more recent and up-to-date python than may come with the system), and being able to use PyCharm’s features to their fullest extent?
I know it’s late, but I thought it would be nice to clarify things: PyCharm and Conda and pip work well together.
The short answer
Just manage Conda from the command line. PyCharm will automatically notice changes once they happen, just like it does with pip.
The long answer
Create a new Conda environment:
conda create --name foo pandas bokeh
This environment lives under
conda_root/envs/foo. Your python interpreter is
conda_root/envs/foo/bin/pythonX.X and your all your site-packages are in
conda_root/envs/foo/lib/pythonX.X/site-packages. This is same directory structure as in a pip virtual environement. PyCharm sees no difference.
Now to activate your new environment from PyCharm go to file > settings > project > interpreter, select Add local in the project interpreter field (the little gear wheel) and hunt down your python interpreter. Congratulations! You now have a Conda environment with pandas and bokeh!
Now install more packages:
conda install scikit-learn
OK… go back to your interpreter in settings. Magically, PyCharm now sees scikit-learn!
And the reverse is also true, i.e. when you pip install another package in PyCharm, Conda will automatically notice. Say you’ve installed requests. Now list the Conda packages in your current environment:
The list now includes requests and Conda has correctly detected (3rd column) that it was installed with pip.
This is definitely good news for people like myself who are trying to get away from the pip/virtualenv installation problems when packages are not pure python.
NB: I run PyCharm pro edition 4.5.3 on Linux. For Windows users, replace in command line with in the GUI (and forward slashes with backslashes). There’s no reason it shouldn’t work for you too.
EDIT: PyCharm5 is out with Conda support! In the community edition too.
Change the project interpreter to
~/anaconda2/python/bin by going to
File -> Settings -> Project -> Project Interpreter. Also update the run configuration to use the project default Python interpreter via
Run -> Edit Configurations. This makes
Anaconda instead of the default Python interpreter under
as per @cyberbikepunk answer pycharm supports Anaconda since pycharm5!
Continuum Analytics now provides instructions on how to setup Anaconda with various IDEs including Pycharm here. However, with Pycharm 5.0.1 running on Unbuntu 15.10 Project Interpreter settings were found via the File | Settings and then under the Project branch of the treeview on the Settings dialog.
this might be repetitive.
I was trying to use pycharm to run flask – had anaconda 3, pycharm 2019.1.1 and windows 10. Created a new conda environment – it threw errors.
Followed these steps –
Used the cmd to install python and flask after creating environment as suggested above.
Followed this answer.
- As suggested above, went to Run -> Edit Configurations and changed the environment there as well as in (2).
Obviously kept the correct python interpreter (the one in the environment) everywhere.