gpt4 book ai didi

python - VirtualEnv 没有正确设置路径,无法使用已安装的模块

转载 作者:太空狗 更新时间:2023-10-30 01:19:53 24 4
gpt4 key购买 nike

简短版本:如何让 PyQt4 的 configure.py 使用安装在虚拟环境中的 SIP 版本?

长版:我知道这个问题的变体在这里被问过一百万次,但我似乎找不到答案。我正在尝试在虚拟环境 (VE) 中安装 SIP 和 PyQt4。我无法将它安装到主系统,因为它是一台工作计算机。我们有一个旧版本的 PyQt,所以我不能只从站点包中复制。

我已经在我的 VE 中安装了 SIP(​​configure.py --incdir,make,make install)但是当我在 PyQt4 上运行 configure 时我收到错误:错误:此版本的 PyQt 需要 SIP v4.19.0 或更高版本.我安装了 4.19.2 版。当运行 sipconfig 时,它告诉我它仍在使用系统版本,即使 VE 已激活。我如何告诉 PyQt 的 configure.py 使用安装在 VE 中的包?

谢谢大家!

编辑:从外观上看,我的 VE 似乎没有从正确的位置拉取 python 库,即使 VE 已激活。我添加了一行以激活将站点包和 bin 目录附加到 pythonpath 的路径和站点包,但没有成功。它仍然没有找到正确的库。

最佳答案

在您的虚拟环境中安装 pip。并使用 which pip 检查 pip 是否使用了正确的目录.如果它没有使用正确的目录,试试这个:

pip install --target=<location of site packages of your pip in your virtual env> sip==4.19

如果你得到一个名为 permission denied 的错误,使用

sudo chown -R your_username:your_username path/to/virtuaelenv/

然后做:

pip install PyQt4

如果以上方法均无效,请按照以下说明操作:

http://movingthelamppost.com/blog/html/2013/07/12/installing_pyqt____because_it_s_too_good_for_pip_or_easy_install_.html

关于python - VirtualEnv 没有正确设置路径,无法使用已安装的模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43354155/

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