PATH points to wrong version of pip - python

I have the anaconda distribution of python installed on my machine. Before installing anaconda, i had pip installed. Right now, my system uses the previous version of pip rather than the anaconda version. In particular
arjuns-mbp:~ Arjun$ which pip
/usr/local/bin/pip
arjuns-mbp:~ Arjun$ which easy_install
/Users/Arjun/anaconda/bin/easy_install
arjuns-mbp:~ Arjun$ which python
/Users/Arjun/anaconda/bin/python
The result is that if i call a pip install, it won't add it to my anaconda version of python. So far i haven't had an issue simply using easy_install to add packages to anaconda, but it would be nice to know what causes this discrepancy and how to fix it
EDIT
i tried using conda install pip, it doesn't work. When I do
conda list
pip showed up before and after a conda install

You probably need to conda install pip.

pip should already come with Anaconda automatically. How did you install Anaconda? No matter, though, you can just conda install pip to make sure you have a version of pip that is tied to the Anaconda distribution.
From there you can create environments as much as you like to install whatever new trial-run software tools using conda create -n env_name python pip

Related

installing pytorch to one conda evnironment removes existing installation from other conda environments

The pip was installed per each environment and which pip returns proper(and different) location for different conda environments.
I am not using any external scripts for the installation. It's vanilla pip install and also tried python -m pip install. Also tried to install with conda. In all of these cases, installing it for env1 will uninstall it from env2 and vice versa. No matter from which env I am installing, all envs will use the same version that was installed last.
Not sure if it's relevant, but I am using WSL2.
What could go wrong? What else should I check?
I still have no idea what is causing this behavior but at least found a workaround - using pip --ignore-installed option:
conda activate your_target_env
pip install --ignore-installed torch torchvision torchaudio
This will not uninstall other versions of pytorch installed inside other conda environments. And both environments will work with their versions of pytorch.

If Anaconda comes with pip, why do instructions suggest installing it?

I have just installed Anaconda with Python3.7 on my Ubuntu 18.04. Ubuntu 18.04 comes with Python3.6 by default (but not pip).
After installing Anaconda and reading its documentation, I can see that Anaconda comes with both conda and pip. This is the case, as I can see:
$ which pip
# Output: /home/user-name/anaconda3/bin/pip
$ pip --version
# Output:
pip 10.0.1 from /home/user-name/anaconda3/lib/python3.7/site-packages/pip (python 3.7)
However, I am confused when reading the instructions from this link:
https://conda.io/docs/user-guide/tasks/manage-pkgs.html#installing-non-conda-packages
On one hand it says: " Both pip and conda are included in Anaconda and Miniconda, so you do not need to install them separately." => That's the pip I can see in my commands above.
But on the other hand it says: " It is possible to have pip installed outside a conda environment or inside a conda environment. To gain the benefits of conda integration, be sure to install pip inside the currently active conda environment, and then install packages with that instance of pip. The command conda list shows packages installed this way, with a label showing that they were installed with pip.
So I'm confused:
I clearly got a version of pip when installing Anaconda and I can see in /home/user-name/anaconda3/bin
But if I want to use pip to install a package, I need to install pip in my environment using $ conda install pip and then $ pip install package (all of this in my normal Ubuntu terminal).
I don't understand how this makes sense..
Many thanks!

What's the difference between pip3 and pip?

I know that pip3 refers to python3 and pip refers to python2.
When I use anaconda environment and set the python version as 3.5, I install a package names itchat as following.
pip3 install itchat
The installation goes on successfully without any errors.
But when I type the following commands, strange things happen.
But if I just use pip install itchat and type python instead of python3, things go on as I think.
I am wondering what leads to this result.
Why there is the difference between python and python3?
Thanks for providing your answers!
I don't see you using conda environment.
Create an environment
conda create -n myenv
activate the envinronment:
conda activate myenv
and then install the package
conda install itchat
or
pip install itchat

