numpy multicore error while using matplotlib - python

while i try to run a matplotlib example program it shows "Failed to import numpy multicore array".Then i upgrade the numpy version from 1.12 to 1.15 on both the python versions 2.7 and 3.5(in raspberry pi python 2.7 is a default version).
The code am using is:
import matplotlib.pyplot as plt
plt.plot([1, 2, 3, 4])
plt.ylabel('some numbers')
plt.show()
while running this code it show some different error that
Traceback (most recent call last):
File "/home/pi/.local/lib/python3.5/site-packages/numpy/core/__init__.py", line 16, in <module>
from . import multiarray
ImportError: libf77blas.so.3: cannot open shared object file: No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pi/hdg.py", line 1, in <module>
import matplotlib.pyplot as plt
File "/usr/local/lib/python3.5/dist-packages/matplotlib/__init__.py", line 141, in <module>
from . import cbook, rcsetup
File "/usr/local/lib/python3.5/dist-packages/matplotlib/cbook/__init__.py", line 33, in <module>
import numpy as np
File "/home/pi/.local/lib/python3.5/site-packages/numpy/__init__.py", line 142, in <module>
from . import add_newdocs
File "/home/pi/.local/lib/python3.5/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/home/pi/.local/lib/python3.5/site-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/home/pi/.local/lib/python3.5/site-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/home/pi/.local/lib/python3.5/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: libf77blas.so.3: cannot open shared object file: No such file or directory
how to overcome this one?

Related

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.

Python as non admin?

Im trying to package Anaconda with Tensorflow and Keras on Windows 10 for a class in our labs environment which the labs computers do not have administrator access nor do the students for security reasons.
Problem few lines of code to test to see if the installation is working correctly only work when you launch python as administrator:
>>> import keras
c:\Anaconda3\lib\site-packages\h5py\__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 ==
np.dtype(float).type`.
from ._conv import register_converters as _register_converters
Using TensorFlow backend.
when running as non admin account:
>>> import keras
Traceback (most recent call last):
File "c:\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 16, in <module>
from . import multiarray
ImportError: dynamic module does not define module export function (PyInit_multiarray)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\Anaconda3\lib\site-packages\keras\__init__.py", line 3, in <module>
from . import utils
File "c:\Anaconda3\lib\site-packages\keras\utils\__init__.py", line 2, in <module>
from . import np_utils
File "c:\Anaconda3\lib\site-packages\keras\utils\np_utils.py", line 6, in <module>
import numpy as np
File "c:\Anaconda3\lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import add_newdocs
File "c:\Anaconda3\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "c:\Anaconda3\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
File "c:\Anaconda3\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "c:\Anaconda3\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: dynamic module does not define module export function (PyInit_multiarray)

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!

Py2exe + nibabel

When I try to launch the application (.exe) file created by p2toexe, I receive the following error message:
Traceback (most recent call last):
File "main_GUI.py", line 12, in <module>
File "nibabel\__init__.pyc", line 38, in <module>
File "nibabel\analyze.pyc", line 87, in <module>
File "nibabel\volumeutils.pyc", line 22, in <module>
File "nibabel\casting.pyc", line 11, in <module>
File "nibabel\testing\__init__.pyc", line 35, in <module>
File "nibabel\testing\np_features.pyc", line 19, in <module>
File "nibabel\testing\np_features.pyc", line 12, in _memmap_after_ufunc
IOError: [Errno 2] No such file or directory: 'C:\\Work\\PyToExe\\GUI\\v4\\dist\\lib2\\library.lib\\nibabel\\testing\\np_features.pyc'
When I ran the original Python script, no errors were raised with regard to importing nibabel.
In response to #Sagar's comment:
The import in the file Main_GUI.m:
from __future__ import print_function
import matplotlib.pyplot as plt
from matplotlib import widgets
import numpy as np
import nibabel as nib
import matplotlib as mpl
import time
import os
there was a problem of compatibility between the modules versions (py2exe==0.6.9 and nibabel==2.2.0).
It works with py2exe 0.6.9 and nibabel 2.1.0.

matplotlib says it needs libpng15, but I have libpng16

The problem is likely a configuration issue, because getting the installation correct on Macs seems to be tricky. I'm running Mavericks and matplotlib 1.4.x, yet when I open a Python 2.7.5 shell and import pylib, I get this error:
>>> import pylab
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/pylab.py", line 1, in <module>
from matplotlib.pylab import *
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/pylab.py", line 230, in <module>
import matplotlib.finance
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/finance.py", line 38, in <module>
from matplotlib.collections import LineCollection, PolyCollection
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/collections.py", line 27, in <module>
import matplotlib.backend_bases as backend_bases
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/backend_bases.py", line 55, in <module>
import matplotlib.textpath as textpath
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/textpath.py", line 22, in <module>
from matplotlib.mathtext import MathTextParser
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/mathtext.py", line 64, in <module>
import matplotlib._png as _png
ImportError: dlopen(/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/_png.so, 2): Library not loaded: /usr/local/lib/libpng15.15.dylib
Referenced from: /Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/_png.so
Reason: image not found
I have libpng16 installed, but not libpng15.
I saw a hardcoded reference to libpng15 in _png.so.
Uninstall and install of matplotlib fixed the issue for me.
You can always moke it by generating a soft link like this
sudo ln -s /opt/X11/lib/libpng.dylib /usr/local/lib/libpng15.15.dylib
Not the cleaner solution but I haven't figure out why matplotlib stubbornly asks specifically for libpng15 and not any 15 or greater.

Categories