I was using Python 2.7 as it was installed on my Mac by default. I tried to update it to python 3.4. In the process I deleted 2.7 via the command line. I installed python 3.4 using an installer but I am still getting following error:
我使用的是Python 2.7,因为它默认安装在我的Mac上。我试图将其更新到python 3.4。在这个过程中,我通过命令行删除了2.7。我使用安装程序安装了python 3.4,但是我仍然得到以下错误:
python: Command not found
没有找到python:命令
I checked and found that this folder does not exist:
我查了一下,发现这个文件夹不存在:
/Library/Frameworks/Python.framework/Versions/3.4
/图书馆/框架/ Python.framework /版本/ 3.4
I followed the instructions on this website to update Python. Everything went well until step 5 but was unsuccessful for step 6 and 7.
我按照这个网站上的说明来更新Python。直到第5步,一切都进行得很顺利,但是第6步和第7步都没有成功。
I am in a complete mess as I have deleted the older version, Python 2.7. How can I fix my Python installation to solve the error and use Python 3.4?
当我删除了旧版本Python 2.7时,我的处境一团糟。如何修复Python安装以解决错误并使用Python 3.4?
1 个解决方案
#1
0
While I agree with the several users who have commented that it's a bad idea to alter or remove the system's Python installation, it looks like the problem here is that you followed the steps given in the linked blog post to upgrade from version 2.x to a more recent version 2.x. Note where it says (emphasis mine):
虽然我同意一些用户的看法,他们认为修改或删除系统的Python安装不是一个好主意,但是这里的问题似乎是您遵循了链接博客文章中给出的从版本2升级的步骤。x的最新版本2。x。注意它说的地方(重点是我的):
To read about how to upgrade to Python 3.3, jump to the very bottom of this post.
要了解如何升级到Python 3.3,请跳到本文的最下面。
Steps 1 through 7 in the blog post show how to upgrade the system Python from 2.7.1 to 2.7.3. While it would be fine to install them side-by-side instead—leaving you free to alter or delete your version without breaking the system version—you probably wouldn't run into trouble upgrading the system version from patch 1 to patch 3 of the same minor release.
博客文章中的步骤1到7展示了如何将系统Python从2.7.1升级到2.7.3。相反,并排安装它们是可以的——您可以在不破坏系统版本的情况下*地修改或删除您的版本——您可能不会遇到将系统版本从补丁1升级到补丁3的麻烦。
However, Python 3 is not backwards-compatible with Python 2. If your system version of Python is 2.x, replacing it with version 3.x just won't work; the system depends on having 2.x available. Note that the section at the bottom of the blog post titled "Updating to Python 3.3" does not remove Python 2.7:
然而,Python 3并不与Python 2向后兼容。如果您的系统版本的Python是2。x,替换为版本3。x是行不通的;系统依赖于2。x。注意,博客文章末尾的“更新到Python 3.3”部分并没有删除Python 2.7:
rm -R /System/Library/Frameworks/Python.framework/Versions/3.3
mv /Library/Frameworks/Python.framework/Versions/3.3 /System/Library/Frameworks/Python.framework/Versions
What it does instead is remove any existing installation of the version to be upgraded, in this case Python 3.3, to avoid a Directory not empty
error when trying to move the upgraded version into the system folder.
相反,它所做的是删除要升级版本的任何现有安装(在本例中为Python 3.3),以避免在尝试将升级版本移动到系统文件夹时出现目录不是空的错误。
You need a working version of Python 2 in your system folder. If you want to use Python 3, you need a separate installation entirely. Rather than backtracking the steps of the guide in reverse order, you may be able to simply start again at step 1, but this time download and install Python 2 instead of Python 3, but you will need to make sure you understand what each step does, looking up shell commands if necessary, because it sounds like you've already made some modifications you don't understand in trying to adapt the wrong section to apply to Python 3.
在您的系统文件夹中需要一个Python 2的工作版本。如果希望使用Python 3,则需要完全独立的安装。而不是回溯倒序的指导的步骤,您可以简单地重新开始第一步,但这一次下载并安装Python 2而不是Python 3,但你需要确保你明白每一步,抬头shell命令如有必要,因为它听起来就像你已经做了一些修改你不明白为了适应错误的部分,适用于Python 3。
For example, you might have changed the second command from step 2 from
例如,您可能已经将第二个命令从第2步更改为第2步
sudo mv /Library/Frameworks/Python.framework/Versions/2.7 /System/Library/Frameworks/Python.framework/Versions
to
来
sudo mv /Library/Frameworks/Python.framework/Versions/3.4 /System/Library/Frameworks/Python.framework/Versions
when you were trying to use this step to "upgrade" from 2 to 3; otherwise, you would have gotten a No such file or directory
error. If this is the case, you won't have a 2.7
folder to remove in the very first step because you already removed it the first time around and didn't replace it.
当您试图使用此步骤从2升级到3时;否则,您将得到一个No文件或目录错误。如果是这样,那么第一步就不会有一个2.7文件夹删除了,因为你已经第一次删除了它,并且没有替换它。
#1
0
While I agree with the several users who have commented that it's a bad idea to alter or remove the system's Python installation, it looks like the problem here is that you followed the steps given in the linked blog post to upgrade from version 2.x to a more recent version 2.x. Note where it says (emphasis mine):
虽然我同意一些用户的看法,他们认为修改或删除系统的Python安装不是一个好主意,但是这里的问题似乎是您遵循了链接博客文章中给出的从版本2升级的步骤。x的最新版本2。x。注意它说的地方(重点是我的):
To read about how to upgrade to Python 3.3, jump to the very bottom of this post.
要了解如何升级到Python 3.3,请跳到本文的最下面。
Steps 1 through 7 in the blog post show how to upgrade the system Python from 2.7.1 to 2.7.3. While it would be fine to install them side-by-side instead—leaving you free to alter or delete your version without breaking the system version—you probably wouldn't run into trouble upgrading the system version from patch 1 to patch 3 of the same minor release.
博客文章中的步骤1到7展示了如何将系统Python从2.7.1升级到2.7.3。相反,并排安装它们是可以的——您可以在不破坏系统版本的情况下*地修改或删除您的版本——您可能不会遇到将系统版本从补丁1升级到补丁3的麻烦。
However, Python 3 is not backwards-compatible with Python 2. If your system version of Python is 2.x, replacing it with version 3.x just won't work; the system depends on having 2.x available. Note that the section at the bottom of the blog post titled "Updating to Python 3.3" does not remove Python 2.7:
然而,Python 3并不与Python 2向后兼容。如果您的系统版本的Python是2。x,替换为版本3。x是行不通的;系统依赖于2。x。注意,博客文章末尾的“更新到Python 3.3”部分并没有删除Python 2.7:
rm -R /System/Library/Frameworks/Python.framework/Versions/3.3
mv /Library/Frameworks/Python.framework/Versions/3.3 /System/Library/Frameworks/Python.framework/Versions
What it does instead is remove any existing installation of the version to be upgraded, in this case Python 3.3, to avoid a Directory not empty
error when trying to move the upgraded version into the system folder.
相反,它所做的是删除要升级版本的任何现有安装(在本例中为Python 3.3),以避免在尝试将升级版本移动到系统文件夹时出现目录不是空的错误。
You need a working version of Python 2 in your system folder. If you want to use Python 3, you need a separate installation entirely. Rather than backtracking the steps of the guide in reverse order, you may be able to simply start again at step 1, but this time download and install Python 2 instead of Python 3, but you will need to make sure you understand what each step does, looking up shell commands if necessary, because it sounds like you've already made some modifications you don't understand in trying to adapt the wrong section to apply to Python 3.
在您的系统文件夹中需要一个Python 2的工作版本。如果希望使用Python 3,则需要完全独立的安装。而不是回溯倒序的指导的步骤,您可以简单地重新开始第一步,但这一次下载并安装Python 2而不是Python 3,但你需要确保你明白每一步,抬头shell命令如有必要,因为它听起来就像你已经做了一些修改你不明白为了适应错误的部分,适用于Python 3。
For example, you might have changed the second command from step 2 from
例如,您可能已经将第二个命令从第2步更改为第2步
sudo mv /Library/Frameworks/Python.framework/Versions/2.7 /System/Library/Frameworks/Python.framework/Versions
to
来
sudo mv /Library/Frameworks/Python.framework/Versions/3.4 /System/Library/Frameworks/Python.framework/Versions
when you were trying to use this step to "upgrade" from 2 to 3; otherwise, you would have gotten a No such file or directory
error. If this is the case, you won't have a 2.7
folder to remove in the very first step because you already removed it the first time around and didn't replace it.
当您试图使用此步骤从2升级到3时;否则,您将得到一个No文件或目录错误。如果是这样,那么第一步就不会有一个2.7文件夹删除了,因为你已经第一次删除了它,并且没有替换它。