Giter Club home page Giter Club logo

Comments (5)

ddxwltan avatar ddxwltan commented on August 16, 2024

采用一个变通方法,首先将cpca模块安装的目录下将/cpca/resources目录下面的pca.csv剪切到/cpca目录下,然后删除resources目录,然后修改/cpca下面的__init__.py 文件的第27行:
with resource_stream('cpca.resources', 'pca.csv') as pca_stream:
修改为:
with resource_stream('cpca', 'pca.csv') as pca_stream:
保存退出
然后打包的时候 用此命令:
pyinstaller.exe -D xxxx.py
完事之后,进入打包的文件夹,手动建立一个cpca文件夹,然后把前面的pca.csv文件拷贝到这个目录,齐活。打包后程序可以正常运行

PS.打包不要用 -F 参数,这样程序会解压到临时目录运行,因为pca.csv文件并不会被解压到临时目录,而系统又不允许程序自动拷贝文件进去,所以只能迂回用-D参数

from chinese_province_city_area_mapper.

chengzi0103 avatar chengzi0103 commented on August 16, 2024

好的 谢谢 大佬

from chinese_province_city_area_mapper.

smart-aiops avatar smart-aiops commented on August 16, 2024

@hanbinpro @DQinYuan
你好,我在自己的项目中引用了cpca, 用如上方法修改了cpca。 我想把自己的项目打包成一个exe包含所有依赖,但是 -D 不会包含依赖在exe中,请问应该怎么做呢。

from chinese_province_city_area_mapper.

ddxwltan avatar ddxwltan commented on August 16, 2024

from chinese_province_city_area_mapper.

LoyalBenny avatar LoyalBenny commented on August 16, 2024

我也遇到相同的问题,对于我的项目可行的解决方法是:
使用pyinstaller的-add-data参数,linux环境下命令是
pyinstaller --add-data="path/to/cpca/resources:cpca/resources" -D xx.py
path/to/cpca/即你安装cpca包的具体路径。
原理应该和 ddxwltan说的一样,只是应该不用修改cpca的__init__.py.

from chinese_province_city_area_mapper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.