tags:

views:

768

answers:

3

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?

+1  A: 

If you have any other versions of Python installed, it may be that another Python version is the default Python. Could this be the case? I believe the default Python installation is determined from a registry setting.

Vinay Sajip
Python 2.4.3 is the default. Is there any way to change it to 2.6.2?
Reshure
+2  A: 

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:\Python26\python.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\rjh>assoc .py
.py=Python.File

C:\Users\rjh>ftype Python.File
Python.File="C:\Python26\python.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.

RichieHindle
The short time solution worked but it couldn't find msvcp90dll when it tried to search for dlls. I downloaded a copy from the internet and placed it in the C:\Python26/DLLs directory and it worked. Thanks!
Reshure
A: 

Seems like you need to download proper py2exe distribution.

Check out if your c:\Python26\Lib\site-packages\ contains py2exe folder.

modosansreves