Hi Claes, It looks from your error messages as if the Anaconda installation of Python 3.7 has had the importlib-metadata library installed which is introducing this error. I would suggest, if you can, upgrading to at least Python 3.9 (3.10 is the current python) and using that as Python 3.7 ends security support in 1 year & 4 months. If you have to support Windows 7 then you would have to go for Python 3.8.
If you can't then you will need to either uninstall or downgrade importlib-metadata - if it was pip installed then pip uninstall importlib-metadata should do the job but as I rarely use Anaconda I am not sure how to do it with conda. Of course if you need to use importlib-metadata, (e.g. for keyring or twine) then you may be stuck with needing to upgrade your python. Hope that is some help! Steve From: [email protected] <[email protected]> On Behalf Of Claes Sterregaard Sent: 15 February 2022 07:48 To: [email protected] Subject: Re: [PyInstaller] pyinstaller command giving "ImportError: cannot import name 'Protocol' from 'typing' eror" Dear Steve. Thank you for your kind reply. I still wonder though - my app_basic.py does not include anything, it is just a print statement. I can run the app_basic.py (as well as the actual program I eventually want to make an .exe for) without issues in my 3.7 environment. Why is "typing.Protocol" suddenly in play when I run the pyinstaller command then? All the best Claes Den tir. 15. feb. 2022 kl. 07.05 skrev Steve Barnes <[email protected]<mailto:[email protected]>>: 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<https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdocs.python.org%2F3%2Flibrary%2Ftyping.html%23typing.Protocol&data=04%7C01%7C%7C9894ac11877740beabc608d9f0595e81%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637805089043463516%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=wBsEJ2cMxA1SApWIhF81rjUr8O5ud8mx0nYfwctFxd0%3D&reserved=0> 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]<mailto:[email protected]> <[email protected]<mailto:[email protected]>> On Behalf Of Claes Sterregaard Sent: 13 February 2022 18:30 To: PyInstaller <[email protected]<mailto:[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<https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapp.basic.py%2F&data=04%7C01%7C%7C9894ac11877740beabc608d9f0595e81%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637805089043463516%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=Nrl0WllHP0kmXWHyJSdOL88noJ4vUxpXWkX4FTeJEdA%3D&reserved=0>) 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%7C9894ac11877740beabc608d9f0595e81%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637805089043463516%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=gy0nDCyhafxVDvR%2FodF%2FOWi8htIu4S4Lrd8lmaXdNMg%3D&reserved=0>. -- You received this message because you are subscribed to a topic in the Google Groups "PyInstaller" group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/pyinstaller/K6liK5_GqV4/unsubscribe<https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Ftopic%2Fpyinstaller%2FK6liK5_GqV4%2Funsubscribe&data=04%7C01%7C%7C9894ac11877740beabc608d9f0595e81%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637805089043463516%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=7p0B3z58Ws85Tl%2FR7%2B1XKSR6K7CrFQuK%2BreBJOqi09Y%3D&reserved=0>. To unsubscribe from this group and all its topics, send an email to [email protected]<mailto:[email protected]>. To view this discussion on the web visit https://groups.google.com/d/msgid/pyinstaller/VI1PR03MB657526F5BD270019C42003649B349%40VI1PR03MB6575.eurprd03.prod.outlook.com<https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fpyinstaller%2FVI1PR03MB657526F5BD270019C42003649B349%2540VI1PR03MB6575.eurprd03.prod.outlook.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=04%7C01%7C%7C9894ac11877740beabc608d9f0595e81%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637805089043463516%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=H020osgIFqb9%2BoxrHwUTkmrBa1HJ5pGG9k73P7PFOCs%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]<mailto:[email protected]>. To view this discussion on the web visit https://groups.google.com/d/msgid/pyinstaller/CADWhU%2BfHvn5rbET_UO8%2BfXy1h%2BgfvRd1CHFT8NzR7Hvax96rhw%40mail.gmail.com<https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fpyinstaller%2FCADWhU%252BfHvn5rbET_UO8%252BfXy1h%252BgfvRd1CHFT8NzR7Hvax96rhw%2540mail.gmail.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=04%7C01%7C%7C9894ac11877740beabc608d9f0595e81%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637805089043463516%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=M1FqZolsivwqbLpkx5682Gpss40o3Y8CfizXolWXETA%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/VI1PR03MB6575A6414D2F61ED4F99E1EE9B349%40VI1PR03MB6575.eurprd03.prod.outlook.com.
