我知道之前已经有人问过这个问题,但是我发现的解决方案都没有解决我的问题,我很沮丧。
重新安装了Python:
sudo brew reinstall python3
查找Python 3在哪里寻找模块:
import sys
type(sys.path)
for path in sys.path:
print(path)
返回:
/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python37.zip
/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7
/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload
/usr/local/lib/python3.7/site-packages
所以我将Cython安装在/usr/local/lib/python3.7/site-packages中:
sudo pip3 install --install-option="--prefix=$PREFIX_PATH/lib/python3.7/site-packages" Cython
运行我的程序: python3.7 setup.py
Traceback (most recent call last):
File "setup.py", line 2, in <module>
from Cython.Build import cythonize
ModuleNotFoundError: No module named 'Cython'
答案 0 :(得分:0)
我在MAC方面经验不足,但是您是否尝试过在virtualenv中安装Cython并在其中运行.py?您是否仅安装了一个版本的Python?