tags:

views:

34

answers:

2

I'm using py2exe and I get the following errors in command prompt.

   C:\Users\Me>C:\Python26\My_scripts\python.exe setup.py py2exe
   C:\Python26\My_scripts\python.exe: can't open file 'setup.py': [Errno 2] No such
   file or directory

What am I doing wrong?

+1  A: 

You have no file called setup.py in the C:\Users\Me directory. Various possible mistakes you could be making, of which the two likeliest ones:

  1. the file might be in the directory in question but with a wrong name (say settup.py, oops, two Ts where one was needed) -- then, rename the file!
  2. the file might be in another directory -- then, cd to that directory and try again!

Of course, both errors might be happening at the same time (in which case you need to fix both).

If you think you made neither mistake show us a dir *.py (from the Me) directory...

Alex Martelli
+2  A: 

Since your comment confirmed what I expected, I'll follow up with an answer post.

You invoked python from the directory you were in when you called the executable. In this case, according to your prompt, you invoked it from C:\Users\Me. Therefore, python is trying to find setup.py under this directory (which doesn't exist). You can either:

1) Change directories to the location of the setup.py file, then invoke python. The full path to the python executable will be necessary if it's not in your PATH or if it's in a different directory, otherwise it is not:

C:\Users\Me> cd C:\Python26\My_Scripts
C:\Python26\My_Scripts> C:\Python26\My_Scripts\python.exe  setup.py py2exe

2) Point python to the absolute path of setup.py:

C:\Users\Me> C:\Python26\My_Scripts\python.exe "C:\Python26\My_Scripts\setup.py" py2exe
eldarerathis