question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] ModuleNotFoundError: No module named 'numpy.core'

See original GitHub issue

Expected behavior

I don’t expect any output as the doctests should all pass

Actual behavior

I want to run doctests, so I want to run for example python3 operation.py (inside /pennylane/pennylane/operation.py), but I get that error module not found.

Additional information

No response

Source code

No response

Tracebacks

Traceback (most recent call last):
  File "/opt/homebrew/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 73, in <module>
    import msvcrt
ModuleNotFoundError: No module named 'msvcrt'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/kristiyandilov/pennylane/pennylane/operation.py", line 108, in <module>
    import pennylane as qml
  File "/opt/homebrew/lib/python3.9/site-packages/pennylane/__init__.py", line 20, in <module>
    import pkg_resources
  File "/opt/homebrew/lib/python3.9/site-packages/pkg_resources/__init__.py", line 30, in <module>
    import platform
  File "/opt/homebrew/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/platform.py", line 119, in <module>
    import subprocess
  File "/opt/homebrew/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 80, in <module>
    import selectors
  File "/opt/homebrew/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/selectors.py", line 11, in <module>
    import math
  File "/Users/kristiyandilov/pennylane/pennylane/math/__init__.py", line 34, in <module>
    import autoray as ar
  File "/opt/homebrew/lib/python3.9/site-packages/autoray/__init__.py", line 1, in <module>
    from .autoray import (
  File "/opt/homebrew/lib/python3.9/site-packages/autoray/autoray.py", line 26, in <module>
    import numpy as _numpy
  File "/Users/kristiyandilov/pennylane/pennylane/numpy/__init__.py", line 84, in <module>
    from autograd import numpy as _np
  File "/opt/homebrew/lib/python3.9/site-packages/autograd/__init__.py", line 2, in <module>
    from .differential_operators import (
  File "/opt/homebrew/lib/python3.9/site-packages/autograd/differential_operators.py", line 13, in <module>
    import autograd.numpy as np
  File "/opt/homebrew/lib/python3.9/site-packages/autograd/numpy/__init__.py", line 2, in <module>
    from .numpy_wrapper import *
  File "/opt/homebrew/lib/python3.9/site-packages/autograd/numpy/numpy_wrapper.py", line 7, in <module>
    from numpy.core.einsumfunc import _parse_einsum_input
ModuleNotFoundError: No module named 'numpy.core'

System information

Name: PennyLane
Version: 0.25.0.dev0
Summary: PennyLane is a Python quantum machine learning library by Xanadu Inc.
Home-page: https://github.com/XanaduAI/pennylane
Author: 
Author-email: 
License: Apache License 2.0
Location: /opt/homebrew/lib/python3.9/site-packages
Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, pennylane-lightning, retworkx, scipy, semantic-version, toml
Required-by: PennyLane-Lightning

Platform info:           macOS-12.3.1-arm64-arm-64bit
Python version:          3.9.10
Numpy version:           1.23.0
Scipy version:           1.8.1
Installed devices:
- default.gaussian (PennyLane-0.25.0.dev0)
- default.mixed (PennyLane-0.25.0.dev0)
- default.qubit (PennyLane-0.25.0.dev0)
- default.qubit.autograd (PennyLane-0.25.0.dev0)
- default.qubit.jax (PennyLane-0.25.0.dev0)
- default.qubit.tf (PennyLane-0.25.0.dev0)
- default.qubit.torch (PennyLane-0.25.0.dev0)
- lightning.qubit (PennyLane-Lightning-0.24.0)

Existing GitHub issues

  • I have searched existing GitHub issues to make sure the issue does not already exist.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
antalszavacommented, Jul 8, 2022

Just had a chat with Josh on this and the issue arises because of our custom NumPy implementation done in the numpy module. This module is attempted to be used for the import as per namespacing.

For this reason, this error is expected. I’ll close this issue, it can be reopened if this causes any other issues.

2reactions
CatalinaAlbornozcommented, Jul 5, 2022

Hi @kris524, thank you for posting this issue here. I have looked into the issue and the most likely explanations are that your version of numpy is broken or that it’s being pulled from some unexpected place. A lot of people seem to have had this issue as can be seen here.

The common suggestion there is to try

pip uninstall numpy
conda install numpy

If this doesn’t work the best possible actions to follow probably are:

  1. Create a new virtual environment. This conda cheat sheet can be very helpful.
  2. Install only the libraries you need in this new environment.

If the problem persists please let me know! We want to help you fix this problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No module named 'numpy.core._multiarray_umath' - Stack ...
I have installed Ancaconda3 and Tensorflow. When I try to import Tensorflow in python shell I receive the following error:.
Read more >
No module named 'numpy.core._multiarray_umath' #12977
I had the same kind of error, I solved it by creating virtual environment using anaconda, then installing the necessary libraries, it worked....
Read more >
python3.10 with numpy - ModuleNotFoundError: No module ...
It looks like the extant version of numpy (1.17) that python3.10 was ok with , is not actually the minimum required (1.21).
Read more >
Original error was: No module named 'numpy.core ...
Original error was: No module named 'numpy.core._multiarray_umath' after installed pythran. Subscribe. More actions.
Read more >
No module named 'numpy.core._multiarray_umath' - Reddit
No module named 'numpy.core._multiarray_umath' ... This is what I have tried. ... Is this on Macbook M1? numpy on M1 requires a special...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found