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.
Related
i have problem with import pandas package on one of my hosting accounts:
Pandas is installed (v 1.5.1)
I've tested import pandas on other hosting accounts
It is shared hosting. I cannot do sudo commands. Anaconda also can't be installed
I'm using python 3.9.0
I've tested it on virtual env ( response listed below ) and also without virtual env
source ~/.virtualenvs/MY_VIRTUAL_ENV_NAME/bin/activate
$ python3
>>> import pandas as pa
and i recive response:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/MY_LOGIN/.virtualenvs/MY_VIRTUAL_ENV_NAME/lib/python3.9/site-packages/pandas/__init__.py", line 48, in <module>
from pandas.core.api import (
File "/home/MY_LOGIN/.virtualenvs/MY_VIRTUAL_ENV_NAME/lib/python3.9/site-packages/pandas/core/api.py", line 47, in <module>
from pandas.core.groupby import (
File "/home/MY_LOGIN/.virtualenvs/MY_VIRTUAL_ENV_NAME/lib/python3.9/site-packages/pandas/core/groupby/__init__.py", line 1, in <module>
from pandas.core.groupby.generic import (
File "/home/MY_LOGIN/.virtualenvs/MY_VIRTUAL_ENV_NAME/lib/python3.9/site-packages/pandas/core/groupby/generic.py", line 76, in <module>
from pandas.core.frame import DataFrame
File "/home/MY_LOGIN/.virtualenvs/MY_VIRTUAL_ENV_NAME/lib/python3.9/site-packages/pandas/core/frame.py", line 170, in <module>
from pandas.core.generic import NDFrame
File "/home/MY_LOGIN/.virtualenvs/MY_VIRTUAL_ENV_NAME/lib/python3.9/site-packages/pandas/core/generic.py", line 147, in <module>
from pandas.core.describe import describe_ndframe
File "/home/MY_LOGIN/.virtualenvs/MY_VIRTUAL_ENV_NAME/lib/python3.9/site-packages/pandas/core/describe.py", line 45, in <module>
from pandas.io.formats.format import format_percentiles
File "/home/MY_LOGIN/.virtualenvs/MY_VIRTUAL_ENV_NAME/lib/python3.9/site-packages/pandas/io/formats/format.py", line 105, in <module>
from pandas.io.common import (
File "/home/MY_LOGIN/.virtualenvs/MY_VIRTUAL_ENV_NAME/lib/python3.9/site-packages/pandas/io/common.py", line 8, in <module>
import bz2
File "/home/MY_LOGIN/.local/lib/python3.9/bz2.py", line 18, in <module>
from _bz2 import BZ2Compressor, BZ2Decompressor
ImportError: libbz2.so.1.0: cannot open shared object file: No such file or directory
I am importing pytest in a file and I am getting an AttributeError.
The error is:
AttributeError: 'WindowsPath' object has no attribute 'read_text'
>>> import pytest
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "--\AppData\Local\Programs\Python\Python36\Lib\site-packages\pytest.py", line 6, in <module>
from _pytest.assertion import register_assert_rewrite
File "--\AppData\Local\Programs\Python\Python36\Lib\site-packages\_pytest\assertion\__init__.py", line 7, in <module>
from _pytest.assertion import rewrite
File "--\AppData\Local\Programs\Python\Python36\Lib\site-packages\_pytest\assertion\rewrite.py", line 26, in <module>
from _pytest.assertion import util
File "--\AppData\Local\Programs\Python\Python36\Lib\site-packages\_pytest\assertion\util.py", line 8, in <module>
import _pytest._code
File "--\AppData\Local\Programs\Python\Python36\Lib\site-packages\_pytest\_code\__init__.py", line 2, in <module>
from .code import Code # noqa
File "--\AppData\Local\Programs\Python\Python36\Lib\site-packages\_pytest\_code\code.py", line 24, in <module>
import pluggy
File "--\AppData\Local\Programs\Python\Python36\Lib\site-packages\pluggy\__init__.py", line 16, in <module>
from .manager import PluginManager, PluginValidationError
File "--\AppData\Local\Programs\Python\Python36\Lib\site-packages\pluggy\manager.py", line 11, in <module>
import importlib_metadata
File "--\AppData\Local\Programs\Python\Python36\Lib\site-packages\importlib_metadata\__init__.py", line 547, in <module>
__version__ = version(__name__)
File "--\AppData\Local\Programs\Python\Python36\Lib\site-packages\importlib_metadata\__init__.py", line 509, in version
return distribution(distribution_name).version
File "--\AppData\Local\Programs\Python\Python36\Lib\site-packages\importlib_metadata\__init__.py", line 260, in version
return self.metadata['Version']
File "--\AppData\Local\Programs\Python\Python36\Lib\site-packages\importlib_metadata\__init__.py", line 248, in metadata
self.read_text('METADATA')
File "--\AppData\Local\Programs\Python\Python36\Lib\site-packages\importlib_metadata\__init__.py", line 469, in read_text
return self._path.joinpath(filename).read_text(encoding='utf-8')
AttributeError: 'WindowsPath' object has no attribute 'read_text'
Is there a way how I can use pytest on my machine?
I have a windows machine.
Python version - 3.6.0
Pytest version - 5.2.4
Thanks
The issue I run into in Python2 was that pathlib is a module that was written for Python3 and althought there is a porting for Python 2.7, the porting (1.0.1) is missing the read_text() method.
In your log read_text() is being called from a string, that is the result of the joinpath(), and read_text() is not a method or attribute of a string. That was the whole purpose of pathlib
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 just installed the discord.py rewrite branch, but attempting to use import discord or from discord.ext import commands simply results in a TypeError.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/site-packages/discord/__init__.py", line 20, in <module>
from .client import Client, AppInfo
File "/usr/local/lib/python3.6/site-packages/discord/client.py", line 30, in <module>
from .guild import Guild
File "/usr/local/lib/python3.6/site-packages/discord/guild.py", line 39, in <module>
from .channel import *
File "/usr/local/lib/python3.6/site-packages/discord/channel.py", line 31, in <module>
from .webhook import Webhook
File "/usr/local/lib/python3.6/site-packages/discord/webhook.py", line 27, in <module>
import aiohttp
File "/usr/local/lib/python3.6/site-packages/aiohttp/__init__.py", line 6, in <module>
from .client import * # noqa
File "/usr/local/lib/python3.6/site-packages/aiohttp/client.py", line 15, in <module>
from . import connector as connector_mod
File "/usr/local/lib/python3.6/site-packages/aiohttp/connector.py", line 17, in <module>
from .client_proto import ResponseHandler
File "/usr/local/lib/python3.6/site-packages/aiohttp/client_proto.py", line 6, in <module>
from .http import HttpResponseParser, StreamWriter
File "/usr/local/lib/python3.6/site-packages/aiohttp/http.py", line 8, in <module>
from .http_parser import (HttpParser, HttpRequestParser, HttpResponseParser,
File "/usr/local/lib/python3.6/site-packages/aiohttp/http_parser.py", line 15, in <module>
from .http_writer import HttpVersion, HttpVersion10
File "/usr/local/lib/python3.6/site-packages/aiohttp/http_writer.py", line 304, in <module>
class URL(yarl.URL):
File "/usr/local/lib/python3.6/site-packages/yarl/__init__.py", line 232, in __init_subclass__
"is forbidden".format(cls))
TypeError: Inheritance a class <class 'aiohttp.http_writer.URL'> from URL is forbidden
Although the error is technically from yarl rather than from discord.py itself, the error only occurs upon trying to import the modules.
I've already tried reinstalling python as well as the discord.py rewrite branch, and if it makes any difference am running on a RPi 3 B+
Your aiohttp package might be out of date.
Try
pip install --upgrade aiohttp
I tried to install discord.py on my python 3.7 and it didn't work.
I had to install python 3.6.6 to make it work, maybe you are using python 3.7, if so you should try rolling back to python 3.6.6
I am trying to install robot framework on my windows 10 machine but I am getting below error.
C:\WINDOWS\system32>pip install robotframework
Traceback (most recent call last):
File "C:\Python27\Scripts\pip-script.py", line 5, in <module>
from pkg_resources import load_entry_point
File "build\bdist.win32\egg\pkg_resources\__init__.py", line 36, in <module>
File "C:\Python27\lib\email\parser.py", line 12, in <module>
from email.feedparser import FeedParser
File "C:\Python27\lib\email\feedparser.py", line 27, in <module>
from email import message
File "C:\Python27\lib\email\message.py", line 16, in <module>
import email.charset
File "C:\Python27\lib\email\charset.py", line 13, in <module>
import email.base64mimeenter code here
File "C:\Python27\lib\email\base64mime.py", line 40, in <module>
from email.utils import fix_eols
File "C:\Python27\lib\email\utils.py", line 32, in <module>
from email._parseaddr import quote
File "C:\Python27\lib\email\_parseaddr.py", line 16, in <module>
import time, calendar
File "C:\Python27\Scripts\calendar.py", line 9, in <module>
cal=calendar.month(str(year),str(month))
TypeError: 'int' object is not callable
I have installed python 2.7.14 before starting robot framework installation.
Kindly suggest a way forward.