the problem of import module

F

fts2012

follow the dive into python
----------------------------------------------------------------------------------------------------------------------------------
I append the filepath of <<dive into python>>'s examples into
sys.path,but
-----------------------------------------------------------------['C:\\Python25\\Lib\\idlelib', 'C:\\WINDOWS\\system32\\python25.zip',
'C:\\Python25\\DLLs', 'C:\\Python25\\lib', 'C:\\Python25\\lib\\plat-
win', 'C:\\Python25\\lib\\lib-tk', 'C:\\Python25', 'C:\\Python25\\lib\
\site-packages', 'E:\x07chieve\x08ook\\diveintopython-pdfzh-cn-5.4b\
\diveintopythonzh-cn-5.4b\\py']
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
import fileinfo
ImportError: No module named fileinfo
 
P

Peter Otten

follow the dive into python
----------------------------------------------------------------- \achieve\book\diveintopython-pdfzh-cn-5.4b\diveintopythonzh-cn-5.4b\py')
-----------------------------------------------------------------
I append the filepath of <<dive into python>>'s examples into
sys.path,but
-----------------------------------------------------------------['C:\\Python25\\Lib\\idlelib', 'C:\\WINDOWS\\system32\\python25.zip',
'C:\\Python25\\DLLs', 'C:\\Python25\\lib', 'C:\\Python25\\lib\\plat-
win', 'C:\\Python25\\lib\\lib-tk', 'C:\\Python25', 'C:\\Python25\\lib\
\site-packages', 'E:\x07chieve\x08ook\\diveintopython-pdfzh-cn-5.4b\
\diveintopythonzh-cn-5.4b\\py']
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
import fileinfo
ImportError: No module named fileinfo

The path you append to sys.path is not properly escaped:
'E:\x07rchive' # \a has become the single character chr(7)

Use double backslashes or raw strings instead:
'E:\\archive'

When you print it the extra backslash will be gone:
E:\archive

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top