From: Ryan G. <rn...@co...> - 2004-06-07 20:36:39
|
Hi all, I'm trying to install Numerical Python without root access, and I'm having great difficulty. I'm running Python 2.2.2 (which was installed systemwide by root). I used 'python setup.py install --prefix ~/installed' to install numpy and I have ~/installed/lib/python2.2/site-packages in my PYTHONPATH. Initially 'import' was failing, but creating an empty __init.py__ in site-packages/Numeric seems to have fixed that. I still can't seem to use any of the functions, though. I get errors like: Python 2.2.2 (#1, Nov 22 2002, 17:25:34) [GCC 2.96 20000731 (Red Hat Linux 7.3 2.96-112)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import Numeric >>> a = array([1.2, 3.5, -1]) Traceback (most recent call last): File "<stdin>", line 1, in ? NameError: name 'array' is not defined >>> a = Numeric.array([1.2, 3.5, -1]) Traceback (most recent call last): File "<stdin>", line 1, in ? AttributeError: 'module' object has no attribute 'array' I'm new at python, and am completely perplexed. Perhaps I need a more complete __init.py__? Thanks in advance, Ryan -- Ryan Gutenkunst | Cornell Dept. of Physics | "It is not the mountain | we conquer but ourselves." Clark 535 / (607)255-6068 | -- Sir Edmund Hillary AIM: JepettoRNG | http://www.physics.cornell.edu/~rgutenkunst/ |
From: Jeffery D. C. <jco...@ea...> - 2004-06-07 21:14:36
|
On Monday 07 June 2004 02:36 pm, Ryan Gutenkunst wrote: > Hi all, > > I'm trying to install Numerical Python without root access, and I'm > having great difficulty. > > I'm running Python 2.2.2 (which was installed systemwide by root). I > used 'python setup.py install --prefix ~/installed' to install numpy and > I have ~/installed/lib/python2.2/site-packages in my PYTHONPATH. Maybe this will work: eliminate the __init__.py (and __init__.pyc) that you created and add the following to your PATH instead: ~/installed/lib/python2.2/site-packages/Numeric > > Initially 'import' was failing, but creating an empty __init.py__ in > site-packages/Numeric seems to have fixed that. I still can't seem to > use any of the functions, though. I get errors like: > > Python 2.2.2 (#1, Nov 22 2002, 17:25:34) > [GCC 2.96 20000731 (Red Hat Linux 7.3 2.96-112)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > > >>> import Numeric > >>> a = array([1.2, 3.5, -1]) > > Traceback (most recent call last): > File "<stdin>", line 1, in ? > NameError: name 'array' is not defined > > >>> a = Numeric.array([1.2, 3.5, -1]) > > Traceback (most recent call last): > File "<stdin>", line 1, in ? > AttributeError: 'module' object has no attribute 'array' > > I'm new at python, and am completely perplexed. Perhaps I need a more > complete __init.py__? > > Thanks in advance, > Ryan -- Jeff |
From: Robert K. <rk...@uc...> - 2004-06-07 21:35:17
|
Ryan Gutenkunst wrote: > Hi all, > > I'm trying to install Numerical Python without root access, and I'm > having great difficulty. Ryan! Long time, no see. Good to see you're joining in on the Python fun. > I'm running Python 2.2.2 (which was installed systemwide by root). I > used 'python setup.py install --prefix ~/installed' to install numpy and > I have ~/installed/lib/python2.2/site-packages in my PYTHONPATH. > > Initially 'import' was failing, but creating an empty __init.py__ in > site-packages/Numeric seems to have fixed that. No good. Numeric isn't a package (in the technical sense of a collection of modules all in a directory that has an __init__.py, etc.). Check for the existence of the file ~/installed/lib/python2.2/site-packages/Numeric.pth . It should have one line saying, "Numeric". When the interpreter starts up, it scans what's in the PYTHONPATH and the defaults paths. When it encounters .pth files, it automatically adds the paths named in them to the PYTHONPATH. You can also try adding ~/installed/lib/python2.2/site-packages/Numeric directly to your PYTHONPATH. If you have more problems, you can contact me off-list; I'll take care of you. -- Robert Kern rk...@uc... "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter |
From: Fernando P. <Fer...@co...> - 2004-06-07 23:40:27
|
Ryan Gutenkunst wrote: > Hi all, > > I'm trying to install Numerical Python without root access, and I'm > having great difficulty. > > I'm running Python 2.2.2 (which was installed systemwide by root). I > used 'python setup.py install --prefix ~/installed' to install numpy and > I have ~/installed/lib/python2.2/site-packages in my PYTHONPATH. > > Initially 'import' was failing, but creating an empty __init.py__ in > site-packages/Numeric seems to have fixed that. I still can't seem to > use any of the functions, though. I get errors like: Don't do this, it's a bit tricky to get it right. You're stuck in .pth hell, because Numeric is not a true python package, and python only picks up .pth files in a few locations in the filesystem (NOT in all of your pythonpath). Since those locations are all root-only, you'll need to add explicitly ~/installed/lib/python2.2/site-packages/Numeric to your PYTHONPATH for things to work smoothly. If you insist, here's a hacked __init__.py to fake what you are looking for: littlewood[Numeric]> cat __init__.py # fperez. Hack to make Numeric behave like a real package, regardless of where it's # installed. This is needed because Numeric relies on a .pth file for path # manipulations, but those are ONLY scanned in sys.prefix, not for all paths in # PYTHONPATH. import sys sys.path.append('/usr/local/lib/python/Numeric') #put what you need here from Numeric import * #--------------- fix the linebreaks above before using Unfortunately it doesn't look like Numeric will become a true python package, so we're stuck with these hacks. Welcome to the club of .pth haters :) Cheers, f |