How to fix ‘ImportError: No module named X’ in Python
The problem is your python path, or rather the lack of one. You need to set environment variable PYTHONPATH to the absolute path of the missing module. One way of doing it is to append the path with in python.
The problem is your python path, or rather the lack of one. You need to set environment variable PYTHONPATH to the absolute path of the missing module. One way of doing it is to append the path with in python.
import sys
sys.path.append('/path/to/module')
Here is example from the real world. When I tried to compress the Netflixprize dataset using the pythonscript pyflix it returned this error.
Traceback (most recent call last): File "pyflix/setup.py", line 13, infrom pyflix import timeCall ImportError: No module named pyflix
My solution to the problem was to add two lines of code in the beginning of setup.py. Notice the import on line seven and the appending of a path on line eight.
#!/usr/bin/env python
'''Script for generating the indexed binary datasets.'''
#==== imports ==================================================================
import sys
sys.path.append('/users/janjarfalk/projects/netflixprize/pyflix-0.1')
import cPickle
from operator import itemgetter
from optparse import OptionParser, make_option
import numpy as N
from pyflix import timeCall
Comments
Make a comment
Projects
- Accordion (jQuery)
- Airport (jQuery)
- Defaultvalue (jQuery)
- Elastic (jQuery)
- Highlight (jQuery)
- Keycan
- Lazy (jQuery)
- Limit (jQuery)
- Password Strength (jQuery)
- Show Password (jQuery)
- Tabify (jQuery)
- Valid8 (jQuery)
Latest posts
- July 8th, 2009 Why are we typing passwords twice?
- July 5th, 2009 Don’t stop password masking; let the user decide
- June 1st, 2009 You can’t validate email addresses with regular expressions
- May 20th, 2009 Konami Code: Why so verbose, when you can make it in 140 characters?
- May 18th, 2009 Let your users know if Firebug slows down your web page.
according it, i still setup under Windows