What is the effect of using pip to install python packages on anaconda?

I have installed a fresh anaconda v4.4. I realized that python packages can be installed using both conda and pip. What is the effect of using pip to install python packages instead of conda when using anaconda? Will the pip-installed libraries cease to function? I am using python v3
EDIT: I don't think the question is a duplicate of What is the difference between pip and conda?
That question explains the difference between pip and conda but does not talk about the effect of using pip when conda can be used.
Everything might keep working if you use pip to install vs conda. However, Conda cannot manage dependencies that pip has installed - it cannot upgrade them, or remove them. More importantly, conda will install a package even if its already been installed with pip! Try this test:
conda create -n testenv python=3
conda activate testenv
pip install numpy
conda install scipy
You will see from the third command that conda will want to re-install NumPy, even though it has already been installed with pip. This can cause problems if there are C libraries whose linking is different, or something like that. In general, whenever possible, use conda to install packages into conda environments.

how to get opencv_contrib module in anaconda

Can anyone tell me commands to get contrib module for anaconda
I need that module for
matches = flann.knnMatch(des1,des2,k=2)
to run correctly
error thrown is
cv2.error: ......\modules\python\src2\cv2.cpp:163: error: (-215) The data should normally be NULL! in function NumpyAllocator::allocate
Also I am using Anaconda openCV version 3, and strictly dont want to switch to lower versions
P.S. as suggested at many places to edit file cv2.cpp option is not available with anaconda.
I would recommend installing pip in your anaconda environment then just doing: pip install opencv-contrib-python. This comes will opencv and opencv-contrib.
Anaconda supports pip install to install package into conda environment. You can download OpenCV 3.2.0 with opencv_contrib from this well known Unofficial Windows Binaries for Python Extension Packages website. See the filename below for the right version. Then type the command in Anaconda Prompt window to install the package:
For Python 3.5 and 64-bit Windows:
pip install opencv_python‑3.2.0+contrib‑cp35‑cp35m‑win_amd64.whl
For Python 3.6 and 64-bit Windows:
pip install opencv_python‑3.2.0+contrib‑cp36‑cp36m‑win_amd64.whl
Most of the OpenCV 3.2.0 packages in Anaconda repository didn't specific if they come with opencv_contrib. The pip install approach is easier and proven, see one of the SO post. The only drawback is that conda list will not show pip installed package there but actually it's.
However, if you want to have trial on conda install, below is the command for installing OpenCV 3.2.0 for Python 3.5 or 3.6 but likely without opencv_contrib.
conda install -c conda-forge opencv=3.2.0
Hope this help.
You can try this: https://anaconda.org/michael_wild/opencv-contrib
To install this package with conda run:
conda install -c michael_wild opencv-contrib
These anaconda packages include the contrib modules with base OpenCV3. Though the file list says it's currently for Windows only!
The question is old but I thought to update the answer with the latest information. My Anaconda version is 2019.10 and build channel is py_37_0 . I used pip install opencv-python==3.4.2.17 and pip install opencv-contrib-python==3.4.2.17. Now they are also visible as installed packages in Anaconda navigator and I am able to use patented methods like SIFT etc.
Method 1: in Anaconda Prompt write this, will install opencv-contrib v4.6
pip install opencv-contrib-python
Method 2: Install previous version of opencv-contrib v3.3.1
According to https://anaconda.org/michael_wild/opencv-contrib it says it support win64bit only and python 3.6.x.
So, first you need to create new enviroment support python 3.6
conda create --opencv_contrib36 python=3.6.13
then, install the packages
conda install -c michael_wild opencv-contrib
There is repo in conda-forge which includes opencv-contrib: https://github.com/conda-forge/opencv-feedstock
To use it:
conda install --channel=conda-forge libopencv opencv py-opencv
if you run into Numpy error, try pinning more recent version (of Numpy).
This worked for me in Windows 10 on Anaconda 5.3 with python 3.6
conda install -c conda-forge opencv

Categories