想打包个.py 去其它电脑运行,在编译目录 warn-testrun.txt 里缺的也太多了吧? - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
qazwsxkevin
V2EX    Python

想打包个.py 去其它电脑运行,在编译目录 warn-testrun.txt 里缺的也太多了吧?

  •  
  •   qazwsxkevin 2019-10-14 14:45:10 +08:00 5118 次点击
    这是一个创建于 2205 天前的主题,其中的信息可能已经有所发展或是发生改变。

    missing module named 'xxx'的内容也太多了,起码>150 行
    贴个前 10 的内容:

    missing module named 'multiprocessing.forking' - imported by c:\users\administrator\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\loader\rthooks\pyi_rth_multiprocessing.py (optional) missing module named multiprocessing.get_context - imported by multiprocessing (top-level), multiprocessing.pool (top-level), multiprocessing.managers (top-level), multiprocessing.sharedctypes (top-level) missing module named multiprocessing.TimeoutError - imported by multiprocessing (top-level), multiprocessing.pool (top-level) missing module named multiprocessing.BufferTooShort - imported by multiprocessing (top-level), multiprocessing.connection (top-level) missing module named multiprocessing.AuthenticationError - imported by multiprocessing (top-level), multiprocessing.connection (top-level) missing module named multiprocessing.set_start_method - imported by multiprocessing (top-level), multiprocessing.spawn (top-level) missing module named multiprocessing.get_start_method - imported by multiprocessing (top-level), multiprocessing.spawn (top-level) missing module named multiprocessing.SimpleQueue - imported by multiprocessing (top-level), concurrent.futures.process (top-level) missing module named 'win32com.gen_py' - imported by win32com (conditional, optional), c:\users\administrator\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\loader\rthooks\pyi_rth_win32comgenpy.py (top-level) missing module named pyimod03_importers - imported by PyInstaller.loader.pyimod02_archive (delayed, conditional), c:\users\administrator\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\loader\rthooks\pyi_rth_pkgres.py (top-level) missing module named 'com.sun' - imported by pkg_resources._vendor.appdirs (delayed, conditional, optional) missing module named com - imported by pkg_resources._vendor.appdirs (delayed) 

    脚本状态下,程序运行没有问题
    就拿第一个“'multiprocessing”来说,我手动 pip install multiprocessing 都报错了。。。

     ERROR: Command errored out with exit status 1: command: 'c:\users\administrator\appdata\local\programs\python\python36\python.exe' -c 'import sys, setuptools, to kenize; sys.argv[0] = '"'"'C:\\Temp\\pip-install-bi2klhf4\\multiprocessing\\setup.py'"'"'; __file__='"'"'C:\\Temp\\pip- install-bi2klhf4\\multiprocessing\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().repl ace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg- info cwd: C:\Temp\pip-install-bi2klhf4\multiprocessing\ Complete output (6 lines): Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\Temp\pip-install-bi2klhf4\multiprocessing\setup.py", line 94 print 'Macros:' ^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print('Macros:')? ---------------------------------------- ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. 

    很像是 python 版本的问题。。。 但又不能降 python 版本这么折腾。。。

    要编译成功,有何办法???

    12 条回复    2019-10-15 10:35:33 +08:00
    littlespider89
        1
    littlespider89  
       2019-10-14 14:50:25 +08:00
    你运行的这个程序用到的 multiprocessing 是 python2.7 的,只能用 python2.7,你在 3.6 里用不了
    multiprocessing 3.6 都内置了,pip 安装以前的当然装不上
    qazwsxkevin
        2
    qazwsxkevin  
    OP
       2019-10-14 15:00:00 +08:00
    @littlespider89 看来没办法了,有几个用到的库,只能在 3.6 以上使用。。。。
    skt041959
        3
    skt041959  
       2019-10-14 17:07:07 +08:00
    我来歪个楼,楼主的用户名“administrator”,怕不是暴露了你还在用 XP ?
    Jirajine
        4
    Jirajine  
       2019-10-14 17:23:18 +08:00 via Android
    @skt041959 新版 Windows 也一直沿用 administrator 这个用户名啊。。
    用这种默认用户名,可以降低终端 prompt,文档作者,配置文件,日志,路径,编译调试信息等各方面暴露个人信息的可能。
    ysc3839
        5
    ysc3839  
       2019-10-14 17:25:40 +08:00
    @Jirajine 没记错的话从 Windows 7 开始就会让用户自己创建一个系统账号了,不会直接使用 Administrator。
    另外不想暴露个人信息的话你还可以把用户名设成 123 abc 之类的。
    ysc3839
        6
    ysc3839  
       2019-10-14 17:26:41 +08:00
    @skt041959 Python 3.5 是最后支持 XP 的版本。
    dantelovepizza
        7
    dantelovepizza  
       2019-10-14 17:28:44 +08:00
    你需要 pyinstaller
    Jirajine
        8
    Jirajine  
       2019-10-14 17:31:24 +08:00 via Android
    @ysc3839 印象中用 7 的时候还是用的 administrator,可能不是官方安装系统,后来到 10 是引导建一个普通用户,但也可以手动启用 administrator 并登录啊。。
    qazwsxkevin
        9
    qazwsxkevin  
    OP
       2019-10-14 21:29:12 +08:00
    @skt041959 Win7,我做系统的时候特意用回 Administrator
    @dantelovepizza 这不就是用了 pyinstaller 来编译的么?
    wangyzj
        10
    wangyzj  
       2019-10-14 22:34:26 +08:00
    你需要 pyinstaller +1
    renmu
        11
    renmu  
       2019-10-15 08:46:25 +08:00 via Android
    你需要新建一个干净的虚拟环境,pyinstaller 好像会把所有的包都打包进去
    flynaj
        12
    flynaj  
       2019-10-15 10:35:33 +08:00 via Android
    要彻底解决,只有换 golang
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     5535 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 25ms UTC 09:07 PVG 17:07 LAX 02:07 JFK 05:07
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86