Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
801 views
in Technique[技术] by (71.8m points)

python - ImportError: no module named py2exe

I get this error when I try to use one of the py2exe samples with py2exe.

File "setup.py", line 22, in ?
   import py2exe
ImportError: no module named py2exe

I've installed py2exe with the installer, and I use python 2.6. I have downloaded the correct installer from the site (The python 2.6 one.)

My path is set to C:Python26 and I can run normal python scripts from within the command prompt.

Any idea what to do?

Thanks.

Edit: I had python 3.1 installed first but removed it afterwards. Could that be the problem?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Sounds like something has installed Python 2.4.3 behind your back, and set that to be the default.

Short term, try running your script explicitly with Python 2.6 like this:

c:Python26python.exe setup.py ...

Long term, you need to check your system PATH (which it sounds like you've already done) and your file associations, like this:

C:Users
jh>assoc .py
.py=Python.File

C:Users
jh>ftype Python.File
Python.File="C:Python26python.exe" "%1" %*

Simply removing Python 2.4.3 might be a mistake, as presumably something on your system is relying on it. Changing the PATH and file associations to point to Python 2.6 probably won't break whatever thing that is, but I couldn't guarantee it.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...