Reputation: 157
I am having issues installing packages using pip. When installing packages through conda from within my environment it works fine however when trying to install through pip I continue receiving the ImportError: No Module named X.
The packages I am trying to install are a group of packages that are not apart of the conda distribution.
Example
[sjamal@login1(franklin) src]$ source activate Py343
(Py343) [sjamal@login1(franklin) src]$ pip install pyvcf
Collecting pyvcf
Requirement already satisfied: setuptools in /users/sjamal/anaconda3/envs/Py343/lib/python3.4/site-packages/setuptools-27.2.0-py3.4.egg (from pyvcf)
Installing collected packages: pyvcf
Successfully installed pyvcf-0.6.8
(Py343) [sjamal@login1(franklin) src]$ python
Python 3.4.3 |Continuum Analytics, Inc.| (default, Oct 19 2015, 21:52:17)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import vcf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'vcf'
In ~/.bashrc I have the following path added /users/sjamal/anaconda3/bin which obviously allows me to access anaconda, conda etc.
I initially thought I had the same issue as in the question posed below. But either I missunderstood the answer or its not the same issue.
Does anaconda create a separate PYTHONPATH variable for each new environment?
I am pretty certain that it is a path issue but my lack of understanding of how installation of packages through pip and conda to the respective environments is probably why I can't seem to solve it.
Additional information:
I am on a login node on a cluster where I can't perform any root commands. I am sure root access is not needed but thought it would be good to mention. My linux distribution is CentOS release 6.6 (Final).
Thanks for taking a look at it!
Upvotes: 0
Views: 2644
Reputation: 157
I managed to figure it out. After doing a bit of searching on my system. I found that pip and conda install the packages to two different locations. In my case..
conda - Installed to my current anaconda environment just as expected
pip - /users/sjamal/gridware/share/python/2.7.8/lib/python3.6/site-packages/
I believe the reason for pip installing to a different location is due the predesigned infrastructure we have on our HPC, hence adding the following prefix below.
/users/sjamal/gridware/share
In order to use my packages there are 3 ways of doing this. Two of which I can do. The last one however I have not been able to figure out as it requires me to change pips default location to install packages. I tried using
pip install -t <dir>
Although it keeps throwing errors and won't allow me to choose the destination to install the folder.
The two other alternatives are:
1. Install the packages using pip install <package> and then move the packages to the original destination.
2. Add the path to the environment where I want to have the packages installed to the local PATH variable in ~/.bashrc. However, this beats the fact of working in different environments as the package will be accessible from different environments.
If anyone knows how to redirect pip's default install destination I would be very grateful if you shared it with me. Until then I will continue my search for a better alternative.
Finally thank you @amrit for responding!
Cheers!
Upvotes: 1
Reputation: 2175
try this first..
$ python3
>>> import sys
>>> sys.path.append('/all/path/to/C/Python')
>>> import vcf
and if not working then...
install python 3.6.2 and ... write
import vcf
instead of
import pyvcf
Upvotes: 0