ImportError: cannot import name 'get_distribution' - python

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

Related

pip ImportError: cannot import name 'Mapping' from 'collections'

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

when importing web3 in python getting error

I am trying to execute the "import web3" statement in python console and getting the following error.
EDIT: I am using Python 3.9.0a1 and pip 21.3.1.
I have tried doing it both in VSCode terminal and windows command prompt.
>>> import web3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\f1cmpica-1\AppData\Local\Programs\Python\Python39\lib\site-packages\web3\__init__.py", line 9, in <module>
from web3.main import (
File "C:\Users\f1cmpica-1\AppData\Local\Programs\Python\Python39\lib\site-packages\web3\main.py", line 87, in <module>
from web3.manager import (
File "C:\Users\f1cmpica-1\AppData\Local\Programs\Python\Python39\lib\site-packages\web3\manager.py", line 47, in <module>
from web3.providers import (
File "C:\Users\f1cmpica-1\AppData\Local\Programs\Python\Python39\lib\site-packages\web3\providers\__init__.py", line 8, in <module>
from .rpc import ( # noqa: F401,
File "C:\Users\f1cmpica-1\AppData\Local\Programs\Python\Python39\lib\site-packages\web3\providers\rpc.py", line 21, in <module>
from web3._utils.request import (
File "C:\Users\f1cmpica-1\AppData\Local\Programs\Python\Python39\lib\site-packages\web3\_utils\request.py", line 6, in <module>
from aiohttp import (
File "C:\Users\f1cmpica-1\AppData\Local\Programs\Python\Python39\lib\site-packages\aiohttp\__init__.py", line 6, in <module>
from .client import (
File "C:\Users\f1cmpica-1\AppData\Local\Programs\Python\Python39\lib\site-packages\aiohttp\client.py", line 35, in <module>
from . import hdrs, http, payload
File "C:\Users\f1cmpica-1\AppData\Local\Programs\Python\Python39\lib\site-packages\aiohttp\http.py", line 7, in <module>
from .http_parser import (
File "C:\Users\f1cmpica-1\AppData\Local\Programs\Python\Python39\lib\site-packages\aiohttp\http_parser.py", line 15, in <module>
from .helpers import NO_EXTENSIONS, BaseTimerContext
File "C:\Users\f1cmpica-1\AppData\Local\Programs\Python\Python39\lib\site-packages\aiohttp\helpers.py", line 48, in <module>
from typing_extensions import Protocol
File "C:\Users\f1cmpica-1\AppData\Local\Programs\Python\Python39\lib\site-packages\typing_extensions.py", line 2142, in <module>
def TypeAlias(self, parameters):
TypeError: __init__() missing 1 required positional argument: 'doc'
You mentioned no version numbers.
https://stackoverflow.com/help/minimal-reproducible-example
I installed these from conda-forge, with interpreter 3.9.7 on MacOS 12.0.1:
typing-extensions 4.0.1
web3 5.26.0
And then import web3 works Just Fine.

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

pandas_datareader ImportError: cannot import name string_types

import pandas_datareader as pdr
pdr.get_data_yahoo('AAPL')
I installed pandas_datareader via pip and it all success.
When i try to run a simple code, i got below error:
"C:\Users\<username>\Anaconda2\python.exe"
"C:/Users/<username>/PycharmProjects/untitled2/Yahoo.py"
Traceback (most recent call last):
File "C:/Users/<username>/PycharmProjects/untitled2/Yahoo.py", line 1, in <module>
import pandas_datareader as pdr
File "C:\Users\<username>\Anaconda2\lib\site-packages\pandas_datareader\__init__.py", line 3, in <module>
from .data import (get_components_yahoo, get_data_famafrench, get_data_google, get_data_yahoo, get_data_enigma, # noqa
File "C:\Users\<username>\Anaconda2\lib\site-packages\pandas_datareader\data.py", line 7, in <module>
from pandas_datareader.google.daily import GoogleDailyReader
File "C:\Users\<username>\Anaconda2\lib\site-packages\pandas_datareader\google\daily.py", line 1, in <module>
from pandas_datareader.base import _DailyBaseReader
File "C:\Users\<username>\Anaconda2\lib\site-packages\pandas_datareader\base.py", line 7, in <module>
import pandas.compat as compat
File "C:\Users\<username>\Anaconda2\lib\site-packages\pandas\__init__.py", line 25, in <module>
from pandas.core.api import *
File "C:\Users\<username>\Anaconda2\lib\site-packages\pandas\core\api.py", line 14, in <module>
from pandas.core.series import Series, TimeSeries
File "C:\Users\<username>\Anaconda2\lib\site-packages\pandas\core\series.py", line 35, in <module>
from pandas.compat.scipy import scoreatpercentile as _quantile
File "C:\Users\<username>\Anaconda2\lib\site-packages\pandas\compat\scipy.py", line 5, in <module>
import numpy as np
File "C:\Users\<username>\Anaconda2\lib\site-packages\pandas\compat\numpy\__init__.py", line 6, in <module>
from pandas.compat import string_types, string_and_binary_types
ImportError: cannot import name string_types
Process finished with exit code 1
I have Python 2.7 version adn Windows 7 64 bit system.
Is the process of installation issue?
conda version issue. Need to upgrade conda version

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