Pyinstaller 编译后的python文件, 运行错误:ImportError: No module named 'gevent.__hub_local'

系统: Ubuntu 14.04.5 LTS
pyinstaller: 3.3.1
gevent: 1.3.5

将python脚本通过pyinstaller编译成可执行文件后,运行报错:

Traceback (most recent call last):
  File "cloud_unique.py", line 5, in <module>
    import gevent
  File "/home/cft/.pyenv/versions/3.5.1/envs/env_3.5.1/lib/python3.5/site-packages/PyInstaller/loader/pyimod03_importers.py", line 631, in exec_module
    exec(bytecode, module.__dict__)
  File "gevent/__init__.py", line 87, in <module>
  File "/home/cft/.pyenv/versions/3.5.1/envs/env_3.5.1/lib/python3.5/site-packages/PyInstaller/loader/pyimod03_importers.py", line 631, in exec_module
    exec(bytecode, module.__dict__)
  File "gevent/_hub_local.py", line 101, in <module>
  File "gevent/_util.py", line 105, in import_c_accel
  File "importlib/__init__.py", line 126, in import_module
ImportError: No module named 'gevent.__hub_local'
[6366] Failed to execute script cloud_unique

解决办法:

pyinstaller 编译时加入 - -hidden-import参数,导入所有找不到的模块

可以写到脚本里:

#!/bin/sh

pyinstaller \
-F cloud_unique.py \
--hidden-import  gevent.__hub_local \
--hidden-import gevent.__greenlet_primitives \
--hidden-import gevent.__waiter \
--hidden-import gevent.__hub_primitives \
--hidden-import  gevent._greenlet \
--hidden-import  gevent.__ident \
--hidden-import  gevent.time \
--hidden-import  gevent.__semaphore \
--hidden-import  gevent._local \
--hidden-import  gevent._event \
--hidden-import gevent._queue \
--hidden-import  gevent.__imap \
--hidden-import gevent.libuv \
--hidden-import gevent.libuv.loop \
--hidden-import gevent.libev \
--hidden-import gevent.libev.corecffi  \
--clean 
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值