配置 Pycharm 以运行 Pyinstaller [英] Configuring Pycharm to run Pyinstaller

查看:59
本文介绍了配置 Pycharm 以运行 Pyinstaller的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是的,我想在 PyCharm 中创建一个运行配置来运行 Pyinstaller 并获取我的可执行文件.根据

运行后,给我这个错误:

/usr/local/Cellar/python3/3.4.3/bin/python3.4/usr/local/lib/python3.4/site-packages/PyInstaller/__main__.py --onefile --nowindow --osx-bundle-identifier=jg.optimizer -F --name=genoptimizer optimizer/manage.py回溯(最近一次调用最后一次):文件/usr/local/lib/python3.4/site-packages/PyInstaller/__main__.py",第26行,在<module>从 .导入 __version__SystemError: 父模块 '' 未加载,无法执行相对导入进程以退出代码 1 结束

它似乎需要一个父模块才能运行,但是,那会是什么样子?

解决方案

PyInstaller 包是一个可运行的模块,可以使用 python -m PyInstaller 运行.要将其配置为 PyCharm 中的运行目标,请将脚本"字段留空,在解释器选项"字段中写入 -m PyInstaller,并将 PyInstaller 参数放入脚本参数"字段.

例如:

PyCharm 会抱怨脚本"字段为空,但无论如何它都会让您运行配置.

Yes I want to create a run configuration in PyCharm to run Pyinstaller and get my executable. According to the Pyinstaller documentation you should be able to locate an python script called pyinstaller-folder/pyinstaller.py after the installation, but it wasn't there. Then I look carefully and found this other one named pyinstaller-folder/__main__.py which should be the same <--(me wild guessing), so I set up my running configuration like this:

After running it, is giving me this error:

/usr/local/Cellar/python3/3.4.3/bin/python3.4 /usr/local/lib/python3.4/sit

e-packages/PyInstaller/__main__.py --onefile --nowindow --osx-bundle-identifier=jg.optimizer -F --name=genoptimizer optimizer/manage.py
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/site-packages/PyInstaller/__main__.py", line 26, in <module>
    from . import __version__
SystemError: Parent module '' not loaded, cannot perform relative import

Process finished with exit code 1

It seems to require a parent module to run but, how would that look like?

解决方案

The PyInstaller package is a runnable module and can be run using python -m PyInstaller. To configure it as a run target in PyCharm, leave the "Script" field blank, write -m PyInstaller in the "Interpreter Options" field, and put the PyInstaller parameters into the "Script Parameters" field.

For example:

PyCharm will complain that the "Script" field is empty, but it will let you run the configuration anyway.

这篇关于配置 Pycharm 以运行 Pyinstaller的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