gpt4 book ai didi

python - 如何让pip将包安装到虚拟环境中?

转载 作者:太空狗 更新时间:2023-10-29 17:49:57 25 4
gpt4 key购买 nike

在 Windows 8 上,我有一个 Python 3 项目的以下结构:

../Project/
../Project/app/app.py
../Project/app/setup.py

在应用程序文件夹中,我调用以下命令来创建并进入虚拟环境:

pyvenv.py venv
cd venv\Scripts
activate.bat
cd ../..

现在我想将 Nose 单元测试框架安装到我的虚拟环境中:

pip install nose

... 并且 Nose 安装到全局文件夹中(在我的例子中,C:\Python33)。

当我调用 python setup.py install 时,我的自定义模块会安装到虚拟环境中。为什么 PIP 不这样做?

最佳答案

在关注 docs 后对我来说效果很好:

Common installation tools such as Distribute and pip work as expected with venvs - i.e. when a venv is active, they install Python packages into the venv without needing to be told to do so explicitly. Of course, you need to install them into the venv first: this could be done by running distribute_setup.py with the venv activated, followed by running easy_install pip. Alternatively, you could download the source tarballs and run python setup.py install after unpacking, with the venv activated.

关于python - 如何让pip将包安装到虚拟环境中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19853855/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com