AttributeError: module 'typing_extensions' has no attribute 'Protocol' - python

I am trying to run the following code: https://github.com/silviazuffi/smalst. However, I am using Python 3 instead of Python 2 because it does not seem to be possible to use Python 2 anymore with new CUDA drivers and due to the compatibility issues of some libraries used by that repo.
However, I am getting this error:
AttributeError: module 'typing_extensions' has no attribute 'Protocol'
Full traceback:
Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.8/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/home/iegorval/Diploma/smalst/smal_eval.py", line 21, in <module>
from .nnutils import smal_predictor as pred_util
File "/home/iegorval/Diploma/smalst/nnutils/smal_predictor.py", line 22, in <module>
from ..nnutils.nmr import NeuralRenderer
File "/home/iegorval/Diploma/smalst/nnutils/nmr.py", line 9, in <module>
import chainer
File "/home/iegorval/Diploma/smalst/venv_smallst/lib/python3.8/site-packages/chainer/__init__.py", line 10, in <module>
from chainer import backends # NOQA
File "/home/iegorval/Diploma/smalst/venv_smallst/lib/python3.8/site-packages/chainer/backends/__init__.py", line 1, in <module>
from chainer.backends import cuda # NOQA
File "/home/iegorval/Diploma/smalst/venv_smallst/lib/python3.8/site-packages/chainer/backends/cuda.py", line 46, in <module>
from chainer.backends import intel64
File "/home/iegorval/Diploma/smalst/venv_smallst/lib/python3.8/site-packages/chainer/backends/intel64.py", line 8, in <module>
from chainer.configuration import config
File "/home/iegorval/Diploma/smalst/venv_smallst/lib/python3.8/site-packages/chainer/configuration.py", line 5, in <module>
from chainer import types # NOQA
File "/home/iegorval/Diploma/smalst/venv_smallst/lib/python3.8/site-packages/chainer/types.py", line 47, in <module>
class AbstractInitializer(tpe.Protocol):
AttributeError: module 'typing_extensions' has no attribute 'Protocol'
So, it fails to detect Protocol in the typing_extensions module. However, I have installed typing-extensions==3.7.4.3 (https://pypi.org/project/typing-extensions/), and PyPi description seem to state that Protocol should be there.
Any idea how to fix this error?

Related

Error while install PySimpleGUI import ModuleNotFoundError: No module named 'Python'

There's an error when i tried to install PySimpleGUI package on PyCharm. i already tried install package from setting, and terminal with command "pip instal PySimpleGUI". Both of them have the same error message.
`Traceback (most recent call last):
File "C:\Users\irsya\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\irsya\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\irsya\PycharmProjects\pythonProject\venv\Scripts\pip.exe\__main__.py", line 4, in <module>
File "C:\Users\irsya\PycharmProjects\pythonProject\venv\lib\site-packages\pip\_internal\cli\main.py", line 9, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "C:\Users\irsya\PycharmProjects\pythonProject\venv\lib\site-packages\pip\_internal\cli\autocompletion.py", line 10, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "C:\Users\irsya\PycharmProjects\pythonProject\venv\lib\site-packages\pip\_internal\cli\main_parser.py", line 8, in <module>
from pip._internal.cli import cmdoptions
File "C:\Users\irsya\PycharmProjects\pythonProject\venv\lib\site-packages\pip\_internal\cli\cmdoptions.py", line 23, in <module>
from pip._internal.cli.parser import ConfigOptionParser
File "C:\Users\irsya\PycharmProjects\pythonProject\venv\lib\site-packages\pip\_internal\cli\parser.py", line 12, in <module>
from pip._internal.configuration import Configuration, ConfigurationError
File "C:\Users\irsya\PycharmProjects\pythonProject\venv\lib\site-packages\pip\_internal\configuration.py", line 20, in <module>
from pip._internal.exceptions import (
File "C:\Users\irsya\PycharmProjects\pythonProject\venv\lib\site-packages\pip\_internal\exceptions.py", line 7, in <module>
from pip._vendor.pkg_resources import Distribution
File "C:\Users\irsya\PycharmProjects\pythonProject\venv\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 22, in <module>
import Python.Bonus.parsers14
ModuleNotFoundError: No module named 'Python'
`
Errro message

I'm trying to run a Python SDK and am getting errors from runpy.py. How to fix it?

(base) kiin#kiin ~ % python3 -m anki_vector.configure
Traceback (most recent call last):
File "/Users/kiin/opt/anaconda3/lib/python3.9/runpy.py", line 188, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/Users/kiin/opt/anaconda3/lib/python3.9/runpy.py", line 111, in _get_module_details
__import__(pkg_name)
File "/Users/kiin/.local/lib/python3.9/site-packages/anki_vector/__init__.py", line 22, in <module>
from . import messaging
File "/Users/kiin/.local/lib/python3.9/site-packages/anki_vector/messaging/__init__.py", line 43, in <module>
from . import client
File "/Users/kiin/.local/lib/python3.9/site-packages/anki_vector/messaging/client.py", line 23, in <module>
from .alexa_pb2_grpc import *
File "/Users/kiin/.local/lib/python3.9/site-packages/anki_vector/messaging/alexa_pb2_grpc.py", line 2, in <module>
import grpc
File "/Users/kiin/.local/lib/python3.9/site-packages/grpc/__init__.py", line 22, in <module>
from grpc import _compression
File "/Users/kiin/.local/lib/python3.9/site-packages/grpc/_compression.py", line 15, in <module>
from grpc._cython import cygrpc
ImportError: dlopen(/Users/kiin/.local/lib/python3.9/site-packages/grpc/_cython/cygrpc.cpython-39-darwin.so, 0x0002): symbol not found in flat namespace (_CFRelease)
I've tried uninstalling and reinstalling the SDK, as well as downgrade to Python 3.8. Same errors for both.

ImportError about Numpy when using Manim

I want to try Manim.
So I installed (using pip) and created a project with the Quickstart tutorial.
RuntimeError, ImportError
But when running it, a bunch of errors show up:
RuntimeError: module compiled against API version 0xf but this version of NumPy is 0xe
Traceback (most recent call last):
File "C:\Users\mitja\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\mitja\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\mitja\AppData\Local\Programs\Python\Python310\Scripts\manim.exe\__main__.py", line 4, in <module>
File "C:\Users\mitja\AppData\Local\Programs\Python\Python310\lib\site-packages\manim\__init__.py", line 24, in <module>
from .animation.animation import *
File "C:\Users\mitja\AppData\Local\Programs\Python\Python310\lib\site-packages\manim\animation\animation.py", line 6, in <module>
from manim.mobject.opengl.opengl_mobject import OpenGLMobject
File "C:\Users\mitja\AppData\Local\Programs\Python\Python310\lib\site-packages\manim\mobject\opengl\opengl_mobject.py", line 17, in <module>
from manim.utils.bezier import integer_interpolate, interpolate
File "C:\Users\mitja\AppData\Local\Programs\Python\Python310\lib\site-packages\manim\utils\bezier.py", line 28, in <module>
from scipy import linalg
File "C:\Users\mitja\AppData\Local\Programs\Python\Python310\lib\site-packages\scipy\__init__.py", line 217, in __getattr__
return _importlib.import_module(f'scipy.{name}')
File "C:\Users\mitja\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "C:\Users\mitja\AppData\Local\Programs\Python\Python310\lib\site-packages\scipy\linalg\__init__.py", line 197, in <module>
from ._misc import *
File "C:\Users\mitja\AppData\Local\Programs\Python\Python310\lib\site-packages\scipy\linalg\_misc.py", line 3, in <module>
from .blas import get_blas_funcs
File "C:\Users\mitja\AppData\Local\Programs\Python\Python310\lib\site-packages\scipy\linalg\blas.py", line 213, in <module>
from scipy.linalg import _fblas
ImportError: numpy.core.multiarray failed to import
I've already tried reinstalling/upgrading the newest version.
How do I solve this and get it running?

ImportError: DLL load failed while importing _ssl: %1 is not a valid Win32 application

E:\WORK\python\Flask>virtualenv enb
Traceback (most recent call last):
File "c:\users\user\appdata\local\programs\python\python38-32\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\users\user\appdata\local\programs\python\python38-32\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\User\AppData\Local\Programs\Python\Python38-32\Scripts\virtualenv.exe\__main__.py", line 4, in <module>
File "c:\users\user\appdata\local\programs\python\python38-32\lib\site-packages\virtualenv\__init__.py", line 3, in <module>
from .run import cli_run, session_via_cli
File "c:\users\user\appdata\local\programs\python\python38-32\lib\site-packages\virtualenv\run\__init__.py", line 9, in <module>
from ..seed.wheels.periodic_update import manual_upgrade
File "c:\users\user\appdata\local\programs\python\python38-32\lib\site-packages\virtualenv\seed\wheels\__init__.py", line 3, in <module>
from .acquire import get_wheel, pip_wheel_env_run
File "c:\users\user\appdata\local\programs\python\python38-32\lib\site-packages\virtualenv\seed\wheels\acquire.py", line 15, in <module>
from .bundle import from_bundle
File "c:\users\user\appdata\local\programs\python\python38-32\lib\site-packages\virtualenv\seed\wheels\bundle.py", line 6, in <module>
from .periodic_update import periodic_update
File "c:\users\user\appdata\local\programs\python\python38-32\lib\site-packages\virtualenv\seed\wheels\periodic_update.py", line 10, in <module>
import ssl
File "c:\users\user\appdata\local\programs\python\python38-32\lib\ssl.py", line 98, in <module>
import _ssl # if we can't import it, let the error propagate
ImportError: DLL load failed while importing _ssl: %1 is not a valid Win32 application.
E:\WORK\python\Flask>
how can I solve this ?

How to fix Attribute Error in just importing pytest

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

Categories