[英]getting Fatal error in launcher: Unable to create process using '"c:\python37\python.exe" "C:\Python37\Scripts\pyrcc5.exe"
[英]How to create a .exe similar to pip.exe, jupyter.exe, etc. from C:\Python37\Scripts?
In order to make pip
or jupyter
available from command-line on Windows no matter the current working directory with just pip...
or jupyter...
, Python on Windows seems to use this method:
C:\Python37\Scripts
放入 PATHC:\Python37\Scripts\pip.exe
或jupyter.exe
,这可能只是用解释器调用 Python 脚本(我猜?) 然后在命令行中执行pip...
或jupyter...
工作,无论当前目录如何。
问题:如何创建一个类似的 100KB mycommand.exe
,我可以将它放在 PATH 中的目录中,以便我可以从命令行中的任何位置执行mycommand
?
注意:我不是在谈论 pyinstaller、cxfreeze 等(我已经知道并且以前使用过); 我不认为这些C:\Python37\Scripts\
exe 文件使用这个。
假设您使用setuptools来 package 这个应用程序,您需要创建一个console_scripts
入口点,如此处所述:
对于单个顶级模块,它可能如下所示:
setup.py
#!/usr/bin/env python3
import setuptools
setuptools.setup(
py_modules=['my_top_level_module'],
entry_points={
'console_scripts': [
'mycommand = my_top_level_module:my_main_function',
],
},
# ...
name='MyProject',
version='1.0.0',
)
my_top_level_module.py
#!/usr/bin/env python3
def my_main_function():
print("Hi!")
if __name__ == '__main__':
my_main_function()
然后使用以下命令安装它:
path/to/pythonX.Y -m pip install path/to/MyProject
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.