0

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?

3
  • Where is setup.py located? Python is going to look in the directory you invoke it from, not in the directory where it (python.exe) is located. Commented Sep 16, 2010 at 1:18
  • It's in the same directory as python.exe. How do I tell which directory I Invoked it from, or specify where it should look for setup.py? Commented Sep 16, 2010 at 1:32
  • That's what I was guessing. I'll follow up with an answer since it would be a bit much to put here. Commented Sep 16, 2010 at 2:42

2 Answers 2

3

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
Sign up to request clarification or add additional context in comments.

Comments

1

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...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.