Numpy not found in python and found in ipython - python

I installed numpy using pip. when I run ipython, numpy is imported successfully but when I run python and import numpy I get
ImportError: No module named numpy
I tried to set $PYTHONPATH to /usr/local/lib/python2.7/dist-packages
but then I get
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/numpy/__init__.py", line 180, 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 14, in <module>
from . import multiarray
ImportError: /usr/local/lib/python2.7/dist-packages/numpy/core/multiarray.so: undefined symbol: PyUnicodeUCS4_AsUnicodeEscapeString
I am using
python 2.7.6
and Ipython 4.1.1

Related

ArcGIS 10.4.1 ImportError: cannot import name multiarray with numpy

I've installed ArcGIS 10.4.1, and with it the numpy 1.9.2 library. However, I get the following error when I try to run any scripts with numpy:
>>> import numpy
Runtime error
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Python27\ArcGIS10.4\lib\site-packages\numpy\__init__.py", line
170, in <module>
from . import add_newdocs
File "C:\Python27\ArcGIS10.4\lib\site-packages\numpy\add_newdocs.py", line
13, in <module>
from numpy.lib import add_newdoc
File "C:\Python27\ArcGIS10.4\lib\site-packages\numpy\lib\__init__.py",
line 8, in <module>
from .type_check import *
File "C:\Python27\ArcGIS10.4\lib\site-packages\numpy\lib\type_check.py",
line 11, in <module>
import numpy.core.numeric as _nx
File "C:\Python27\ArcGIS10.4\lib\site-packages\numpy\core\__init__.py",
line 6, in <module>
from . import multiarray
ImportError: cannot import name multiarray
I've tried uninstalling and re-installing ArcGIS, still with no luck.
Thanks in advance

Numpy Import Issue

I'm trying to run some code that uses the numpy library, but with only the statement
>>>import numpy
i get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\numpy\__init__.py", line 137, in <module>
import add_newdocs
File "C:\Python27\lib\site-packages\numpy\add_newdocs.py", line 9, in <module>
from numpy.lib import add_newdoc
File "C:\Python27\lib\site-packages\numpy\lib\__init__.py", line 4, in <module>
from type_check import *
File "C:\Python27\lib\site-packages\numpy\lib\type_check.py", line 8, in <module>
import numpy.core.numeric as _nx
File "C:\Python27\lib\site-packages\numpy\core\__init__.py", line 5, in <module>
import multiarray
ImportError: DLL load failed: %1 no es una aplicaci¾n Win32 vßlida.
I already done the numpy installation as follows:
pip install numpy
at the command line, and everithing was fine.
What's wrong?
I have 64 bits Windows 10 and python 2.7.13
Thanks!!

Unable to import python packages in Ubuntu (ImportError : undefined symbol)

I recently installed python on my Ubuntu 14.04. I downloaded tensorflow by pip.
When I tried to import tensorflow it said ImportError:No module named tensorflow.
Then I edited PYTHONPATH by adding /usr/local/lib/python2.7/dist-packages. Now when I try to import, it says
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py", line 23, in <module>
from tensorflow.python import *
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 45, in <module>
import numpy as np
File "/usr/local/lib/python2.7/dist-packages/numpy/__init__.py", line 180, 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 14, in <module>
from . import multiarray
ImportError: /usr/local/lib/python2.7/dist-packages/numpy/core/multiarray.so: undefined symbol: PyUnicodeUCS4_AsUnicodeEscapeString
I found here that 2 versions of python causes the conflict, but that didn't help. Any assistance will be appreciated. Thank you
Best way to install packages if you have more than one python installed is:
path_to_your_python_executable -m pip install package_name
This way, you can make sure that you have installed package for proper python.
And don't forget about sudo ;)

numpy suddenly started failing to import

I have anaconda installed. Running python 2.7. I have uninstalled, reinstalled, and upgraded numpy to 1.11.0, uninstalled and reinstalled pandas, and I still get this traceback when I try to import numpy:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/nicole/anaconda/lib/python2.7/site-packages/numpy-1.11.0-py2.7-macosx-10.5-x86_64.egg/numpy/__init__.py", line 180, in <module>
from . import add_newdocs
File "/Users/nicole/anaconda/lib/python2.7/site-packages/numpy-1.11.0-py2.7-macosx-10.5-x86_64.egg/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/Users/nicole/anaconda/lib/python2.7/site-packages/numpy-1.11.0-py2.7-macosx-10.5-x86_64.egg/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/Users/nicole/anaconda/lib/python2.7/site-packages/numpy-1.11.0-py2.7-macosx-10.5-x86_64.egg/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/Users/nicole/anaconda/lib/python2.7/site-packages/numpy-1.11.0-py2.7-macosx-10.5-x86_64.egg/numpy/core/__init__.py", line 58, in <module>
from numpy.testing.nosetester import _numpy_tester
File "/Users/nicole/anaconda/lib/python2.7/site-packages/numpy-1.11.0-py2.7-macosx-10.5-x86_64.egg/numpy/testing/__init__.py", line 12, in <module>
from . import decorators as dec
File "/Users/nicole/anaconda/lib/python2.7/site-packages/numpy-1.11.0-py2.7-macosx-10.5-x86_64.egg/numpy/testing/decorators.py", line 21, in <module>
from .utils import SkipTest
File "/Users/nicole/anaconda/lib/python2.7/site-packages/numpy-1.11.0-py2.7-macosx-10.5-x86_64.egg/numpy/testing/utils.py", line 15, in <module>
from tempfile import mkdtemp, mkstemp
File "/Users/nicole/anaconda/lib/python2.7/tempfile.py", line 35, in <module>
from random import Random as _Random
File "random/__init__.py", line 99, in <module>
from .mtrand import *
File "numpy.pxd", line 92, in init mtrand (numpy/random/mtrand/mtrand.c:37726)
It was working fine last night, which is really frustrating. Thank you for any insight.

Numpy: ImportError: cannot import name TestCase

I installed numpy from
sudo apt-get install numpy
Then in python2.7 on importing numpy with
import numpy
I get this error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/numpy/__init__.py", line 137, in <module>
import add_newdocs
File "/usr/local/lib/python2.7/dist-packages/numpy/add_newdocs.py", line 9, in <module>
from numpy.lib import add_newdoc
File "/usr/local/lib/python2.7/dist-packages/numpy/lib/__init__.py", line 4, in <module>
from type_check import *
File "/usr/local/lib/python2.7/dist-packages/numpy/lib/type_check.py", line 8, in <module>
import numpy.core.numeric as _nx
File "/usr/local/lib/python2.7/dist-packages/numpy/core/__init__.py", line 45, in <module>
from numpy.testing import Tester
File "/usr/local/lib/python2.7/dist-packages/numpy/testing/__init__.py", line 8, in <module>
from unittest import TestCase
ImportError: cannot import name TestCase
I then removed Numpy and Scipy. Then again installed from the github repo. But I still get the same error. Please help.
Thank You.
I suspect that you have a local file called unittest.py that is getting imported instead of the standard module.

Categories