Python “无法访问 setup.py:没有这样的文件或目录” - 无法运行任何 .py 文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25036688/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"Cannot access setup.py: No such file or directory" - can't run any .py files?
提问by acaciarose
This problem started while I was installing pyswip and needed to run a setup.py file. Using the command "python setup.py", I'm greeted with the following message: "python: can't open file 'setup.py': [Errno 2] No such file or directory."
这个问题是在我安装 pyswip 并且需要运行 setup.py 文件时开始的。使用命令“python setup.py”,我收到以下消息:"python: can't open file 'setup.py': [Errno 2] No such file or directory."
I know this question's been asked a lot before, so I've tried everything in previous answers. Including #!/usr/bin/env pythonor #!/usr/bin/env python-3.3.0at the very top of the script and then trying "chmod +x setup.py"
gives the following: "chmod: cannot accesssetup.py': No such file or directory".
我知道这个问题以前被问过很多次,所以我已经尝试了以前的答案中的所有内容。包括#!/usr/bin/env python或#!/usr/bin/env python-3.3.0在脚本的最顶端,然后试图“ chmod +x setup.py”给出了以下情况:"chmod: cannot accesssetup.py': No such file or directory"。
Trying to run other .py files from the terminal gives the same result.
尝试从终端运行其他 .py 文件给出了相同的结果。
Running the file in the Python Shell from IDLE doesn't do anything.
从 IDLE 在 Python Shell 中运行该文件不会执行任何操作。
Running the "ls -d */" command shows that the Python-3.3.0/ directory, where the .py files in question are, is definitely there.
运行 "ls -d */" 命令显示 Python-3.3.0/ 目录,其中有问题的 .py 文件,肯定存在。
Am I missing something really obvious? (If it helps, I have Elementary OS 0.2.)
我错过了一些非常明显的东西吗?(如果有帮助,我有 Elementary OS 0.2。)
回答by Kuishi
I have no knowledge about Elementary OS but you could try to use the full path of the setup.py.
我对 Elementary OS 一无所知,但您可以尝试使用 setup.py 的完整路径。
python /home/acacia/Python-3.3.0/PySwip/pyswip-0.2.3/setup.py install
[EDIT] Can't answer comments, so I just added the install parameter in my answer
[编辑] 无法回答评论,所以我只是在我的回答中添加了安装参数
回答by Charles Duffy
When you run python setup.pythat requires the setup.pyfile to be in the current directory.
当您运行时python setup.py,要求setup.py文件位于当前目录中。
You can control the current directory with the cdcommand.
您可以使用该cd命令控制当前目录。
So:
所以:
cd /home/acacia/Python-3.3.0/PySwip/pyswip-0.2.3
python setup.py install
回答by Yu-Hsiang Lin
You need to go into the directory that you are going to "setup". For example, if you are installing numpy, and you have git-cloned it, then it probably is located at ~/numpy. So first cd into ~/numpy, and the type the commend like "python setup.py build" there.
您需要进入要“设置”的目录。例如,如果您正在安装 numpy,并且您已经 git 克隆了它,那么它可能位于 ~/numpy。所以首先cd到~/numpy,然后在那里输入像“python setup.py build”这样的推荐。

