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.
Related
There appear to be conflicting libraries of python that pip is trying to access, as you can see with the following error:
[root#fedora user]# pip
Traceback (most recent call last):
File "/usr/local/bin/pip", line 5, in <module>
from pip._internal import main
File "/usr/local/lib/python3.10/site-packages/pip/_internal/__init__.py", line 40, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/usr/local/lib/python3.10/site-packages/pip/_internal/cli/autocompletion.py", line 8, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/usr/local/lib/python3.10/site-packages/pip/_internal/cli/main_parser.py", line 12, in <module>
from pip._internal.commands import (
File "/usr/local/lib/python3.10/site-packages/pip/_internal/commands/__init__.py", line 6, in <module>
from pip._internal.commands.completion import CompletionCommand
File "/usr/local/lib/python3.10/site-packages/pip/_internal/commands/completion.py", line 6, in <module>
from pip._internal.cli.base_command import Command
File "/usr/local/lib/python3.10/site-packages/pip/_internal/cli/base_command.py", line 25, in <module>
from pip._internal.index import PackageFinder
File "/usr/local/lib/python3.10/site-packages/pip/_internal/index.py", line 14, in <module>
from pip._vendor import html5lib, requests, six
File "/usr/local/lib/python3.10/site-packages/pip/_vendor/html5lib/__init__.py", line 25, in <module>
from .html5parser import HTMLParser, parse, parseFragment
File "/usr/local/lib/python3.10/site-packages/pip/_vendor/html5lib/html5parser.py", line 8, in <module>
from . import _tokenizer
File "/usr/local/lib/python3.10/site-packages/pip/_vendor/html5lib/_tokenizer.py", line 16, in <module>
from ._trie import Trie
File "/usr/local/lib/python3.10/site-packages/pip/_vendor/html5lib/_trie/__init__.py", line 3, in <module>
from .py import Trie as PyTrie
File "/usr/local/lib/python3.10/site-packages/pip/_vendor/html5lib/_trie/py.py", line 6, in <module>
from ._base import Trie as ABCTrie
File "/usr/local/lib/python3.10/site-packages/pip/_vendor/html5lib/_trie/_base.py", line 3, in <module>
from collections import Mapping
ImportError: cannot import name 'Mapping' from 'collections' (/usr/lib64/python3.10/collections/__init__.py)
How can I fix this to be able to use pip? I have already tried
dnf reinstall python and dnf reinstall python3 and dnf remove python3-pip, dnf install python3-pip.
I fixed this by removing all pip folders in /usr/local/lib/python3.10/site-packages
Open the File: "/usr/local/lib/python3.10/site-packages/pip/_vendor/html5lib/_trie/_base.py", and at line 3 instead of
from collections import Mapping
add .abc after collections
from collections.abc import Mapping
Python version: 3.6.8
SpaCy version: 2.1.4
Just try to import spacy:
Traceback (most recent call last):
File "src/discovery/pipeline/news/news_pipeline.py", line 9, in <module>
from src.discovery.modules.news.pipeline.auginewspipeline import AugINewsPipeline
File "/local/apps/discopyusr1/discovery-python/src/discovery/modules/news/pipeline/auginewspipeline.py", line 10, in <module>
from src.discovery.modules.news.pipeline.feature_extraction.featureextractor import FeatureExtracter
File "/local/apps/discopyusr1/discovery-python/src/discovery/modules/news/pipeline/feature_extraction/featureextractor.py", line 2, in <module>
import spacy
File "/usr/local/lib64/python3.6/site-packages/spacy/__init__.py", line 12, in <module>
from .cli.info import info as cli_info
File "/usr/local/lib64/python3.6/site-packages/spacy/cli/__init__.py", line 1, in <module>
from .download import download # noqa: F401
File "/usr/local/lib64/python3.6/site-packages/spacy/cli/download.py", line 11, in <module>
from .link import link
File "/usr/local/lib64/python3.6/site-packages/spacy/cli/link.py", line 9, in <module>
from .. import util
File "/usr/local/lib64/python3.6/site-packages/spacy/util.py", line 17, in <module>
from jsonschema import Draft4Validator
File "/usr/local/lib/python3.6/site-packages/jsonschema/__init__.py", line 32, in <module>
from pkg_resources import get_distribution
ImportError: cannot import name 'get_distribution'
install pkg-resources, that should fix it.
pip install pkg-resource. Make sure pip is up to date
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
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!!
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