由于某些错误 homebrew.pth,无法使用 Python
Can't use Python because of some error homebrew.pth
每当我尝试 运行 python 时,我都会收到与我的路径相关的错误。
FrankieMacBook-Pro-2~$ python
Error processing line 2 of /Users/Frankie/Library/Python/2.7/lib/python/site-packages/homebrew.pth:
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 152, in addpackage
exec line
File "<string>", line 1
import site; site.addsitedir("/usr/local/lib/python2.7/site-packages") mkdir -p /Users/Frankie/Library/Python/2.7/lib/python/site-packages
^
SyntaxError: invalid syntax
Remainder of file ignored
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
我一直在使用 Python3,对我来说没有这个问题,但现在我有一个任务需要使用 Python2,所以需要面对这个问题。
知道我的问题是什么吗?
我是否以某种方式用自制软件搞砸了我的道路?
您的问题是 Python 解释器在启动时运行 site.py
。它正在导入 homebrew.pth
并且此文件在您的 2.7 安装中的副本已损坏。
找到此文件并删除它或使用文本编辑器获取此代码
mkdir -p /Users/Frankie/Library/Python/2.7/lib/python/site-packages
超出开头的行
import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")
如果执行此操作后出现更多语法错误,请查看语法错误消息中的 ^
。它将指向解释器不喜欢的任何其他内容。
每当我尝试 运行 python 时,我都会收到与我的路径相关的错误。
FrankieMacBook-Pro-2~$ python
Error processing line 2 of /Users/Frankie/Library/Python/2.7/lib/python/site-packages/homebrew.pth:
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 152, in addpackage
exec line
File "<string>", line 1
import site; site.addsitedir("/usr/local/lib/python2.7/site-packages") mkdir -p /Users/Frankie/Library/Python/2.7/lib/python/site-packages
^
SyntaxError: invalid syntax
Remainder of file ignored
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
我一直在使用 Python3,对我来说没有这个问题,但现在我有一个任务需要使用 Python2,所以需要面对这个问题。
知道我的问题是什么吗? 我是否以某种方式用自制软件搞砸了我的道路?
您的问题是 Python 解释器在启动时运行 site.py
。它正在导入 homebrew.pth
并且此文件在您的 2.7 安装中的副本已损坏。
找到此文件并删除它或使用文本编辑器获取此代码
mkdir -p /Users/Frankie/Library/Python/2.7/lib/python/site-packages
超出开头的行
import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")
如果执行此操作后出现更多语法错误,请查看语法错误消息中的 ^
。它将指向解释器不喜欢的任何其他内容。