我正在尝试在我的Mac上(MacOS 10.14.6 Mojave)编写Python脚本,并遇到安装模块(watchdog)的问题。我有内置的Python 2,也使用Homebrew安装了Python 3。
如果我在终端中输入python
,我会得到:
Python 2.7.16 (default, Oct 16 2019, 00:34:56)
[GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.37.14)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Python 2 使用了正确的 GCC 编译器(由 Apple 提供?我不确定),而不是 Clang。现在,如果我执行 python -m pip install watchdog
命令,它就可以正常工作。但是我想要将该模块安装到 Python 3 上,可是它使用 Clang 而不是 GCC。事实上,如果我键入“python3”,我会得到以下结果:
Python 3.8.0 (v3.8.0:fa919fdf25, Oct 14 2019, 10:23:27)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
我认为,由于Python 3没有使用GCC,因此python3 -m pip install watchdog
会导致编译错误。错误消息非常长,可以在此处找到:https://pastebin.com/DEAKANQ9
在我的$PATH中,/usr/local/bin
(其中安装了gcc
)位于/usr/bin
之前。
echo $PATH
/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin
我认为一切都设置正确了,但显然情况并非如此。我该如何使Python 3使用GCC而不是Clang?