gpt4 book ai didi

python - pip 选项 "--force-reinstall"是否重新编译模块? (我正在尝试重新安装cx_Oracle)

转载 作者:行者123 更新时间:2023-12-01 03:33:31 29 4
gpt4 key购买 nike

我的设置有:

- oracle-instantclient (downgraded from 12 to 11)
- Virtual Environment with Python + Django + cx_Oracle

当我降级 oracle-instantclient 时,我尝试使用以下方法重新安装 cx_oracle:

pip install --upgrade --force-reinstall cx_Oracle

问题是 cx_Oracle 一直提示我没有使用以前安装的版本 12:

$ python -c "import cx_Oracle"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: libclntsh.so.12.1: cannot open shared object file: No such file or directory

所以,这里有一些问题:“--force-reinstall”不应该进行完全重新安装,包括模块重新编译(又名 cx_Oracle)?有人对如何解决这个问题有一些建议吗?我看了pip manual只是告诉我它会重新安装该软件包。不是很有用。

更新1:

我尝试遵循解决方案 here ,将我的 cx_Oracle 路径添加到 LD_LIBRARY_PATH 但它仍然不起作用。

echo $LD_LIBRARY_PATH
/usr/lib/oracle/11.2/client64/lib:/home/myuser/myuserenv/lib/python3.5/site-packages/cx_Oracle-5.2.1.dist-info

请注意,我的 root 用户有不同的 python,而我的 virtualenv 使用自己的 python 安装。

[root@myserver]# which python
/usr/bin/python

来 self 的虚拟环境:

(myvirtualenv) [myuser@myserver]$ which python
~/myvirtualenv/bin/python

是否有某种方法可以使用 root 用户手动安装 cx_Oracle,但以某种方式将文件放在虚拟环境中?

更新2:

我尝试下载 cx_Oracle 并使用以下命令手动编译:

sudo -u myuser ~/myvirtualenv/bin/python setup.py build install

但现在我看到一些权限错误:

(...)
error: could not create 'build/bdist.linux-x86_64/egg': Permission denied

我做的事情正确吗?我不想破坏这个环境。谢谢。

最佳答案

您的问题的答案(尽管您似乎遇到了另一个问题)如下:这取决于模块的结构。如果它的安装脚本调用编译器,那么它确实会调用。因为,您会看到,pip 模块默认情况下不包含已编译的部分,因此由模块作者提供它们。

关于python - pip 选项 "--force-reinstall"是否重新编译模块? (我正在尝试重新安装cx_Oracle),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40598029/

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