Files
kman/makepkg.md
2020-07-05 20:49:42 +08:00

73 lines
3.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 打包问题
### 'ValueError: too many values to unpack (expected 2)
A: [资源文件打包配置](https://blog.csdn.net/weixin_42052836/article/details/82315118) <br>
资源文件包括打包的python项目使用的相关文件如图标文件文本文件等。<br>
对于此类资源文件的打包需要设置Analysis的datas如例子所示datas接收元组<br>
datas=[(SETUP_DIR+'lib\\icon','lib\\icon'),(SETUP_DIR+'data','data')]。<br>
元组的组成为(原项目中资源文件路径,打包后路径)<br>
例子中的(SETUP_DIR+'lib\\icon','lib\\icon')表示从D:\\install_test\\FASTPLOT\\lib\\icon下的图标文件打包后放入打包结果路径下的lib\\icon目录。<br><br>
### (kmanenv) [gavin@gavin-2 tkman]$open Release/kmanapp.app/<br>
### FAIL - LSOpenURLsWithRole() failed with error -10810 for the file /Users/mark/penv/tkman/Release/kmanapp.app.<br>
(kmanenv) [gavin@gavin-2 tkman]$Release/kmanapp.app/Contents/MacOS/kmanapp<br>
OK
A:
1. 到其他路径区执行(kmanenv) [gavin@gavin-2 penv]$py kman/kmanapp.py看有没有问题
1. 所有路径合并,不用+, 用os.path.join()
```python
frozen = 'not'
#CURRPATH = os.path.dirname(os.path.realpath(sys.argv[0]))
CURRPATH = ''
if getattr(sys, 'frozen', False):
# we are running in a bundle
frozen = 'ever so'
CURRPATH = sys._MEIPASS
os.chdir(CURRPATH)
else:
# we are running in a normal Python environment
CURRPATH = os.path.dirname(os.path.abspath(__file__))
```
### (kmanenv) [gavin@gavin-2 tkman]$pyinstaller --distpath Release -w -c -i kmanapp.ico kmanapp.spec <br>
### 21750 ERROR: Can not find path ./libshiboken2.abi3.5.15.dylib (needed by /Users/mark/.virtualenvs/kmanenv/lib/python3.7/site-packages/PySide2/QtGui.abi3.so)
A: rm -fr __pycache__, 重新打包 <br>
### (kmanenv) [gavin@gavin-2 kman]$Release/kmanapp.app/Contents/MacOS/kmanapp <br>
### NameError: name 'kMan' is not defined <br>
A:
```
pathex=['/Users/mark/penv/kman',]
Analysis(['kmanapp.py'], ==>
Analysis(['kman.py', 'kmanapp.py', 'kmanapp_rc.py', 'mainwindow.py', 'mtable.py', 'parseweb.py', ],
...
```
**这里有个问题打开app是会运行所有('kman.py', 'kmanapp.py', 'kmanapp_rc.py', 'mainwindow.py', 'mtable.py', 'parseweb.py',)py文件里的main所以在打包时要把不是入口py程序的main删除或注释掉**
### 移植到其他机器上运行还是显示: (20200702)<br>
### **LSOpenURLsWithRole() failed with error -10810 for the file /Users/mark/penv/tkman/Release/kmanapp.app.**<br>
A: MAC下: <br>
```
cd /path/to/your/ApplicationName.app
xattr -l Contents/MacOS/*
```
发现有一堆"com.apple.quarantine",说明有问题,运行: <br>
**xattr -dr com.apple.quarantine '/我的安装路径/kmanapp.app'** <br>
可以正常打开,原因不清,[参考链接](https://apple.stackexchange.com/questions/181026/lsopenurlswithrole-failed-with-error-10810-cant-open-install-os-x-yosemite) <br>
Windows下<br>
# reference
1. [ModuleNotFoundError: No module named 'pkg_resources.py2_warn' ](https://blog.csdn.net/qq_40608730/article/details/104864943)
1. [ref2](https://www.cnblogs.com/yemeng/p/6253097.html)
1. [ref3](https://blog.csdn.net/SCDS_Zyx/article/details/82052396)
1. [ref4](https://apple.stackexchange.com/questions/181026/lsopenurlswithrole-failed-with-error-10810-cant-open-install-os-x-yosemite) <br>