[英]I tried to remove Python and think I may have broken my whole operating system (Mac)
So over the summer I tried switching to Python3 and wanted to get rid of all previous Python versions on my computer.所以在整个夏天,我尝试切换到 Python3 并希望摆脱我计算机上所有以前的 Python 版本。 I just went through the files on my computer and threw anything that said Python in the trash.我只是浏览了我电脑上的文件,然后把任何说 Python 的东西都扔进了垃圾箱。 I've been having issues running Python scripts on my computer every since and as I've been digging online for help on uninstalling and reinstalling Python, I've seen many people warn not to delete Apple-supplied system Python.从那以后,我一直在我的计算机上运行 Python 脚本时遇到问题,因为我一直在网上寻找卸载和重新安装 Python 的帮助,我看到很多人警告不要删除 Apple 提供的系统 Python。 I'm getting the feeling I may have done this....我感觉我可能已经这样做了......
What can I do if that is the case?如果是这种情况,我该怎么办? Am I completely doomed?我完全注定了吗? Is there a way to check what files should be on my computer and which shouldn't?有没有办法检查哪些文件应该在我的电脑上,哪些不应该?
This has been really inhibiting me from doing work and I would love to get to the root of this issue.这真的阻碍了我的工作,我很想找到这个问题的根源。 I have run commands in the terminal to install Python3 and force link it but my issues persist and I can't run Python scripts that work perfectly well on my coworkers computers.我已经在终端中运行命令来安装 Python3 并强制链接它,但我的问题仍然存在,我无法运行在我同事的计算机上运行良好的 Python 脚本。
I'm currently using Visual Studio Code and when I run my script I get an error that says我目前正在使用 Visual Studio Code,当我运行我的脚本时,我收到一个错误消息
/bin/sh: python: command not found
or when I run my script using the terminal或者当我使用终端运行我的脚本时
python3 Desktop/folder/file.py
it'll say:它会说:
[Errno 2] No such file or directory
I've been struggling with this for months, I believe there's something going on with my operating system.我已经为此苦苦挣扎了几个月,我相信我的操作系统出了点问题。 Any help is appreciated!任何帮助表示赞赏!
Backup and then re-install the OS.备份然后重新安装操作系统。
That's all pretty easy to do with a mac.用 mac 做这一切都很容易。 But if you've removed things out of the OS folders and you're not sure what, the only real way to get back to normal is to reinstall但是,如果您已经从操作系统文件夹中删除了一些东西并且您不确定是什么,那么恢复正常的唯一真正方法就是重新安装
This is not a complete answer, I can update as more information comes in. I noticed a couple of issues, so wanted to point them out.这不是一个完整的答案,我可以随着更多信息的出现而更新。我注意到几个问题,所以想指出它们。 First:第一的:
/bin/sh: python: command not found
Depending on the environment, you might not have a python
even if everything is correct.根据环境的不同,即使一切正常,您也可能没有python
。 You might only have a python3
.您可能只有一个python3
。 To test, try:要测试,请尝试:
python3 -V
so if need be, you could edit files to call the correct executable, or perhaps make a symlink, like one of these:因此,如果需要,您可以编辑文件以调用正确的可执行文件,或者创建一个符号链接,例如以下之一:
ln -s /bin/python3 /bin/python
ln -s /usr/bin/python3 /usr/bin/python
Then this:然后这个:
python3 Desktop/folder/file.py
[Errno 2] No such file or directory
You probably should be calling /Desktop
instead of Desktop
, depending on the current directory.您可能应该调用/Desktop
而不是Desktop
,具体取决于当前目录。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.