Python ModuleNotFoundError: No module named ‘numpy.random._pcg64’

huangapple go评论107阅读模式
英文:

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 &quot;C:\Users\myname\OneDrive\Documents\Python Scripts\Physics Project\working3d.py&quot;, line 1, in &lt;module&gt;
    import numpy as np
  File &quot;C:\Users\myname\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\numpy\__init__.py&quot;, line 152, in &lt;module&gt;
    from . import random
  File &quot;C:\Users\myname\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\numpy\random\__init__.py&quot;, line 180, in &lt;module&gt;
    from . import _pickle
  File &quot;C:\Users\myname\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\numpy\random\_pickle.py&quot;, line 3, in &lt;module&gt;
    from ._pcg64 import PCG64, PCG64DXSM
ModuleNotFoundError: No module named &#39;numpy.random._pcg64&#39;

答案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.

huangapple
  • 本文由 发表于 2023年6月1日 21:15:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/76382296.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定