1

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.

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.

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.

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?

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

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.

Thanks!

dylkot
  • 2,275
  • 2
  • 20
  • 24
  • Sorry if this too obvious, but when you run ipython, are you running it from within the virtualenv (ie: after running activate) ? – user590028 Aug 06 '14 at 21:00
  • typing "which ipython" points to the correct ipython within the virtualenv – dylkot Aug 06 '14 at 21:05

2 Answers2

0

You could try using the pkg_resources from setuptools:

import pkg_resources
pkg_resources.require("Tornado==4.0.0")
import tornado
celeritas
  • 2,191
  • 1
  • 17
  • 28
  • For one thing I would have to tell ipython to do this as well. But even just trying it in a python window, I get the error: File "build/bdist.linux-i686/egg/pkg_resources.py", line 666, in require unloadable plugin distributions to an exception instance describing the File "build/bdist.linux-i686/egg/pkg_resources.py", line 569, in resolve doesn't already have a distribution in the set. If it's added, any pkg_resources.VersionConflict: (tornado 2.4 (/insitutionspath.../pkgs/python_2.7.1-sqlite3-rtrees/lib/python2.7/site-packages/tornado-2.4-py2.7.egg), Requirement.parse('Tornado==4.0.0')) – dylkot Aug 06 '14 at 21:06
0

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 is present in the python2.7 directory

and

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

dylkot
  • 2,275
  • 2
  • 20
  • 24