3
$\begingroup$

I have installed TensorFlow on Linux (Anaconda) by following the documentation which states that one should create and activate a virtual environment tensorflow. So far, so good (albeit it is not entirely clear why is this virtual environment is necessary when I want to incorporate TF to my existing env).

But when I activate the tensorflow environment I observe that several packages are unavailable in the new environment while available outside the environment at the same time:

$source activate tensorflow
$python

>>>import h5py

... No module named h5py

$source deactivate tensorflow
$python

>>>import h5py
>>>

No problem in this case.

I guessed that I should install the missing package in the tensorflow environment as well, but when I try to, I get informed that the package in question has already been installed and nothing happens:

$source activate tensorflow
$pip install h5py

Requirement already statisfied ....

The same inconsistency occurs with several other packages. What is the problem here?

$\endgroup$

2 Answers 2

2
$\begingroup$

I can't offer any suggestions as to why your virtual environment can't find the packages (I'm not familiar with anaconda). The only thing that comes to mind is a PATH problem.

Perhaps try installing the package with the following command:

conda install -n yourenvname [package]

or, in your case:

conda install -n tensorflow h5py

To install additional packages only to your virtual environment, enter the following command where yourenvname is the name of your environemnt, and [package] is the name of the package you wish to install. Failure to specify “-n yourenvname” will install the package to the root Python installation.

source: https://uoa-eresearch.github.io/eresearch-cookbook/recipe/2014/11/20/conda/

$\endgroup$
0
$\begingroup$

I believe that there might be a conflicting version of python, try to see which python you're using when you're in the virtual environment:

which python

If the python version you're using is not the one in the conda environment, try setting it:

export PATH=path/to/python

You can try two more things, first try the conda pip install to see if this works:

conda install pip

It might be possible that you have two conflicting versions of pip, to see if this is the case try this and set it to the right version with export:

which -a pip
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.