Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > module error in Vista -- works as administrator

Reply
Thread Tools

module error in Vista -- works as administrator

 
 
sawilla
Guest
Posts: n/a
 
      04-21-2008
First, I'm new to Python. I'm getting and error when I run Python
2.5.2 as a regular user in Vista but not when I run Python as an
administrator.

For example, if I type "import numpy" after I launch python from an
adminstrator-privileged command window it loads fine. However, from a
regular-user command window I get:

>>> import numpy

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named numpy

Thanks in advance for your help.

Reg
 
Reply With Quote
 
 
 
 
John Machin
Guest
Posts: n/a
 
      04-21-2008
sawilla wrote:
> First, I'm new to Python. I'm getting and error when I run Python
> 2.5.2 as a regular user in Vista but not when I run Python as an
> administrator.
>
> For example, if I type "import numpy" after I launch python from an
> adminstrator-privileged command window it loads fine. However, from a
> regular-user command window I get:
>
>>>> import numpy

> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> ImportError: No module named numpy
>


Log on as administrator, start python in command window and do this:

import sys
sys.path # shows where python is looking for importables
import numpy
import os.path
print os.path.abspath(numpy.__file__) # shows where it found numpy

Log on as ordinary user, start python in command window and do this:

import sys
sys.path
# check how this is different from the admin's sys.path

If you can't see what to do after that, come back here with the output
from those steps.

HTH,
John
 
Reply With Quote
 
 
 
 
sawilla
Guest
Posts: n/a
 
      04-21-2008
On Apr 21, 5:42 pm, John Machin <(E-Mail Removed)> wrote:
> Log on as administrator, start python in command window and do this:
>
> import sys
> sys.path # shows where python is looking for importables
> import numpy
> import os.path
> print os.path.abspath(numpy.__file__) # shows where it found numpy
>
> Log on as ordinary user, start python in command window and do this:
>
> import sys
> sys.path
> # check how this is different from the admin's sys.path
>
> If you can't see what to do after that, come back here with the output
> from those steps.
>
> HTH,
> John


That was a great help, thank you. I now see what is causing the
problem but I don't know how to fix it. I used easy_install to install
several packages. When I run Python from an administrator command
window all of the directories in C:\Program Files\Python25\Lib\site-
packages\easy-install.pth are added to the sys.path. When I run it as
a regular user, those directories are not added to the sys.path and so
Python can't find the modules.

I know how to manually add those directories to Python's search path
but then I'll need to update the path every time I install something.
How do I get Python to automatically load the easy-install.pth file
for the regular user account?

Reg
 
Reply With Quote
 
John Machin
Guest
Posts: n/a
 
      04-21-2008
sawilla wrote:
> On Apr 21, 5:42 pm, John Machin <(E-Mail Removed)> wrote:
>> Log on as administrator, start python in command window and do this:
>>
>> import sys
>> sys.path # shows where python is looking for importables
>> import numpy
>> import os.path
>> print os.path.abspath(numpy.__file__) # shows where it found numpy
>>
>> Log on as ordinary user, start python in command window and do this:
>>
>> import sys
>> sys.path
>> # check how this is different from the admin's sys.path
>>
>> If you can't see what to do after that, come back here with the output
>> from those steps.
>>
>> HTH,
>> John

>
> That was a great help, thank you. I now see what is causing the
> problem but I don't know how to fix it. I used easy_install to install
> several packages. When I run Python from an administrator command
> window all of the directories in C:\Program Files\Python25\Lib\site-
> packages\easy-install.pth are added to the sys.path. When I run it as
> a regular user, those directories are not added to the sys.path and so
> Python can't find the modules.
>
> I know how to manually add those directories to Python's search path
> but then I'll need to update the path every time I install something.
> How do I get Python to automatically load the easy-install.pth file
> for the regular user account?
>
> Reg


"""
If you can't see what to do after that, come back here with the output
from those steps.
"""
in particular what is in sys.path for the non-admin user.
Also what are the access rights to the easy-install.pth file?

 
Reply With Quote
 
sawilla
Guest
Posts: n/a
 
      04-25-2008
The access writes to easy-install.pth for regular users is read and
execute.

