mac下python环境问题

pretty@goodapp:~/codelearning% pip3 install pangu
Requirement already satisfied: pangu in /usr/local/lib/python3.6/site-packages
pretty@goodapp:~/codelearning% python3 /usr/local/bin/custom_ocr.py
Traceback (most recent call last):
  File "/usr/local/bin/custom_ocr.py", line 8, in <module>
    import pangu
ImportError: No module named 'pangu'
pretty@goodapp:~/codelearning% which python3
/usr/local/bin/python3

到底问题出在哪?mac 下的 python 环境实在太复杂了

阅读 2.6k
3 个回答

macos 内置的是python2 你使用pip3会将pangu装到python3去,因为你没有设置默认使用的是系统的python2运行py文件,所以pangu不存在

查看两个python的环境变量的优先级,把python3的优先级设置高于python2

python3 /usr/local/bin/custom_ocr.py
换成
python3.6 /usr/local/bin/custom_ocr.py

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题