importlib.metadata.PackageNotFoundError: No package metadata was found for pyproj
Asked Answered
R

2

7

I wrote a code using the pyproj library and converted this code to an exe file for use on another computer. I added the pyproj to the requirements.txt file. And I installed the library with the requirements.txt file on the other computer I will use. When I run the exe file, I get the following error:

importlib.metadata.PackageNotFoundError: No package metadata was found for pyproj

I'd be glad if you can help.

Rebhun answered 21/9, 2022 at 8:48 Comment(2)
Is there a way to tell which python executable installed the code and which one is running the code in the executable?Allover
I solved the problem when I created the exe file with the command "pyinstaller --onefile --copy-metadata pyproj example.py". Thank you.Rebhun
R
5

Here is my solution for those who have problems like above while running the exe file:

 pyinstaller --onefile --copy-metadata pyproj "example.py"

For now this seems to have fixed the problem.

Rebhun answered 23/9, 2022 at 8:30 Comment(1)
should be automatic nowAdar
L
2

This was caused by a change on pyproj when they updated to version 3.4.0

https://github.com/pyproj4/pyproj/issues/1155

It now requires that the dist-info of the pyproj to be present, so it can find the "version" property inside the METADATA file, so if you have an slim installation (an installation without the dist-info folder) the project will break during the first run of its pyproj/__init__.py.

Another way to fix this problem would be to manually remove that line of the code, (line 70 in the __init__.py) or to hardcode the version of the project there.

Another solution could be to install and leave the metadata with the project, another approach would be to delete everything in the dist-info folder except the METADATA file.

You could however roll back to version 3.3.1 which is prior to that breaking change.

edit: I made a change to pyproj a few days after this message, so this is fixed and no longer happens

Logicize answered 3/10, 2022 at 20:50 Comment(1)
Totally different python package (sagemaker) but this was the answer. Thanks a bunch.Triliteral

© 2022 - 2024 — McMap. All rights reserved.