setting PYTHONPATH to override system wide site-packages
hi all, i recently installed a new version of a package using python setup.py install --prefix=/my/homedir on a system where i don't have root access. the old package still resides in /usr/lib/python2.5/site- packages/ and i cannot erase it. i set my python path as follows in ~/.cshrc setenv PYTHONPATH /path/to/newpackage but whenever i go to python and import the module, the version in site- packages is loaded. how can i override this setting and make it so python loads the version of the package that's in my home dir? thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: setting PYTHONPATH to override system wide site-packages
On Feb 28, 7:30 pm, per perfr...@gmail.com wrote: hi all, i recently installed a new version of a package using python setup.py install --prefix=/my/homedir on a system where i don't have root access. the old package still resides in /usr/lib/python2.5/site- packages/ and i cannot erase it. i set my python path as follows in ~/.cshrc setenv PYTHONPATH /path/to/newpackage but whenever i go to python and import the module, the version in site- packages is loaded. how can i override this setting and make it so python loads the version of the package that's in my home dir? What happens when you run the command print sys.path from the Python prompt? /path/to/newpackage should be the second item, and shoud be listed in front of the site-packages dir. What happens when you run print os.eviron['PYTHONPATH'] at the Python interpreter? It's possible that the sysadmin installed a script that removes PYTHONPATH environment variable before invoking Python. What happens when you type which python at the csh prompt? What happens when you type ls /path/to/newpackage at your csh prompt? Is the module you're trying to import there? You approach should work. These are just suggestions on how to diagnose the problem; we can't really help you figure out what's wrong without more information. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Re: setting PYTHONPATH to override system wide site-packages
On Feb 28, 11:24 pm, Carl Banks pavlovevide...@gmail.com wrote: On Feb 28, 7:30 pm, per perfr...@gmail.com wrote: hi all, i recently installed a new version of a package using python setup.py install --prefix=/my/homedir on a system where i don't have root access. the old package still resides in /usr/lib/python2.5/site- packages/ and i cannot erase it. i set my python path as follows in ~/.cshrc setenv PYTHONPATH /path/to/newpackage but whenever i go to python and import the module, the version in site- packages is loaded. how can i override this setting and make it so python loads the version of the package that's in my home dir? What happens when you run the command print sys.path from the Python prompt? /path/to/newpackage should be the second item, and shoud be listed in front of the site-packages dir. What happens when you run print os.eviron['PYTHONPATH'] at the Python interpreter? It's possible that the sysadmin installed a script that removes PYTHONPATH environment variable before invoking Python. What happens when you type which python at the csh prompt? What happens when you type ls /path/to/newpackage at your csh prompt? Is the module you're trying to import there? You approach should work. These are just suggestions on how to diagnose the problem; we can't really help you figure out what's wrong without more information. Carl Banks hi, i am setting it programmatically now, using: import sys sys.path = [] sys.path now looks exactly like what it looked like before, except the second element is my directory. yet when i do import mymodule print mymodule.__version__ i still get the old version... any other ideas? -- http://mail.python.org/mailman/listinfo/python-list
Re: setting PYTHONPATH to override system wide site-packages
On Feb 28, 11:53 pm, per perfr...@gmail.com wrote: On Feb 28, 11:24 pm, Carl Banks pavlovevide...@gmail.com wrote: On Feb 28, 7:30 pm, per perfr...@gmail.com wrote: hi all, i recently installed a new version of a package using python setup.py install --prefix=/my/homedir on a system where i don't have root access. the old package still resides in /usr/lib/python2.5/site- packages/ and i cannot erase it. i set my python path as follows in ~/.cshrc setenv PYTHONPATH /path/to/newpackage but whenever i go to python and import the module, the version in site- packages is loaded. how can i override this setting and make it so python loads the version of the package that's in my home dir? What happens when you run the command print sys.path from the Python prompt? /path/to/newpackage should be the second item, and shoud be listed in front of the site-packages dir. What happens when you run print os.eviron['PYTHONPATH'] at the Python interpreter? It's possible that the sysadmin installed a script that removes PYTHONPATH environment variable before invoking Python. What happens when you type which python at the csh prompt? What happens when you type ls /path/to/newpackage at your csh prompt? Is the module you're trying to import there? You approach should work. These are just suggestions on how to diagnose the problem; we can't really help you figure out what's wrong without more information. Carl Banks hi, i am setting it programmatically now, using: import sys sys.path = [] sys.path now looks exactly like what it looked like before, except the second element is my directory. yet when i do import mymodule print mymodule.__version__ i still get the old version... any other ideas? in case it helps, it gives me this warning when i try to import the module /usr/lib64/python2.5/site-packages/pytz/__init__.py:29: UserWarning: Module dateutil was already imported from /usr/lib64/python2.5/site- packages/dateutil/__init__.pyc, but /usr/lib/python2.5/site-packages is being added to sys.path from pkg_resources import resource_stream -- http://mail.python.org/mailman/listinfo/python-list
Re: setting PYTHONPATH to override system wide site-packages
On Feb 28, 9:18 pm, per perfr...@gmail.com wrote: On Feb 28, 11:53 pm, per perfr...@gmail.com wrote: On Feb 28, 11:24 pm, Carl Banks pavlovevide...@gmail.com wrote: On Feb 28, 7:30 pm, per perfr...@gmail.com wrote: hi all, i recently installed a new version of a package using python setup.py install --prefix=/my/homedir on a system where i don't have root access. the old package still resides in /usr/lib/python2.5/site- packages/ and i cannot erase it. i set my python path as follows in ~/.cshrc setenv PYTHONPATH /path/to/newpackage but whenever i go to python and import the module, the version in site- packages is loaded. how can i override this setting and make it so python loads the version of the package that's in my home dir? What happens when you run the command print sys.path from the Python prompt? /path/to/newpackage should be the second item, and shoud be listed in front of the site-packages dir. What happens when you run print os.eviron['PYTHONPATH'] at the Python interpreter? It's possible that the sysadmin installed a script that removes PYTHONPATH environment variable before invoking Python. What happens when you type which python at the csh prompt? What happens when you type ls /path/to/newpackage at your csh prompt? Is the module you're trying to import there? You approach should work. These are just suggestions on how to diagnose the problem; we can't really help you figure out what's wrong without more information. Carl Banks hi, i am setting it programmatically now, using: import sys sys.path = [] sys.path now looks exactly like what it looked like before, except the second element is my directory. yet when i do import mymodule print mymodule.__version__ i still get the old version... any other ideas? in case it helps, it gives me this warning when i try to import the module /usr/lib64/python2.5/site-packages/pytz/__init__.py:29: UserWarning: Module dateutil was already imported from /usr/lib64/python2.5/site- packages/dateutil/__init__.pyc, but /usr/lib/python2.5/site-packages is being added to sys.path from pkg_resources import resource_stream Ok then. When pkg_resources is involved, who knows what behavior to expect. pkg_resources.py is a third-party module from PEAK (which unfortunately a number of other third-party packages depend on, so it can be hard to keep your installation free of it, but I digress). Among other things no one knows about, it's a sort of run-time package version management system. It's possible, maybe, that some module that runs on startup specifically requested and imported the version of dateutils that's on the system path. Which means, if you don't properly appease pkg_resources, it could actually ignore your version of the package even if it's earlier in the system path. This is only speculation, because who actually knows what's in the mind of pkg_resources?, but if that is the reason, I won't be the one to tell you how to fix it. Here's something to try, however. Set up your PYTHONPATH as you did before, but also create an empty pkg_resources.py file in the directory you specified. Warning: this might make some packages unusable. Not-a-fan-of-pkg_resources-ly y'rs, Carl Banks -- http://mail.python.org/mailman/listinfo/python-list