因此,我尝试在 Mac OSX El Capitan 版本 10.11.6 上使用 Homebrew 重新安装 python3,但一直出现错误。我用来安装 python3 的命令如下:
$ brew install python3
第一个命令似乎运行良好,没有抛出任何错误。
$ brew linkapps
第二条命令抛出以下错误:
Warning: `brew linkapps` has been deprecated and will eventually be removed!
Unfortunately `brew linkapps` cannot behave nicely with e.g. Spotlight using
either aliases or symlinks and Homebrew formulae do not build "proper" `.app`
bundles that can be relocated. Instead, please consider using `brew cask` and
migrate formulae using `.app`s to casks.
Linking: /usr/local/opt/python/IDLE.app
Linking: /usr/local/opt/python/Python Launcher.app
Linking: /usr/local/opt/python3/IDLE 3.app
Linking: /usr/local/opt/python3/Python Launcher 3.app
Linking: /usr/local/opt/qt5/libexec/Assistant-qt5.app
Linking: /usr/local/opt/qt5/libexec/Designer-qt5.app
Linking: /usr/local/opt/qt5/libexec/Linguist-qt5.app
Linking: /usr/local/opt/qt5/libexec/pixeltool-qt5.app
Linking: /usr/local/opt/qt5/libexec/qdbusviewer-qt5.app
Linking: /usr/local/opt/qt5/libexec/qml-qt5.app
Linked 10 apps to /Applications
当我尝试$ python3
在终端中运行时,出现以下错误:
Failed to import the site module
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/site.py", line 73, in <module>
__boot()
File "/usr/local/lib/python2.7/site-packages/site.py", line 26, in __boot
import imp # Avoid import loop in Python >= 3.3
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/imp.py", line 27, in <module>
import tokenize
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/tokenize.py", line 33, in <module>
import re
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/re.py", line 142, in <module>
class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
希望能得到一些关于如何解决这个问题的建议。我的目标是按照建议安装 python3 和 opencv3本教程然而我被困住了,python3 无法工作。
答案1
我解决了这个问题感谢https://stackoverflow.com/a/42214539/5511915,使用简单的unset PYTHONPATH
(设置为PYTHONPATH=/usr/local/lib/python2.7/site-packages
,与python3冲突)