6

I installed pycharm on my computer. I set the project interpreter to acaconda3/bin/python because that is the python3 interpreter I used on my computer before installing pycharm. I was able to install all packages I need using pycharm's package installer except for pydicom which is not provided by anaconda. However, pydicom, one of the packages I need for my project, is not provided by conda and hence does not show up in the list of available packages when I search.

How do I install this package that is not available with conda?

enter image description here

Semihcan Doken
  • 776
  • 3
  • 10
  • 23
  • 1
    Haven't used conda, but doesn't pip work from anaconda command line? – pyeR_biz Jun 12 '18 at 21:49
  • I will guess that it does. How would I access anaconda command line from pycharm? – Semihcan Doken Jun 12 '18 at 21:50
  • 1
    anaconda prompt should be there in your windows start menu, just search for it. install your package using pip, it will install to a default library, which should be accessible in pycharm . – pyeR_biz Jun 12 '18 at 21:54
  • I am using a mac. – Semihcan Doken Jun 12 '18 at 21:56
  • Do I need to install it to the specific virtual environment created by pycharm? Or were you suggesting I install it in general on my machine? – Semihcan Doken Jun 12 '18 at 21:57
  • I just tried to switch to the virtualenvironment created by pycharm by doing `source activate virtualenvname` but that did not help. – Semihcan Doken Jun 12 '18 at 22:04
  • Open Anaconda Prompt in your environment, and run `conda install -c conda-forge pydicom ` or `conda install -c conda-forge/label/broken pydicom` – pyeR_biz Jun 12 '18 at 22:10
  • Possible duplicate of [Using (Ana)conda within PyCharm](https://stackoverflow.com/questions/28390961/using-anaconda-within-pycharm) – Morse Jun 12 '18 at 22:14

4 Answers4

10
  • Open Anaconda navigator

enter image description here

  • Open environment from side tab

  • Open your environment which you created or choose the default( seems in this case)

  • Choose Open in terminal

  • Run pip command here.


OR run pip by going to directory anaconda3/Scripts directory


Since pydicom is supported by conda-forge channel it wont show up on Pycharm unless you add that channel to conda environment channels manually.

Run below command for the environment

conda config --add channels conda-forge

enter image description here

Then it should show up in Pycharm.

enter image description here

Once channel added you can run below command within environment

conda install pydicom

Reference:

Morse
  • 8,258
  • 7
  • 39
  • 64
3

Using PyCharm 2020.2 I can do this without going to the terminal or Anaconda.

Go to "Settings->Project->Python Interpreter" (same place as VictorLegros went, but the UI is different now: note the + button at the bottom of the list of packages)

Hit the + button, search for your package in the new dialog and then click "Install Package"

enter image description here

I double checked in the Anaconda UI afterward, and - after click on Update Index.. and waiting a bit (not 100% sure that was necessary, but I didn't see it at first) - I can now see the package "scikit-learn" that installed via PyCharm.

enter image description here

(Note: I'm not using Anaconda to do anything but verify: the search and installation was all in PyCharm)

Rhubarb
  • 34,705
  • 2
  • 49
  • 38
1

I had this problem and I figured out that from the python interpreter dialogue I had to click the green circular Conda icon to disable "Use Conda Package Manager" (above the list of packages). Then when I clicked to add a package, I found all the packages I needed, which I presume were installed with pip.

I was also able to install packages that Conda needed to handle like psycopg2. Hope this helps.

bksam
  • 108
  • 8
0

I don't know if it's identical on the Mac, but for Win 10 Pycharm, you can access the Terminal from:

View > Tool Windows > Terminal (Alt+F12)

Pycharm Terminal Menu Item

From there, make sure the correct conda environment is active through:

conda activate <your_env>

Then, you can install a package as one normally would typing in the command line, e.g.

conda install -c conda-forge <some_thing>

PyCharm Terminal View

The exact command changes if you're using pip or some other manager or repository location, but it's helpful to do it this way if you want to stay in the IDE.

Also, you can verify the package in present in File > Settings > Project: ... > Python Interpreter

You should see your manually added package listed here, even though you didn't install it through the GUI.

PyCharm Installed Packages

VictorLegros
  • 380
  • 1
  • 4
  • 13