Search code examples
pythonpipjupyter-notebookcondapydicom

Path confusion using Conda, PIP, and Jupyter notebook at the same time


I've been using conda and jupyter notebook for a while now and recently I need some packages that are only available for install via pip. My understanding was that they are completely compatible and transparent with each other but apparently not.

I did a pip install pydicom and when I tried to do an import pydicom in my Jupyter Notebook, it says No module named pydicom.

In command prompt (using a Windows machine here) I ran conda list and I see pydicom is listed and marked as < pip >.

In my Jupyter notebook, this is my sys.executable output:

C:\Users\USERNAME\AppData\Local\Continuum\Anaconda2\python.exe

Is that normal/correct???

Disclaimer: I'm thoroughly confused by how the paths, environment, and dependencies work in conda and pip. I can't find a good tutorial or explanation how conda/pip work behind the scenes. Any pointers will be greatly appreciated!


Solution

  • While the package is named pydicom, you need to import dicom:

    import dicom
    

    You can also in install pydicom via conda. You need to provide the channel 'conda-forge`:

    conda install -c conda-forge pydicom
    

    You can find more packages a https://anaconda.org/. Just enter the package name in the search window. If the package is available you will see the channel you can with the -c option.