Importing numpy in python take an error - python

I try to run import numpy on my machine. but after do it take an error like this:
$ python -c "import numpy"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/numpy/__init__.py", line 142, in <module>
from . import add_newdocs
File "/usr/local/lib/python2.7/dist-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/usr/local/lib/python2.7/dist-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/usr/local/lib/python2.7/dist-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/usr/local/lib/python2.7/dist-packages/numpy/core/__init__.py", line 24, in <module>
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control). Otherwise reinstall numpy.
The error is about numpy! i try to check numpy by excute this command
$apt-cache policy python-numpy
python-numpy:
Installed: 1:1.11.0-1ubuntu1
Candidate: 1:1.11.0-1ubuntu1
Version table:
*** 1:1.11.0-1ubuntu1 500
500 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages
100 /var/lib/dpkg/status
this show that numpy install in my machine in correct state.
i uninstalled numpy and all of my python dependency in my machine and install it again.
but problem is exist. i cant find what is the problem?

Related

Pycharm can't find the python(conda env) packages

I'm using a conda env as python interpreter and I've all the necessary packages installed
But when I run the file, I get this error
Traceback (most recent call last):
File "D:\Anaconda3\envs\tf\lib\site-packages\numpy\core\__init__.py", line 16,
in <module>
from . import multiarray
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:/Programming Projects/python projects/MaskRCNN/src/test_tf.py", line 8
, in <module>
import numpy as np
File "D:\Anaconda3\envs\tf\lib\site-packages\numpy\__init__.py", line 142, in
<module>
from . import add_newdocs
File "D:\Anaconda3\envs\tf\lib\site-packages\numpy\add_newdocs.py", line 13, i
n <module>
from numpy.lib import add_newdoc
File "D:\Anaconda3\envs\tf\lib\site-packages\numpy\lib\__init__.py", line 8, i
n <module>
from .type_check import *
File "D:\Anaconda3\envs\tf\lib\site-packages\numpy\lib\type_check.py", line 11
, in <module>
import numpy.core.numeric as _nx
File "D:\Anaconda3\envs\tf\lib\site-packages\numpy\core\__init__.py", line 26,
in <module>
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control). Otherwise reinstall numpy.
Original error was: DLL load failed: The specified module could not be found.
Process finished with exit code 1
But when I run it from the terminal, it works just fine
Does anyone have any clue on what might be a fix?
It is a known issue, should be fixed in 2019.1 EAP. Could you please update and check?

Numpy Library not loading(In face none of the library)

I have installed Python 3.7, and I have been working in Python for a while. It was working all fine and suddenly from this afternoon, I am unable to load any Python libraries. I have tried to uninstall and install entire libraries and Python itself. It has not fixed the issue yet. Could someone help on what else to be looked at. I have been using pip3 to install packages. I am not using Anaconda. I was able to install the package successfully but unable to load for some reason. When I try to load numpy, I am getting below mentioned error
import numpy
Traceback (most recent call last):
File "C:\Users\chango3\AppData\Local\Programs\Python\Python37\lib\site-packages\numpy\core\__init__.py", line 16, in <module>
from . import multiarray
ImportError: DLL load failed: The network path was not found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\chango3\AppData\Local\Programs\Python\Python37\lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import add_newdocs
File "C:\Users\chango3\AppData\Local\Programs\Python\Python37\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Users\chango3\AppData\Local\Programs\Python\Python37\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
File "C:\Users\chango3\AppData\Local\Programs\Python\Python37\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "C:\Users\chango3\AppData\Local\Programs\Python\Python37\lib\site-packages\numpy\core\__init__.py", line 26, in <module>
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control). Otherwise reinstall numpy.
Original error was: DLL load failed: The network path was not found.
Any help would be appreciated

import arcpy in the VS Code terminal fails

I am trying to get arcpy to import in the vs code terminal (running python 2.7 as an arcgis install). It runs fine if I open a command window, initiate python, and import arcpy. It also works within the ArcGIS environment. This leads me to beloeve that the error below is inaccurate. Importing arcpy does not work at the VS Code terminal. How can I resolve this?
>>> import arcpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Program Files (x86)\ArcGIS\Desktop10.6\ArcPy\arcpy\__init__.py", line 20, in <module>
import numpy
File "C:\Python27\ArcGIS10.6\lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import add_newdocs
File "C:\Python27\ArcGIS10.6\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Python27\ArcGIS10.6\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
File "C:\Python27\ArcGIS10.6\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "C:\Python27\ArcGIS10.6\lib\site-packages\numpy\core\__init__.py", line 26, in <module>
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control). Otherwise reinstall numpy.
Original error was: DLL load failed: The specified path is invalid.

