执行 py2exe 失败,并显示无法打开文件“setup.py”;

发布于 2024-09-19 12:25:32 字数 250 浏览 5 评论 0原文

我正在使用 py2exe,但在命令提示符中出现以下错误。

   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

我做错了什么?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

⒈起吃苦の倖褔 2024-09-26 12:25:32

由于您的评论证实了我的预期,我将跟进回复帖子。

您从调用可执行文件时所在的目录调用了 python。在这种情况下,根据您的提示,您从 C:\Users\Me 调用它。因此,python 尝试在此目录下查找 setup.py(该目录不存在)。您可以:

1) 将目录更改为 setup.py 文件的位置,然后调用 python。如果 python 可执行文件不在您的 PATH 中或位于不同的目录中,则需要它的完整路径,否则就不是:

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

2) 将 python 指向 setup.py 的绝对路径:

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

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
乱了心跳 2024-09-26 12:25:32

C:\Users\Me 目录中没有名为 setup.py 的文件。您可能会犯各种可能的错误,其中最有可能的是两个:

  1. 该文件可能位于有问题的目录中,但名称错误(例如 settup.py,哎呀,需要一个的地方有两个 T ) -- 然后,重命名该文件!
  2. 该文件可能位于另一个目录中 - 然后,cd 到该目录并重试!

当然,两个错误可能同时发生(在这种情况下,您需要修复这两个错误)。

如果您认为您没有犯任何错误,请向我们展示 dir *.py (来自 Me)目录...

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文