Search code examples
pythoninstallationanacondapackagepydicom

How do I get python to recognize a module from any directory?


I'm installing some additional packages to anaconda and I can't get them to work. One such package is pydicom which I downloaded, unziped, and moved to /usr/local/anaconda/lib/python2.7/site-package/pydicom. In the pydicom folder the is a subfolder called source which contains both ez_setup.py and setup.py. I ran sudo python setup.py install which didn't spit out any errors and then ran sudo python ez_setup.py install when I still couldn't get the module to open in ipython. Now I can successfully import dicom but ONLY when my current directory is /usr/local/anaconda/lib/python2.7/site-package/pydicom/source. How do I get it so I import it from any directory? I'm running CentOS and I put

export PATH=/usr/local/anaconda/bin:$PATH export PATH=/usr/local/anaconda/lib/python2.7/:$PATH in my .bashrc file.


Solution

  • You shouldn't copy the source to site-packages directly. Rather, use python setup.py install in the source directory, or use pip install .. Make sure your Python is indeed the one in /usr/local/anaconda, especially if you use sudo (which in general is not necessary and not recommended with Anaconda).