numpy error when running Python script from cmd

I have a Python script which I want to start from cmd because I'm going to call it in a C# script.
The problem is, the code works fine in the IDE and when I call it from the Anaconda script but not when I call it from the regular cmd.
I'm calling the script with the following line:
$ python c:/Users/myname/pycharmProjects/testing/main.py
I get the following error message:
Traceback (most recent call last):
File "c:/Users/myname/pycharmProjects/testing/main.py", line 1, in <module>
import process
File "/cygdrive/c/Users/myname/pycharmProjects/testing/process.py", line 4, in <module>
import numpy as np
File "/cygdrive/c/Users/myname/pycharmProjects/testing/numpy/__init__.py", lin e 142, in <module>
from . import add_newdocs
File "/cygdrive/c/Users/myname/pycharmProjects/testing/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/cygdrive/c/Users/myname/pycharmProjects/testing/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/cygdrive/c/Users/myname/pycharmProjects/testing/numpy/lib/type_check.py ", line 11, in <module>
import numpy.core.numeric as _nx
File "/cygdrive/c/Users/myname/pycharmProjects/testing/numpy/core/__init__.py" , line 26, in <module>
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control). Otherwise reinstall numpy.
Original error was: cannot import name multiarray
I have uninstalled and reinstalled numpy, but the error is still the same. I'm really confused why I it works via the Anaconda prompt, but not the cmd as I did set the PATH variable.
Any help is appreciated!

Installing Matplotlib in Windows 10 64bits

Could anyone tell me what files I should download and which statements I must execute in the command line to install Matplotlib?
I have Python 2.7.13 on Windows 10 64 bit.
These are the files I unzipped:
All downloaded from: http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
Commands I executed:
python -m pip install -U pip setuptools
python -m pip install matplotlib
python -m pip install -U pip
I am getting these two errors when checking if Numpy and Matplotlib are installed.
>>> import numpy
**Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
import numpy
File "numpy\__init__.py", line 142, in <module>
from . import add_newdocs
File "numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
File "numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "numpy\core\__init__.py", line 26, in <module>
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control). Otherwise reinstall numpy.
Original error was: DLL load failed: %1 no es una aplicación Win32 válida.**
>>> import matplotlib
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
import matplotlib
File "matplotlib\__init__.py", line 122, in <module>
from matplotlib.cbook import is_string_like, mplDeprecation, dedent, get_label
File "matplotlib\cbook.py", line 33, in <module>
import numpy as np
File "numpy\__init__.py", line 142, in <module>
from . import add_newdocs
File "numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
File "numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "numpy\core\__init__.py", line 26, in <module>
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control). Otherwise reinstall numpy.
Original error was: DLL load failed: %1 no es una aplicación Win32 válida.
This is a common issue for windows users. And you will probably need precompiled packages for some other libraries as well, e.g. scipy.
You will find on SourceForge the numpy superpack whose name structure is numpy-X.X.X-win32-superpack-python2.7.exe, e.g. numpy-1.9.2-win32-superpack-python2.7.
On Pypi (Python Package Index), you will find the matplotlib library, whose name structure is matplotlib-X.X.X.win32-py2.7.exe, e.g matplotlib-1.4.3.win32-py2.7.exe.
Installing matplotlib through pip by automatically downloading the files from the python index as you're trying to do here will most probably fail for windows.
There are two main options:
Install a complete distribution like Anaconda, Canopy, WinPython, etc. which already has all the respective libraries included.
Use precompiled wheels. A source for those is indeed this site by Christoph Gohlke. You would then need to make sure to install all dependencies first and matplotlib last. Starting with numpy is the best, then other dependencies, matplotlib last. To install those use
pip install <filename of wheel>
e.g.
pip install numpy‑1.13.0rc1+mkl‑cp27‑cp27m‑win_amd64.whl

Categories