The output of sys.path for regular users is:
['', 'C:\\Program Files\\Python25\\lib\\site-packages\
\setuptools-0.6c8-py2.5.eg
g', 'C:\\Program Files\\Python25\\python25.zip', 'C:\\Program Files\
\Python25\\D
LLs', 'C:\\Program Files\\Python25\\lib', 'C:\\Program Files\\Python25\
\lib\\pla
t-win', 'C:\\Program Files\\Python25\\lib\\lib-tk', 'C:\\Program Files\
\Python25
', 'C:\\Program Files\\Python25\\lib\\site-packages']

The output of sys.path for the admin user is:
['', 'C:\\Program Files\\Python25\\lib\\site-packages\
\setuptools-0.6c8-py2.5.eg
g', 'C:\\Program Files\\Python25\\lib\\site-packages\\networkx-0.36-
py2.5.egg',
'C:\\Program Files\\Python25\\lib\\site-packages\\numpy-1.0.4-py2.5-
win32.egg',
'C:\\Program Files\\Python25\\lib\\site-packages\\scipy-0.6.0-py2.5-
win32.egg',
'C:\\Program Files\\Python25\\lib\\site-packages\\matplotlib-0.91.2-
py2.5-win32.
egg', 'C:\\Program Files\\Python25\\lib\\site-packages\\dot2tex-2.7.0-
py2.5.egg'
, 'C:\\Program Files\\Python25\\lib\\site-packages\\pydot-1.0.2-
py2.5.egg', 'C:\
\Program Files\\Python25\\lib\\site-packages\\pyparsing-1.4.11-py2.5-
win32.egg',
'C:\\Program Files\\Python25\\python25.zip', 'C:\\Program Files\
\Python25\\DLLs
', 'C:\\Program Files\\Python25\\lib', 'C:\\Program Files\\Python25\
\lib\\plat-w
in', 'C:\\Program Files\\Python25\\lib\\lib-tk', 'C:\\Program Files\
\Python25',
'C:\\Program Files\\Python25\\lib\\site-packages']

The contents of easy-install.pth are:
import sys; sys.__plen = len(sys.path)
./setuptools-0.6c8-py2.5.egg
./networkx-0.36-py2.5.egg
./numpy-1.0.4-py2.5-win32.egg
./scipy-0.6.0-py2.5-win32.egg
./matplotlib-0.91.2-py2.5-win32.egg
./dot2tex-2.7.0-py2.5.egg
./pydot-1.0.2-py2.5.egg
./pyparsing-1.4.11-py2.5-win32.egg
import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:];
p=getattr(sys,
'__egginsert',0); sys.path[p]=new; sys.__egginsert = p+len(new)

The location where numpy is found:
>>> print os.path.abspath(numpy.__file__)

C:\Program Files\Python25\lib\site-packages\numpy-1.0.4-py2.5-win32.egg
\numpy\__
init__.pyc

So I believe I need to have the easy-install.pth file executed
automatically for regular users but I don't know how to do this.

Reg




On Apr 21, 7:29*pm, John Machin <(E-Mail Removed)> wrote:
> sawillawrote:
> > On Apr 21, 5:42 pm, John Machin <(E-Mail Removed)> wrote:
> >> Log on as administrator, start python in command window and do this:

>
> >> import sys
> >> sys.path # shows where python is looking for importables
> >> import numpy
> >> import os.path
> >> print os.path.abspath(numpy.__file__) # shows where it found numpy

>
> >> Log on as ordinary user, start python in command window and do this:

>
> >> import sys
> >> sys.path
> >> # check how this is different from the admin's sys.path

>
> >> If you can't see what to do after that, come back here with the output
> >> from those steps.

>
> >> HTH,
> >> John

>
> > That was a great help, thank you. I now see what is causing the
> > problem but I don't know how to fix it. I used easy_install to install
> > several packages. When I run Python from an administrator command
> > window all of the directories in C:\Program Files\Python25\Lib\site-
> > packages\easy-install.pth are added to the sys.path. When I run it as
> > a regular user, those directories are not added to the sys.path and so
> > Python can't find the modules.

>
> > I know how to manually add those directories to Python's search path
> > but then I'll need to update the path every time I install something.
> > How do I get Python to automatically load the easy-install.pth file
> > for the regular user account?

>
> > Reg

>
> """
> If you can't see what to do after that, come back here with the output
> from those steps.
> """
> in particular what is in sys.path for the non-admin user.
> Also what are the access rights to the easy-install.pth file?- Hide quoted text -
>
> - Show quoted text -


 
Reply With Quote
 
sawilla
Guest
Posts: n/a
 
      04-25-2008
I've discovered the cause of the problem. At some point previously,
Windows Vista had created a copy of the site-packages directory in a
virtual store for the user account. The easy-install.pth file in the
virtual store did not contain the same path information as the easy-
install.pth that the administrator account sees. I deleted the user's
Python25 directory in the virtual store and now the user's sys.path
contains all of the necessary paths.

Reg

