安装iPython时遇到问题

2024-05-26 20:47:14 发布

您现在位置:Python中文网/ 问答频道 /正文

嗯,我的Python工作得很好。突然之间,它给了我这样一个信息:

-bash: ipython: command not found

我确实玩过一些bash配置文件,但我是一个初学者,所以我真的不知道我做了什么。我真的需要帮助。你知道吗

不管怎样,现在我试着这样做,得到了这个:

Eddy-Lopez-Torres-Computer:~ eddylopez-torres$ pip install ipython
-bash: pip: command not found
Eddy-Lopez-Torres-Computer:~ eddylopez-torres$ sudo python setup.py install
python: can't open file 'setup.py': [Errno 2] No such file or directory
Eddy-Lopez-Torres-Computer:~ eddylopez-torres$ sudo python setup.py install
python: can't open file 'setup.py': [Errno 2] No such file or directory
Eddy-Lopez-Torres-Computer:~ eddylopez-torres$ cd Downloads/
Eddy-Lopez-Torres-Computer:Downloads eddylopez-torres$ cd LabTools-0.2.2
Eddy-Lopez-Torres-Computer:LabTools-0.2.2 eddylopez-torres$ python setup.py install
running install
Checking .pth file support in /Library/Python/2.7/site-packages/
/usr/bin/python -E -c pass
TEST PASSED: /Library/Python/2.7/site-packages/ appears to support .pth files
running bdist_egg
running egg_info
writing LabTools.egg-info/PKG-INFO
writing top-level names to LabTools.egg-info/top_level.txt
writing dependency_links to LabTools.egg-info/dependency_links.txt
reading manifest file 'LabTools.egg-info/SOURCES.txt'
writing manifest file 'LabTools.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.10-intel/egg
running install_lib
running build_py
creating build/bdist.macosx-10.10-intel/egg
error: could not create 'build/bdist.macosx-10.10-intel/egg': Permission denied

我试着跟帖:

Chances are that at one point you tried running python setup.py under sudo and now have a dist directory belonging to root. Clear out the existing dist subdirectory in your build directory and rerun:

sudo rm -rf ./dist
ARCHFLAGS='-arch x86_64' python setup.py install

If you then get permission errors in the final install step, you may need to run the install step under sudo:

sudo bash
export ARCHFLAGS='-arch x86_64'
/path/to/same/python2.7 setup.py install
exit

but it's probably better to not do that if you don't have to.

但正如你所见…事情并没有按计划进行:

Eddy-Lopez-Torres-Computer:LabTools-0.2.2 eddylopez-torres$ sudo rm -rf ./dist ARCHFLAGS='arch x86_64' python setup.py install
Eddy-Lopez-Torres-Computer:LabTools-0.2.2 eddylopez-torres$ ipython
-bash: ipython: command not found
Eddy-Lopez-Torres-Computer:LabTools-0.2.2 eddylopez-torres$ sudo rm -rf ./dist
Eddy-Lopez-Torres-Computer:LabTools-0.2.2 eddylopez-torres$ ARCHFLAGS='-arch x86_64' python setup.py install
python: can't open file 'setup.py': [Errno 2] No such file or directory
Eddy-Lopez-Torres-Computer:LabTools-0.2.2 eddylopez-torres$ sudo bash
root@Eddy-Lopez-Torres-Computer:~/Downloads/LabTools-0.2.2# export ARCHFLAGS=' arch x86_64'root@Eddy-Lopez-Torres-Computer:~/Downloads/LabTools-0.2.2# /path/to/same/python2.7 setup.py install
bash: /path/to/same/python2.7: No such file or directory
root@Eddy-Lopez-Torres-Computer:~/Downloads/LabTools-0.2.2# exit

任何帮助都将不胜感激。非常感谢!你知道吗


Tags: installtopybasheggsetupsudocomputer
1条回答
网友
1楼 · 发布于 2024-05-26 20:47:14

上次引用的终端会话中的错误是由以下命令引起的:

sudo rm -rf ./dist ARCHFLAGS='arch x86_64' python setup.py install

-r选项告诉rm递归删除所有列出的文件。-f选项告诉它强制删除它们。以sudo的形式运行命令意味着rm有删除任何内容的权限。所以你可以看到,使用sudo rm -rf应该非常小心。你知道吗

您的命令删除了以下内容:

  • ./dist-您可能要删除的文件夹
  • ARCHFLAGS='arch x86_64'-命令行中的下一项。这可能不是一个文件,但是-f关闭了rm关于不存在的文件的警告。你知道吗
  • python-谢天谢地,真正的Python程序并没有存储在您正在工作的目录中。如果是的话,它早就被删除了!你知道吗
  • setup.py-已删除(您不打算这样做)
  • install-可能也不是此目录中的文件。你知道吗

由于setup.py被删除,当您尝试运行ARCHFLAGS='-arch x86_64' python setup.py install时,第一个no such file or directory失败。你知道吗

然后,复制并粘贴命令/path/to/same/python2.7 setup.py install。但是,该命令并不意味着复制和粘贴路径/path/to/same/python2.7意味着替换为您的Python安装的路径(可能是/usr/bin/python2.7,但是您可以使用命令which python2which python)。你知道吗

由于删除了setup.py文件,您的安装将无法继续工作。你得从你拿到第一本的地方拿一本新的。一旦你这么做了,也许会奏效。你知道吗

哦,顺便说一句,你真的应该永远不要在不知道命令具体是什么的情况下复制和粘贴命令(尤其是如果它们包含sudo)。当你这么做的时候,你把你的电脑完全交给了一个你没有理由信任的人。如果你不懂这个命令,开始谷歌搜索。大多数命令都可以通过一点研究来理解。你知道吗

相关问题 更多 >

    热门问题