【发布时间】:2018-08-23 20:34:44
【问题描述】:
我当前的 bash shell 加载了 python3,但偶尔我倾向于运行旧的 python2 脚本,我得到这个错误
python/2.7.10/bin/python:加载共享库时出错:libpython2.7.so.1.0:无法打开共享对象文件:没有这样的文件或目录”
所以每次我都必须来回加载 python2。有没有办法通过更改任何环境变量在 python3 环境中运行 python2 脚本?
【问题讨论】:
-
当你说你正在“加载”python2是什么意思?
-
这可能会对你有所帮助,@Gopinath:stackoverflow.com/questions/20842732/…
-
@Scott Skiles。通过加载,我的意思是选择集群中可用的 python 版本之一。感谢您的链接,我确实尝试过,但它似乎对我不起作用。
-
运行
which python、which python2、which python3会得到什么?一般: (1) 不要同时使用 python2 和 python3。 (2) 用户应在旧的 python 脚本中指定要使用的 python 版本。如果是这种情况,您可以安装一个 virtualenv,例如 conda。 (3) 需要时,可以快速从python3虚拟环境切换到python2虚拟环境。
标签: python python-3.x bash python-2.7