Traceback (most recent call last):
File “start_cli_test.py”, line 2, in
import transformers
ModuleNotFoundError: No module named ‘transformers’
Traceback (most recent call last):
File “/usr/local/python3/lib/python3.8/runpy.py”, line 185, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File “/usr/local/python3/lib/python3.8/runpy.py”, line 111, in _get_module_details
import(pkg_name)
File “/root/meta-llama/llama-2/start_cli_test.py”, line 2, in
import transformers
ModuleNotFoundError: No module named ‘transformers’
一、问题复现:
虽然已经通过pip install transformers安装了transformers,但是仍然报错"ImportError: No module named ‘transformers’"
二、原因分析:
python版本和pip版本不一致
frank@MacBook-Pro ~ % python --version
Python 3.10.10
frank@MacBook-Pro ~ % pip --version
pip 23.0.1 from /Users/zhangsanlisi/Library/Python/3.9/lib/python/site-packages/pip (python 3.9)
三、解决办法:
python -m pip install transformers