简体   繁体   English

pip3 版本安装 package 到不同的目录

[英]pip3 version installing package into different directory

I recently set up a new version of Python 3.11 in my system using Homebrew, the pip3 that came with it seems to be installing into the wrong target (numpy package is used as an example):我最近使用 Homebrew 在我的系统中设置了一个新版本 Python 3.11,它附带的 pip3 似乎安装到错误的目标中(以 numpy package 为例):

python3.11 -m pip install numpy
Collecting numpy
  Using cached numpy-1.24.1-cp311-cp311-macosx_10_9_x86_64.whl (19.8 MB)
Installing collected packages: numpy
Successfully installed numpy-1.24.1
WARNING: Target directory /usr/local/lib/python3.11/site-packages/pip/numpy-1.24.1.dist-info already exists. Specify --upgrade to force replacement.
WARNING: Target directory /usr/local/lib/python3.11/site-packages/pip/numpy already exists. Specify --upgrade to force replacement.
WARNING: Target directory /usr/local/lib/python3.11/site-packages/pip/bin already exists. Specify --upgrade to force replacement.

The Python3 pip list and uninstall command shows that the package is uninstalled: Python3 pip list and uninstall 命令显示package被卸载:

python3.11 -m pip list
Package    Version
---------- -------
pip        22.3.1
setuptools 65.6.3
wheel      0.38.4

---------- ----------------- ----------------- ----------------- ----------------- -----------
python3.11 -m pip uninstall numpy
WARNING: Skipping numpy as it is not installed.

The locations of my Python 3.11 and pip3.11 are:我的 Python 3.11 和 pip3.11 的位置是:

which python3.11
/usr/local/bin/python3.11
---------- ----------------- ----------------- ----------------- ----------------- -----------
which pip3.11
/usr/local/bin/pip3.11
---------- ----------------- ----------------- ----------------- ----------------- -----------
pip3.11 --version
pip 22.3.1 from /usr/local/lib/python3.11/site-packages/pip (python 3.11)

I've tried installing different versions of Python (3.9 & 3.10) but all of it suffers from the error shown, the pip3 command keeps targeting the wrong directory.我已经尝试安装不同版本的 Python(3.9 和 3.10),但所有版本都出现了显示的错误,pip3 命令一直指向错误的目录。

I've also tried the following command:我还尝试了以下命令:

python3.11 -m pip install --upgrade --force-reinstall pip

but it doesn't seem to work.但它似乎不起作用。

You can try reinstalling Python 3.11 using Homebrew, and then make sure that the python3.11 executable and the pip3.11 executable are pointing to the same location by running which python3.11 and which pip3.11 commands.您可以尝试使用 Homebrew 重新安装 Python 3.11,然后通过运行 which python3.11 和 which pip3.11 命令确保 python3.11 可执行文件和 pip3.11 可执行文件指向相同的位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM