简体   繁体   中英

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

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.

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM