ModuleNotFoundError: No module named 'numpy.core._multiarray_umath' - python-3.x

I have a simple python program which I am running on a Mac machine.
import numpy as np
def main():
print("np arr test")
arr = np.array([1.0, 2.0, 3.0])
print(arr)
if __name__ == "__main__":
main()
I've verified that the numpy library was correct installed through pip
pip3 list | grep numpy
msgpack-numpy 0.4.4.3
numpy 1.16.2
numpydoc 0.8.0
I get the following error when I run the program
Traceback (most recent call last):
File "/Volumes/brazil-pkg-cache/packages/Python-numpy/Python-numpy-1.x.140450.0/AL2012/DEV.STD.PTHREAD/build/lib/python3.6/site-packages/numpy/core/__init__.py", line 24, in <module>
from . import multiarray
File "/Volumes/brazil-pkg-cache/packages/Python-numpy/Python-numpy-1.x.140450.0/AL2012/DEV.STD.PTHREAD/build/lib/python3.6/site-packages/numpy/core/multiarray.py", line 14, in <module>
from . import overrides
File "/Volumes/brazil-pkg-cache/packages/Python-numpy/Python-numpy-1.x.140450.0/AL2012/DEV.STD.PTHREAD/build/lib/python3.6/site-packages/numpy/core/overrides.py", line 7, in <module>
from numpy.core._multiarray_umath import (
ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Volumes/workplace/RPAsosDevelopmentWS/src/RPAsosDevelopmentPy/src/rp_asos_development_py/adhoc_dev/float_nan_test.py", line 1, in <module>
import numpy as np
File "/Volumes/brazil-pkg-cache/packages/Python-numpy/Python-numpy-1.x.140450.0/AL2012/DEV.STD.PTHREAD/build/lib/python3.6/site-packages/numpy/__init__.py", line 142, in <module>
from . import core
File "/Volumes/brazil-pkg-cache/packages/Python-numpy/Python-numpy-1.x.140450.0/AL2012/DEV.STD.PTHREAD/build/lib/python3.6/site-packages/numpy/core/__init__.py", line 50, in <module>
raise ImportError(msg)
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.6 from "/usr/local/bin/python3.6"
* The NumPy version is: "1.18.4"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: No module named 'numpy.core._multiarray_umath'
Process finished with exit code 1
Can you please help me figure out what I am missing? Appreciate your response!
NOTE : Based on the stack overflow post I updated the numpy through the following command
pip3 install numpy --upgrade
pip3 list | grep numpy
msgpack-numpy 0.4.4.3
numpy 1.21.2
numpydoc 0.8.0
WARNING: You are using pip version 21.2.1; however, version 21.2.4 is available.
However I still see the error message

Try to uninstall numpy and install it again.

Related

CuPy import failing due to missing DLL file although it appears in my directories

I am attempting to use cuPy to speed up some background numpy operations in my python code but when attempting to import cupy I am told that the DLL load failed and the module could not be found, cupy_backends.cuda.libs import nvrtc. (Specific errors at end of post)
I've attempted almost everything the error message suggests. I check my version of cupy and cuda which are cupy-cuda111==8.4.0, I have Cuda 11.2 installed as well. I am running Windows 10 and Python 3.7.6 on Spyder 3. I have tried uninstalling cupy via pip uninstall in hopes of reinstalling correctly but it just hangs and never uninstalls the package.
It appears I have the file its looking for when I go search manually via my file explorer. (Imaged Below)
I am fairly inexperienced when it comes to handling things like this so any help would be greatly appreciated. The entire error message and trace is copied below:
import cupy as cp
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\cupy\__init__.py", line 20, in <module>
from cupy import core # NOQA
File "C:\ProgramData\Anaconda3\lib\site-packages\cupy\core\__init__.py", line 1, in <module>
from cupy.core import core # NOQA
File "cupy\core\core.pyx", line 1, in init cupy.core.core
File "C:\ProgramData\Anaconda3\lib\site-packages\cupy\cuda\__init__.py", line 5, in <module>
from cupy.cuda import compiler # NOQA
File "C:\ProgramData\Anaconda3\lib\site-packages\cupy\cuda\compiler.py", line 14, in <module>
from cupy_backends.cuda.libs import nvrtc
ImportError: DLL load failed: The specified module could not be found.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<ipython-input-1-e011b0e859cc>", line 1, in <module>
import cupy as cp
File "C:\ProgramData\Anaconda3\lib\site-packages\cupy\__init__.py", line 41, in <module>
raise ImportError(_msg) from e
ImportError: CuPy is not correctly installed.
If you are using wheel distribution (cupy-cudaXX), make sure that the version of CuPy you installed matches with the version of CUDA on your host.
Also, confirm that only one CuPy package is installed:
$ pip freeze
If you are building CuPy from source, please check your environment, uninstall CuPy and reinstall it with:
$ pip install cupy --no-cache-dir -vvvv
Check the Installation Guide for details:
https://docs.cupy.dev/en/latest/install.html
original error: DLL load failed: The specified module could not be found.

Import NumPy fails using Windows despite it being installed

I just managed to get this figured out but i couldn't find a post about my specific problem so here it is.
I had installed numpy using
py -m pip install NumPy
I got the following error when I tried to import it
>>> import NumPy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'NumPy'
I solved my problem by unistalling NumPy and re-installing it with all LOWER-CASE LETTERS i.e.
py -m pip install numpy
Now I can import it with lower case letters
>>> import numpy
>>>
hope this can help someone else save an hour.

Pandas not working: DataFrameGroupBy ; PanelGroupBy

I have just upgraded python and I cannot get pandas to run properly, please see below. Nothing appears to work.
Traceback (most recent call last): File
"/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tqdm/_tqdm.py",
line 613, in pandas
from pandas.core.groupby.groupby import DataFrameGroupBy, \ ImportError: cannot import name 'DataFrameGroupBy' from
'pandas.core.groupby.groupby'
(/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/groupby/groupby.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"code/analysis/get_cost_matrix.py", line 23, in
tqdm.pandas() # Gives us nice progress bars File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tqdm/_tqdm.py",
line 616, in pandas
from pandas.core.groupby import DataFrameGroupBy, \ ImportError: cannot import name 'PanelGroupBy' from 'pandas.core.groupby'
(/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/groupby/init.py)
I guess you are using an older version of tqdm. Try using a version above tqdm>=4.23.4.
The command using pip would be,
pip install tqdm --upgrade
The problem is with the 0.25.1 version of pandas. Consider downgrading it to 0.24.0.
For more information read this
pip install --upgrade pandas==0.24.0

import rpy2.ipython meet error ModuleNotFoundError: No module named 'IPython'

My python version is 3.6. my OS is windows. After install rpy2 module, when I type import rpy2, got no issue. But when type import rpy2.ipython, got error as below:
>>> import rpy2.ipython
Warning (from warnings module):
File "D:\Soft_app\Python\lib\site-packages\rpy2\ipython\rmagic.py", line 76
"either.")))
UserWarning: The Python package 'pandas' is strongly recommended when using `rpy2.ipython`. Unfortunately it could not be loaded, and we did not manage to load 'numpy' either.
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
import rpy2.ipython
File "D:\Soft_app\Python\lib\site-packages\rpy2\ipython\__init__.py", line 1, in <module>
from .rmagic import load_ipython_extension
File "D:\Soft_app\Python\lib\site-packages\rpy2\ipython\rmagic.py", line 81, in <module>
from IPython.core.displaypub import publish_display_data
ModuleNotFoundError: No module named 'IPython'
Can help to figure out what's issue??
It seems that you are missing Ipython and pandas. Installing them should resolve your issue.
Run "pip install ipython" to install Ipython and run "pip install pandas" to install pandas.
Hopefully, this will solve your problem.
Happy Coding ~

from pandas import * -- Python issue

I am trying to run the following code in python 3.3
from pandas import *
and I receive the following error:
Traceback (most recent call last):
File "C:\Users\Tom\Desktop\ProgrammingStuff\Python\FXCointegrationBacktesting.py", line 9, in <module>
cannot import name text_type
from pandas import *
File "C:\Python33\lib\site-packages\pandas\__init__.py", line 6, in <module>
from . import hashtable, tslib, lib
File "tslib.pyx", line 31, in init pandas.tslib (pandas\tslib.c:48782)
File "C:\Python33\lib\site-packages\dateutil\parser.py", line 24, in <module>
from six import text_type, binary_type, integer_types
ImportError: cannot import name text_type
Not sure what the problem is, I am fairly new to python and I cannot currently find any solutions to this problem on stack overflow.
Thanks!
You're using a version of dateutil that depends on six.
In dateutil <= 1.5 you don't need six, but those versions are not compatible with Python >= 3.0. So, the solution is to install six. However you do that is up to you.
You could do
pip install six
If you choose not to use pip it will depend on your system's package manager how you go about installing it.

Resources