英文:
Python ModuleNotFoundError: No module named 'numpy.random._pcg64'
问题
ModuleNotFoundError: 找不到模块'numpy.random._pcg64'
当我在pycharm和vscode两者中使用时,在运行任何导入numpy的脚本时都会出现此错误。Numpy已更新到最新版本。
我在pycharm和vscode上都尝试过。我运行了多个带有numpy导入的脚本,它们都引发了这个错误。我在网上没有找到任何相关信息。这里可能的问题是什么,我该如何修复它?
来自pycharm的完整错误代码如下:
Traceback (most recent call last):
File "C:\Users\myname\OneDrive\Documents\Python Scripts\Physics Project\working3d.py", line 1, in <module>
import numpy as np
File "C:\Users\myname\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\numpy\__init__.py", line 152, in <module>
from . import random
File "C:\Users\myname\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\numpy\random\__init__.py", line 180, in <module>
from . import _pickle
File "C:\Users\myname\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\numpy\random\_pickle.py", line 3, in <module>
from ._pcg64 import PCG64, PCG64DXSM
ModuleNotFoundError: 找不到模块'numpy.random._pcg64'
英文:
ModuleNotFoundError: No module named 'numpy.random._pcg64'
When using both pycharm and vscode, I get this error when starting to run any script with a numpy import. Numpy is updated to the most recent version.
I've tried on both pycharm and vscode. I've run multiple scripts all with the numpy import and they all raise this error. I haven't been able to find anything online about it. What is likely the problem here and how might I fix it?
The full error code from pycharm is:
Traceback (most recent call last):
File "C:\Users\myname\OneDrive\Documents\Python Scripts\Physics Project\working3d.py", line 1, in <module>
import numpy as np
File "C:\Users\myname\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\numpy\__init__.py", line 152, in <module>
from . import random
File "C:\Users\myname\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\numpy\random\__init__.py", line 180, in <module>
from . import _pickle
File "C:\Users\myname\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\numpy\random\_pickle.py", line 3, in <module>
from ._pcg64 import PCG64, PCG64DXSM
ModuleNotFoundError: No module named 'numpy.random._pcg64'
答案1
得分: 0
你可以尝试重新安装NumPy以确保安装干净。
pip卸载numpy
pip安装numpy
英文:
You can try to reinstalling NumPy to ensure a clean installation.
pip uninstall numpy
pip install numpy
答案2
得分: 0
我还不完全确定出了什么问题,但我认为与我的conda环境设置方式有关。我重新安装了Anaconda并设置了新的环境,问题得以解决。
英文:
I'm still not completely sure what was wrong, but I think it had to do with my conda environments being set up in a weird way. I reinstalled anaconda and set up new environments and it fixed the problem.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论