This is an easy one - your code is trying to:

  1.  Use typing.Protocol which was introduced in Python 3.8 
https://docs.python.org/3/library/typing.html#typing.Protocol
  2.  Build and executable using PyInstaller using Python 3.7 from the error 
message paths below.

To resolve this I would suggest:

  1.  create a venv or equivalent that specifically uses python 3.8 or greater,
  2.  activate it and
  3.  install your dependencies including PyInstaller
  4.  Build your executable
Then going forwards make sure that you use steps 2 & 4 every time that you 
build your code.

Hope that helps

Steve Barnes

From: [email protected] <[email protected]> On Behalf Of 
Claes Sterregaard
Sent: 13 February 2022 18:30
To: PyInstaller <[email protected]>
Subject: [PyInstaller] pyinstaller command giving "ImportError: cannot import 
name 'Protocol' from 'typing' eror"

Hi All
I am trying to use pyinstaller to make an .exe of my dash app.
I first did pip install pyinstaller which went well.
But when I run the pyinstaller command I get the error below.
I then tried to make a basic project (app.basic.py) holding only a simple 
print('hallo') line to see if it was related to my dash app somehow but the 
error was raised again.
What is causing this and how can I solve it :-)?

C:\users\claus\desktop\test>pyinstaller app_basic.py
Traceback (most recent call last):
  File 
"c:\users\claus\anaconda3\pkgs\python-3.7.0-hea74fb7_0\lib\site-packages\importlib_metadata\_compat.py",
 line 9, in <module>
    from typing import Protocol
ImportError: cannot import name 'Protocol' from 'typing' 
(c:\users\claus\anaconda3\pkgs\python-3.7.0-hea74fb7_0\lib\typing.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\claus\anaconda3\pkgs\python-3.7.0-hea74fb7_0\lib\runpy.py", 
line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\claus\anaconda3\pkgs\python-3.7.0-hea74fb7_0\lib\runpy.py", 
line 85, in _run_code
    exec(code, run_globals)
  File 
"C:\Users\Claus\Anaconda3\pkgs\python-3.7.0-hea74fb7_0\Scripts\pyinstaller.exe\__main__.py",
 line 9, in <module>
  File 
"c:\users\claus\anaconda3\pkgs\python-3.7.0-hea74fb7_0\lib\site-packages\PyInstaller\__main__.py",
 line 103, in run
    compat.check_requirements()
  File 
"c:\users\claus\anaconda3\pkgs\python-3.7.0-hea74fb7_0\lib\site-packages\PyInstaller\compat.py",
 line 736, in check_requirements
    from importlib_metadata import distribution, PackageNotFoundError
  File 
"c:\users\claus\anaconda3\pkgs\python-3.7.0-hea74fb7_0\lib\site-packages\importlib_metadata\__init__.py",
 line 17, in <module>
    from . import _adapters, _meta
  File 
"c:\users\claus\anaconda3\pkgs\python-3.7.0-hea74fb7_0\lib\site-packages\importlib_metadata\_meta.py",
 line 1, in <module>
    from ._compat import Protocol
  File 
"c:\users\claus\anaconda3\pkgs\python-3.7.0-hea74fb7_0\lib\site-packages\importlib_metadata\_compat.py",
 line 11, in <module>
    from typing_extensions import Protocol  # type: ignore
  File 
"c:\users\claus\anaconda3\pkgs\python-3.7.0-hea74fb7_0\lib\site-packages\typing_extensions.py",
 line 494, in <module>
    OrderedDict = typing._alias(collections.OrderedDict, (KT, VT))
  File "c:\users\claus\anaconda3\pkgs\python-3.7.0-hea74fb7_0\lib\typing.py", 
line 1191, in _alias
    return _GenericAlias(origin, params, special=True, inst=inst)
  File "c:\users\claus\anaconda3\pkgs\python-3.7.0-hea74fb7_0\lib\typing.py", 
line 613, in __init__
    self.__parameters__ = _collect_type_vars(params)
  File 
"c:\users\claus\anaconda3\pkgs\python-3.7.0-hea74fb7_0\lib\site-packages\typing_extensions.py",
 line 143, in _collect_type_vars
    not isinstance(t, _UnpackAlias)
NameError: name '_UnpackAlias' is not defined
--
You received this message because you are subscribed to the Google Groups 
"PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
[email protected]<mailto:[email protected]>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyinstaller/47695ca5-37ac-4eb7-b93e-2ff89f6170d2n%40googlegroups.com<https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fpyinstaller%2F47695ca5-37ac-4eb7-b93e-2ff89f6170d2n%2540googlegroups.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=04%7C01%7C%7C77502469b69f41a8416908d9ef9c8d8f%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637804277937350168%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=oSMOuWGvL0rvHVOjBa0oAOm2MRczveV%2BI%2Bboijb0Fr8%3D&reserved=0>.

-- 
You received this message because you are subscribed to the Google Groups 
"PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyinstaller/VI1PR03MB657526F5BD270019C42003649B349%40VI1PR03MB6575.eurprd03.prod.outlook.com.

Reply via email to