On Apr 25, 12:04*pm, sawilla <(E-Mail Removed)> wrote:
> The access writes to easy-install.pth for regular users is read and
> execute.
>
> The output of sys.path for regular users is:
> ['', 'C:\\Program Files\\Python25\\lib\\site-packages\
> \setuptools-0.6c8-py2.5.eg
> g', 'C:\\Program Files\\Python25\\python25.zip', 'C:\\Program Files\
> \Python25\\D
> LLs', 'C:\\Program Files\\Python25\\lib', 'C:\\Program Files\\Python25\
> \lib\\pla
> t-win', 'C:\\Program Files\\Python25\\lib\\lib-tk', 'C:\\Program Files\
> \Python25
> ', 'C:\\Program Files\\Python25\\lib\\site-packages']
>
> The output of sys.path for the admin user is:
> ['', 'C:\\Program Files\\Python25\\lib\\site-packages\
> \setuptools-0.6c8-py2.5.eg
> g', 'C:\\Program Files\\Python25\\lib\\site-packages\\networkx-0.36-
> py2.5.egg',
> 'C:\\Program Files\\Python25\\lib\\site-packages\\numpy-1.0.4-py2.5-
> win32.egg',
> 'C:\\Program Files\\Python25\\lib\\site-packages\\scipy-0.6.0-py2.5-
> win32.egg',
> 'C:\\Program Files\\Python25\\lib\\site-packages\\matplotlib-0.91.2-
> py2.5-win32.
> egg', 'C:\\Program Files\\Python25\\lib\\site-packages\\dot2tex-2.7.0-
> py2.5.egg'
> , 'C:\\Program Files\\Python25\\lib\\site-packages\\pydot-1.0.2-
> py2.5.egg', 'C:\
> \Program Files\\Python25\\lib\\site-packages\\pyparsing-1.4.11-py2.5-
> win32.egg',
> *'C:\\Program Files\\Python25\\python25.zip', 'C:\\Program Files\
> \Python25\\DLLs
> ', 'C:\\Program Files\\Python25\\lib', 'C:\\Program Files\\Python25\
> \lib\\plat-w
> in', 'C:\\Program Files\\Python25\\lib\\lib-tk', 'C:\\Program Files\
> \Python25',
> 'C:\\Program Files\\Python25\\lib\\site-packages']
>
> The contents of easy-install.pth are:
> import sys; sys.__plen = len(sys.path)
> ./setuptools-0.6c8-py2.5.egg
> ./networkx-0.36-py2.5.egg
> ./numpy-1.0.4-py2.5-win32.egg
> ./scipy-0.6.0-py2.5-win32.egg
> ./matplotlib-0.91.2-py2.5-win32.egg
> ./dot2tex-2.7.0-py2.5.egg
> ./pydot-1.0.2-py2.5.egg
> ./pyparsing-1.4.11-py2.5-win32.egg
> import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:];
> p=getattr(sys,
> '__egginsert',0); sys.path[p]=new; sys.__egginsert = p+len(new)
>
> The location where numpy is found:>>> print os.path.abspath(numpy.__file__)
>
> C:\Program Files\Python25\lib\site-packages\numpy-1.0.4-py2.5-win32.egg
> \numpy\__
> init__.pyc
>
> So I believe I need to have the easy-install.pth file executed
> automatically for regular users but I don't know how to do this.
>
> Reg
>
> On Apr 21, 7:29*pm, John Machin <(E-Mail Removed)> wrote:
>
>
>
> > sawillawrote:
> > > On Apr 21, 5:42 pm, John Machin <(E-Mail Removed)> wrote:
> > >> Log on as administrator, start python in command window and do this:

>
> > >> import sys
> > >> sys.path # shows where python is looking for importables
> > >> import numpy
> > >> import os.path
> > >> print os.path.abspath(numpy.__file__) # shows where it found numpy

>
> > >> Log on as ordinary user, start python in command window and do this:

>
> > >> import sys
> > >> sys.path
> > >> # check how this is different from the admin's sys.path

>
> > >> If you can't see what to do after that, come back here with the output
> > >> from those steps.

>
> > >> HTH,
> > >> John

>
> > > That was a great help, thank you. I now see what is causing the
> > > problem but I don't know how to fix it. I used easy_install to install
> > > several packages. When I run Python from an administrator command
> > > window all of the directories in C:\Program Files\Python25\Lib\site-
> > > packages\easy-install.pth are added to the sys.path. When I run it as
> > > a regular user, those directories are not added to the sys.path and so
> > > Python can't find the modules.

>
> > > I know how to manually add those directories to Python's search path
> > > but then I'll need to update the path every time I install something.
> > > How do I get Python to automatically load the easy-install.pth file
> > > for the regular user account?

>
> > > Reg

>
> > """
> > If you can't see what to do after that, come back here with the output
> > from those steps.
> > """
> > in particular what is in sys.path for the non-admin user.
> > Also what are the access rights to the easy-install.pth file?- Hide quoted text -

>
> > - Show quoted text -- Hide quoted text -

>
> - Show quoted text -


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
2473-1 Systems Administrator - IBM RequisitePro Administrator,Chicago,Illinois.- Isaac Java 0 10-20-2010 07:44 PM
WCF service install on 2003 fails using new ADMIN user but works as user ADMINISTRATOR Scott ASP .Net 2 11-13-2008 04:03 PM
need administrator...but no administrator century.dave Windows 64bit 2 12-09-2007 12:47 PM
When I turn on my PC, it works, works, works. Problem! Fogar Computer Information 1 01-17-2006 12:57 AM
After rebooting my PC works, works, works! Antivirus problem? Adriano Computer Information 1 12-15-2003 05:30 AM



Advertisments