virtualenv 找不到更新的模块 [英] virtualenv not finding updated module

查看:24
本文介绍了virtualenv 找不到更新的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在没有 root 访问权限的 unix 服务器上使用 virtualenv 运行 python-2.7.我使用 pip install tornado --upgrade 更新了模块 tornado,因为安装 ipython 需要 tornado >= 3.1.0 但服务器上默认只安装了 2.4 版.但是,当我尝试打开 ipython 时,它仍然抱怨我没有更新版本.

I am running python-2.7 with virtualenv on a unix server to which I do not have root access. I updated the module tornado using pip install tornado --upgrade because installing ipython required tornado >= 3.1.0 but only version 2.4 was installed by default on the server. However, when I try to open ipython, it still complains that I don't have the updated version.

我确认 ipython 被正确地命名为 virtualenv,并且升级确实在 virtualenv 的站点包中产生了 Tornado 4.0 版.

I confirmed that ipython is correctly aliased to the virtualenv, and that the upgrade had indeed produced tornado version 4.0 in the site-packages of the virtualenv.

但是,如果我打开 python(正确别名为 virtualenv)并导入 tornado,我发现它正在从我的 virtualenv 导入早期版本 (2.4) 而不是较新版本.导入另一个仅安装在 virtualenv 上的包会正确地从 virtualenv 的站点包中导入它.

However if I open python (correctly aliased to the virtualenv) and import tornado, I find that it is importing the earlier version (2.4) and not the newer version from my virtualenv. Importing another package that was only installed on the virtualenv correctly imports it from the site-packages of the virtualenv.

知道我应该如何告诉 python 默认使用更新版本的 tornado 而不是 virtualenv 上没有的早期版本吗?

Any idea how I should tell python to use the updated version of tornado by default instead of the earlier version that isn't on the virtualenv?

我尝试过的一件非常棘手的事情是将以下内容附加到我的 virtualenv 激活文件中:

One really hacky thing that I tried was appending to my virtualenv activate file the following:

PYTHONPATH=path_to_standardVE/lib/python2.7/site-packages/tornado:$PYTHONPATH

PYTHONPATH=path_to_standardVE/lib/python2.7/site-packages/tornado:$PYTHONPATH

如果我在启动时检查 $PYTHONPATH,它确实在前面包含了这个路径.但是,在python中加载模块仍然加载2.4版本.

If I check $PYTHONPATH upon startup, it indeed contains this path at the front. However, loading the module in python still loads the 2.4 version.

谢谢!

推荐答案

会不会是 virtualEnv 继承了全局站点包?我不确定在设置 virtualEnv 时是否添加了 -no-site-packages.现在有什么简单的方法可以解决此设置或测试这种可能性吗?

Could it be that the virtualEnv is inheriting the global site-packages? I'm not sure if I added -no-site-packages when I set up the virtualEnv. Is there an easy way to address this setting now or to test this possibility?

no-global-site-packages.txt 存在于 python2.7 目录中

no-global-site-packages.txt is present in the python2.7 directory

orig-prefix.txt 包含正在加载的旧版 tornado 的 virtualenv 之外的父目录

orig-prefix.txt contains a parent directory outside of the virtualenv of the older version of tornado that is being loaded

这篇关于virtualenv 找不到更新的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