简体   繁体   English

如何控制 pip3 安装软件包的位置?

[英]How do I control where pip3 installs packages?

I updated pip3 and now packages are being installed for python 3.8 and not 3.9.我更新了 pip3,现在正在为 python 3.8 而不是 3.9 安装软件包。 What do I do to make it so that packages are installed to where they used to be installed?我该怎么做才能将软件包安装到它们以前安装的位置?

I updated pip3 today using the command pip3 install --upgrade pip and then installed a new package with pip3 install statsmodels which did indeed install the package. I checked the install location with pip3 list -v and saw that the package and its dependencies were installed to /Users/myusername/Library/Python/3.8/lib/python/site-packages.我今天使用命令pip3 install --upgrade pip更新了 pip3,然后使用pip3 install statsmodels安装了一个新的 package,它确实安装了 package。我用pip3 list -v检查了安装位置,发现 package 及其依赖项已安装到 /Users/myusername/Library/Python/3.8/lib/python/site-packages。

The problem is... this is not where my other packages are.问题是……这不是我的其他包裹所在的地方。 pip3 list -v doesn't show any of the packages I've installed in the past (for example, I know I have matplotlib installed but it doesn't show up). pip3 list -v没有显示我过去安装的任何软件包(例如,我知道我安装了 matplotlib 但它没有显示)。 I only use python 3.9, so I don't want any of my packages being installed for python 3.8 but don't know how to fix this.我只使用 python 3.9,所以我不想为 python 3.8 安装我的任何软件包,但不知道如何解决这个问题。

If you want to change your default installation target如果你想改变你的默认安装目标

The --target switch is the thing you're looking for: --target开关是你要找的东西:

pip config set global.target /Users/Bob/Library/Python/3.8/lib/python/site-packages

Installs packages into directory provied.将软件包安装到提供的目录中。 By default this will not replace existing files/folders in the directory.默认情况下,这不会替换目录中的现有文件/文件夹。 Use --upgrade to replace existing packages in with new versions.使用--upgrade将现有包替换为新版本。

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

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