我正在尝试使用cx_Freeze作为将.py转换为.exe (auto-py-to-exe)的常用应用程序的替代方案。当我在cmd中运行它时,我得到:
C:\WINDOWS\system32>cxfreeze-quickstart
Project name: FE
Version [1.0]: 1.0
Description: File Edit and more!!!
Python file to make executable from: File Create.py
Executable file name [File Create]: FileCreateExe
(C)onsole application, (G)UI application, or (S)ervice [C]: C
Save setup script to [setup.py]: C:\Users\tom\Documents\python\_Thiswill createfiles_
Overwrite C:\Users\tom\Documents\python\_Thiswillcreatefiles_ [n]? yes
Traceback (most recent call last):
File "c:\users\tom\appdata\local\programs\python\python38-32\lib\runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\users\tom\appdata\local\programs\python\python38-32\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\tom\AppData\Local\Programs\Python\Python38-32\scripts\cxfreeze-quickstart.exe\__main__.py", line 7, in <module>
File "c:\users\tom\appdata\local\programs\python\python38-32\lib\site-packages\cx_Freeze\setupwriter.py", line 101, in main
writer.Write()
File "c:\users\tom\appdata\local\programs\python\python38-32\lib\site-packages\cx_Freeze\setupwriter.py", line 64, in Write
output = open(self.setupFileName, "w")
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\tom\\Documents\\python\\_This will create files_'正如您所看到的,我以管理员身份运行我的命令提示符,因为我在正常运行时遇到了相同的错误。我能做些什么来修复这个错误?PermissionError: [Errno 13] Permission denied: 'C:\\Users\\tom\\Documents\\python\\_This will create files_'。我找不到任何其他网站来解释如何解决这个问题。为什么会出现这个错误?能帮我一下吗..。
发布于 2020-06-12 06:41:40
发布于 2020-06-14 02:28:07
第1步:将Python添加到Windows路径
第2步:以管理员身份打开Windows命令提示符
步骤3:安装Pyinstaller包
在Windows命令提示符下,键入以下命令以安装pyinstaller软件包(然后按Enter键):
pip install pyinstaller步骤4:保存Python脚本
然后,我将Python脚本保存在以下文件夹中:
C:\Users\Ron\Desktop\MyPython
其中我将Python脚本命名为‘hello’
步骤5:使用Pyinstaller创建可执行文件
现在,您可以使用pyinstaller从Python脚本创建可执行文件。
只需转到命令提示符,然后键入:
cd,后跟Python脚本的存储位置
在我的示例中,我在命令提示符中键入了以下内容:
cd C:\Users\r Ron\Desktop\MyPython
接下来,使用以下模板创建可执行文件:
pyinstaller --onefile pythonScriptName.py因为在我们的示例中,pythonScriptName是‘hello’,所以创建可执行文件的命令是:
pyinstaller --onefile hello.py完成后,最后一次按Enter键。
步骤6:运行可执行文件
您的可执行文件现在应该在您指定的位置创建。
在我的例子中,我回到了最初存储‘hello’脚本的位置
(C:\Users\Ron\Desktop\MyPython.)。
在该位置创建的附加文件很少。要查找可执行文件,请打开dist文件夹:
现在我希望这能解决这个问题..
发布于 2020-06-14 08:13:53
Read this doc.在项目目录中创建一个setup.py文件,并将文档中的内容复制到该文件中。
根据需要修改它,然后在项目目录中运行python setup.py build。
https://stackoverflow.com/questions/61101482
复制相似问题