我在树莓派上使用opencv时需要导入numpy,在安装numpy时使用了以下命令:
pip3 install -U numpy -i https://pypi.tuna.tsinghua.edu.cn/simple/
但当我安装成功后常识运行
import numpy
或
import cv2
我遇到了以下问题
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/pi/.local/lib/python3.9/site-packages/numpy/__init__.py", line 135, in <module>
raise ImportError(msg) from e
ImportError: Error importing numpy: you should not try to import numpy from
its source directory; please exit the numpy source tree, and relaunch
your python interpreter from there
其中 numpy安装到了
/home/pi/.local/lib/python3.9/site-packages/numpy-1.26.4.dist-info/
这是默认安装的路径,我并没有更改,但是我查到的答案告诉我也许是路径出了问题,我需要将该目录删除并重新安装,我这样试过并没有用,numpy仍安装到了原来的地方,而且当我进入python导入numpy时仍然会报错,这应该怎么解决
相似问题