Bizarre python ImportError
Here's my setup: a Mac, running OS X Tiger. Windows XP running in a virtual machine (Parallels). Windows XP has my Mac home directory mapped as a network drive.
I have two files in a directory of my Mac home directory:
If I run test.py from within my virtual machine by typing 'python test.py', I get this:
Traceback (most recent call last): File "test.py", line 1, in <module> import foo ImportError: No module named foo
If I try to import foo from the console (running python under Windows from the same directory), all is well:
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import foo >>>
If I run test.py with Mac python, all is well.
If I copy test.py and foo.py to a different directory, I can run test.py under Windows without problems.
There is an init.py in the original directory, but it is empty. Furthermore, copying it with the other files doesn't break anything in the previous paragraph.
There are no python-related environment variables set.
Asked by: Chloe758 | Posted: 28-01-2022
Add import sys; print sys.path to the start of test.py. See what it prints out in the failing case. If "." isn't on the list, that may be your problem.Answered by: Roland556 | Posted: 01-03-2022
As a random guess: are the permissions on foo.py accessable from the windows client? (eg try opening with notepad from the virtual machine).
If that's OK, try running:
python -v -v test.py
and looking at the output (alternatively, set PYTHONVERBOSE=2). This should list all the places it tries to import foo from. Comparing it with a similar trace on the working machine may give some further clues.Answered by: Joyce582 | Posted: 01-03-2022
python - Why do I receive an ImportError when running one of the CherryPy tutorials
I have installed CherryPy 3.1.0,. Here is what happens when I try to run tutorial 9: $ cd /Library/Python/2.5/site-packages/cherrypy/tutorial/ $ python tut09_files.py Traceback (most recent call last): File "tut09_files.py", line 48, in <module> from cherrypy.lib import static ImportError: cannot import name static The previous line in the file: import cherrypy ...
python - Django ImportError at / no matter what I do
So I've just started playing around with Django and I decided to give it a try on my server. So I installed Django and created a new project, following the basics outlined in the tutorial on Djangoproject.com Unfortunatly, no matter what I do, I can't get views to work: I constantly get ImportError at / No module named index
importerror - unable to import libxml2mod from the python script
File "/usr/local/lib/python2.5/site-packages/libxml2.py", line 1, in <module> import libxml2mod ImportError: /usr/local/lib/python2.5/site-packages/libxml2mod.so: undefined symbol:xmlTextReaderSetup >>> import libxml2mod >>> import libxml2 >>> on Python Prompt it works fine !! can anyone has idea why my program is not working from .py file as i...
python - PyQt 4.7 - ImportError after installing on Windows
I've been trying to install PyQt 4.7 on Vista, but I am getting an ImportError when I try to do: from PyQt4 import QtCore, QtGui. ImportError: DLL load failed: The specified module could not be found. I've checked my System Path, and C:\Python31\Lib\site-packages\PyQt4\bin is on there. I can't run any of the examples, but t...
Python: ImportError no module named urllib
I just rented a VPS from Linode which has python2.5 and ubuntu 8.04. When I run this command from python shell: import urllib I get: ImportError: No module named urllib What can be the reason? How can I add this module to python? Isn't it prepackaged with the basic version? Can it be PYTHONPATH problem?
python - ImportError and Django driving me crazy
OK, I have the following directory structure (it's a django project): -> project --> app and within the app folder, there is a scraper.py file which needs to reference a class defined within models.py I'm trying to do the following: import urllib2 import os import sys import time import datetime import re import BeautifulSoup sys.path.append('/home/userspace/Development/') os...
unix - New at Python: GLPK not building properly / Python ImportError
This is a beginner question, and a follow-up to this one, where I was pointed to GLPK. I'm trying to get PyGLPK, a Python binding for the
python - ImportError using nose, no ImportError using raw unittest?
I get an ImportError when running my unittests using Nose and I don't when I just run it standalone. All files referred to here may be seen at http://gist.github.com/395541# . If I run the test script, importTest-Test.py, directly I get this output: C:\usr\x\data\src\Python\mmm>python importTest-Test....
python - manage.py runserver throws an ImportError with my appname, MacPorts issue on OSX?
I've been developing a Django app for weeks locally on OSX 10.6.3. Recently, I rebooted my machine and went to start my development environment up. Here's the error: cm:myApp cm$ python manage.py runserver Traceback (most recent call last): File "manage.py", line 11, in execute_manager(settings) File "/Library/Python/2.6/site-packages/django/core/management/init...
python - How to fix ImportError in matplotlib
I compiled matplotlib on a mac running snow leopard only to find that when I import matplotlib.pyplot I get the following error: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/pyplot.py", line 6, in <module> from matplotlib.figure import Figure, figaspect File "/...
Still can't find your answer? Check out these communities...
PySlackers | Full Stack Python | NHS Python | Pythonist Cafe | Hacker Earth | Discord Python