Comments (5)
采用一个变通方法,首先将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.
好的 谢谢 大佬
from chinese_province_city_area_mapper.
@hanbinpro @DQinYuan
你好,我在自己的项目中引用了cpca, 用如上方法修改了cpca。 我想把自己的项目打包成一个exe包含所有依赖,但是 -D 不会包含依赖在exe中,请问应该怎么做呢。
from chinese_province_city_area_mapper.
from chinese_province_city_area_mapper.
我也遇到相同的问题,对于我的项目可行的解决方法是:
使用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)
- 一些归属地识别问题 HOT 1
- 安装失败,2014年的Mac不能正常安装?
- 应新增30个自治州、3个盟等地级行政区划的简称
- 新增地名缩写
- 使用cpca过程中,报错缺少某些库,如下 HOT 1
- 希望新增匹配到相似区的异常抛出
- 不支持python3.6版本
- 有些地址的区/县/镇无法识别,列表如下 HOT 5
- adcodes.csv内有龙华区而无法识别
- 两个省份相连只能识别第一个!
- 如何返回行政区划的经纬度信息?
- transform_text_with_addrs 输入不含省市区的文本会报错
- 无法使用csv文件吗
- 安徽省池州市教育园区池州学院内 地址识别结果是
- import capa的时候能自定义使用自己本地的adcodes.csv么
- 使用echarts进行绘图的时候,会报错 ImportError: cannot import name 'Markup' from 'jinja2' (C:\Python\work\venv\lib\site-packages\jinja2\__init__.py)
- 能否新增参数,当只根据区信息无法区分时,给出可能的全部解析让用户选择
- 乡镇级别是否可实现?难度如何? HOT 1
- 深圳的区域龙华坪山无法区分 HOT 1
- 安徽省马鞍山市当涂县无法解析 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chinese_province_city_area_mapper.