pip Specifies how to install packages at python locations

  • 2021-07-18 08:16:45
  • OfStack

Because multiple versions of pip are installed on your computer, and different pip correspond to different python, sometimes when you install a package using pip install, it may not be installed in the desired location.

Specifically, on my computer, when I run pip-version, the output is as follows


pip 9.0.1 from /opt/anaconda3/lib/python3.6/site-packages (python 3.6)

When you run sudo pip--version, the output is as follows


pip 18.0 from /usr/local/lib/python3.5/dist-packages/pip (python 3.5)

When I used the command pip install scedar, I prompted that there was a problem with permissions, and then added sudo permissions. When I installed sudo pip install scedar, it was installed in the package of python 3.5, but I actually used python 3.6, so I prompted that the package did not exist when I imported it.

To solve this problem, you only need to use the directive-t to specify the installation path during installation, as follows


sudo pip install -t /opt/anaconda3/lib/python3.6/site-packages scedar

This allows the required package to be installed in the specified location, which resolves the python version error problem


Related articles: