Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wrong pip in conda env

Tags:

python

pip

conda

I have a conda env called birdid.

While working in the env (i.e. I did source activate bird_dev), showing the list of the packages give

(bird_dev)...$ conda list
# packages in environment at /home/jul/Development/miniconda/envs/bird_dev:
#
...
pep8                      1.6.2                    py27_0  
pip                       7.1.2                    py27_0  
pixman                    0.26.2                        0  
...

but when trying to see what pip is used I get

(bird_dev)...$ which pip
/usr/local/bin/pip

while the correct python is found

(bird_dev)...$ which python
/home/jul/Development/miniconda/envs/bird_dev/bin/python

Anybody can help?

Edit: more details about the installed versions

Check which -a pip

(bird_dev)...$ which -a pip
/usr/local/bin/pip
/usr/bin/pip

The version in /usr/bin/pip is quite old.

(bird_dev)...$ /usr/bin/pip -V
pip 1.5.4 from /usr/lib/python2.7/dist-packages (python 2.7)    
(bird_dev)....$ /usr/local/bin/pip -V
pip 6.1.1 from /usr/local/lib/python2.7/dist-packages (python 2.7)

There is actually no pip in the env

$ ll /home/jul/Development/miniconda/envs/bird_dev/bin/ | grep pip

returns nothing

there is one pip in /home/jul/Development/miniconda/bin/pip

$ /home/jul/Development/miniconda/bin/pip -V
pip 6.1.1 from /usr/local/lib/python2.7/dist-packages (python 2.7)

but it is not the version listed by conda list, and it is a python script (!)

$ cat /home/jul/Development/miniconda/bin/pip
#!/home/jul/Development/miniconda/bin/python
if __name__ == '__main__':
    import sys
    from pip import main

    sys.exit(main())

Edit: echo $PATH

(bird_dev)...$ echo $PATH
/home/jul/Development/miniconda/envs/bird_dev/bin:/home/jul/torch/install/bin:/home/jul/torch/install/bin:/home/jul/torch/install/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

Edit: try to force install

(bird_dev)...$ conda install --force pip
Fetching package metadata: ....
Solving package specifications: .
Package plan for installation in environment /home/jul/Development/miniconda/envs/bird_dev:

The following packages will be UPDATED:

    pip: 7.1.2-py27_0 --> 7.1.2-py27_0

Proceed ([y]/n)? y

[      COMPLETE      ]|##################################################################################################################################################################################| 100%
Extracting packages ...
[      COMPLETE      ]|##################################################################################################################################################################################| 100%
Unlinking packages ...
[      COMPLETE      ]|##################################################################################################################################################################################| 100%
Linking packages ...
[      COMPLETE      ]|##################################################################################################################################################################################| 100%
(bird_dev)...$ which pip
/home/jul/Development/miniconda/envs/bird_dev/bin/pip
(bird_dev)...$ /home/jul/Development/miniconda/envs/bird_dev/bin/pip -V
pip 6.1.1 from /usr/local/lib/python2.7/dist-packages (python 2.7)
(bird_dev)...$ cat /home/jul/Development/miniconda/envs/bird_dev/bin/pip 
#!/home/jul/Development/miniconda/envs/bird_dev/bin/python
if __name__ == '__main__':
    import sys
    from pip import main

    sys.exit(main())

Weird.

like image 788
jul Avatar asked Sep 01 '15 10:09

jul


People also ask

Can I use pip in a conda ENV?

You can install pip in the current conda environment with the command conda install pip , as discussed in Using pip in an environment. If there are instances of pip installed both inside and outside the current conda environment, the instance of pip installed inside the current conda environment is used.

How do I change my pip environment?

Click on the Advanced system settings link on the left panel. Click Environment Variables. Under System Variables, double-click the variable PATH. Click New, and add the directory where pip is installed, e.g. C:Python\Scripts, and select OK.

Is it OK to mix pip and conda?

In summary, when combining conda and pip, it is best to use an isolated conda environment. Only after conda has been used to install as many packages as possible should pip be used to install any remaining software.

Can I use pip install in Anaconda environment?

pip is the standard package manager for python, meaning you can use it both inside and outside of Anaconda.


1 Answers

You probably have PYTHONPATH set. I would recommend unsetting it, and removing any lines from ~/.bashrc that set it. It will cause any of your conda environments' Pythons to look in that location before themselves.

like image 189
asmeurer Avatar answered Sep 29 '22 10:09

asmeurer