开发者

Distributing an executable zip file with __main__.py, how to access extra data? [duplicate]

开发者 https://www.devze.com 2022-12-31 11:08 出处:网络
This question already has answers here: python: can executable zip files include data files? 开发者_开发技巧(4 answers)
This question already has answers here: python: can executable zip files include data files? 开发者_开发技巧 (4 answers) Closed 7 years ago.

I'm doing a little program and I want to distribute it using this recipe:

  1. single directory with __main__.py in it
  2. zip this directory and adding a shebang on it #!/usr/bin/env python
  3. making it executable

The problem is that in this package I have also extra files (I'm using pygtk toolkit and I need images and ui xml files). When I try to access these files I have the error that the resource is unavailable (the path that I'm trying to open is something like file.zip/gui/gui.ui ).

How can I handle this situation?


I figured out by myself, It's sufficient to use pkgutil.get_data to access the data inside a package.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号