当我尝试将我的python脚本构建为exe文件时,我收到此错误。 这是我的剧本:
C:\Python34\Scripts>pyinstaller btcloot.py build
109 INFO: PyInstaller: 3.3
109 INFO: Python: 3.6.2
109 INFO: Platform: Windows-8.1-6.3.9600-SP0
109 INFO: wrote C:\Python34\Scripts\btcloot.spec
109 INFO: UPX is not available.
109 INFO: Extending PYTHONPATH with paths
['C:\\Python34\\Scripts', 'C:\\Python34\\Scripts', 'C:\\Python34\\Scripts']
109 INFO: checking Analysis
109 INFO: Building Analysis because out00-Analysis.toc is non existent
109 INFO: Initializing module dependency graph...
109 INFO: Initializing module graph hooks...
125 INFO: Analyzing base_library.zip ...
5109 INFO: running Analysis out00-Analysis.toc
5109 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies o
inal executable
required by c:\python34\python.exe
6093 INFO: Caching module hooks...
6109 INFO: Analyzing C:\Python34\Scripts\btcloot.py
6328 INFO: Analyzing C:\Python34\Scripts\build
Traceback (most recent call last):
File "C:\Python34\Scripts\pyinstaller-script.py", line 11, in <module>
load_entry_point('PyInstaller==3.3', 'console_scripts', 'pyinstaller')()
File "c:\python34\lib\site-packages\PyInstaller\__main__.py", line 92, in r
run_build(pyi_config, spec_file, **vars(args))
File "c:\python34\lib\site-packages\PyInstaller\__main__.py", line 46, in r
build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "c:\python34\lib\site-packages\PyInstaller\building\build_main.py", li
791, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_bui
))
File "c:\python34\lib\site-packages\PyInstaller\building\build_main.py", li
737, in build
exec(text, spec_namespace)
File "<string>", line 16, in <module>
File "c:\python34\lib\site-packages\PyInstaller\building\build_main.py", li
213, in __init__
self.__postinit__()
File "c:\python34\lib\site-packages\PyInstaller\building\datastruct.py", li
161, in __postinit__
self.assemble()
File "c:\python34\lib\site-packages\PyInstaller\building\build_main.py", li
415, in assemble
priority_scripts.append(self.graph.run_script(script))
File "c:\python34\lib\site-packages\PyInstaller\depend\analysis.py", line 2
in run_script
return super(PyiModuleGraph, self).run_script(pathname, caller=caller)
File "c:\python34\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph
", line 1326, in run_script
with open(pathname, 'rb') as fp:
PermissionError: [Errno 13] Permission denied: 'C:\\Python34\\Scripts\\build'
C:\Python34\Scripts>pyinstaller btcloot.py build
103 INFO: PyInstaller: 3.3
104 INFO: Python: 3.6.2
104 INFO: Platform: Windows-8.1-6.3.9600-SP0
106 INFO: wrote C:\Python34\Scripts\btcloot.spec
107 INFO: UPX is not available.
109 INFO: Extending PYTHONPATH with paths
['C:\\Python34\\Scripts', 'C:\\Python34\\Scripts', 'C:\\Python34\\Scripts']
110 INFO: checking Analysis
110 INFO: Building Analysis because out00-Analysis.toc is non existent
110 INFO: Initializing module dependency graph...
113 INFO: Initializing module graph hooks...
116 INFO: Analyzing base_library.zip ...
5156 INFO: running Analysis out00-Analysis.toc
5156 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies o
inal executable
required by c:\python34\python.exe
6156 INFO: Caching module hooks...
6171 INFO: Analyzing C:\Python34\Scripts\btcloot.py
6406 INFO: Analyzing C:\Python34\Scripts\build
Traceback (most recent call last):
File "C:\Python34\Scripts\pyinstaller-script.py", line 11, in <module>
load_entry_point('PyInstaller==3.3', 'console_scripts', 'pyinstaller')()
File "c:\python34\lib\site-packages\PyInstaller\__main__.py", line 92, in r
run_build(pyi_config, spec_file, **vars(args))
File "c:\python34\lib\site-packages\PyInstaller\__main__.py", line 46, in r
build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "c:\python34\lib\site-packages\PyInstaller\building\build_main.py", li
791, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_bui
))
File "c:\python34\lib\site-packages\PyInstaller\building\build_main.py", li
737, in build
exec(text, spec_namespace)
File "<string>", line 16, in <module>
File "c:\python34\lib\site-packages\PyInstaller\building\build_main.py", li
213, in __init__
self.__postinit__()
File "c:\python34\lib\site-packages\PyInstaller\building\datastruct.py", li
161, in __postinit__
self.assemble()
File "c:\python34\lib\site-packages\PyInstaller\building\build_main.py", li
415, in assemble
priority_scripts.append(self.graph.run_script(script))
File "c:\python34\lib\site-packages\PyInstaller\depend\analysis.py", line 2
in run_script
return super(PyiModuleGraph, self).run_script(pathname, caller=caller)
File "c:\python34\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph
", line 1326, in run_script
with open(pathname, 'rb') as fp:
PermissionError: [Errno 13] Permission denied: 'C:\\Python34\\Scripts\\build'
这就是我在控制台中得到的:
pyinstaller
有人能帮助我吗?我是py2exe
的新手。
此外,当我尝试使用real_batchsize = 200
for epoch in range(1, 5):
net.train()
total_loss = Variable(torch.zeros(1).cuda(), requires_grad=True)
iter_count = 0
for batch_idx, (input, target) in enumerate(train_loader):
input, target = Variable(input.cuda()), Variable(target.cuda())
output = net(input)
loss = F.nll_loss(output, target)
total_loss = total_loss + loss
if batch_idx % real_batchsize == 0:
iter_count += 1
ave_loss = total_loss/real_batchsize
ave_loss.backward()
optimizer.step()
if iter_count % 10 == 0:
print("Epoch:{}, iteration:{}, loss:{}".format(epoch,
iter_count,
ave_loss.data[0]))
total_loss.data.zero_()
optimizer.zero_grad()
时,它不会为我编译它。
答案 0 :(得分:2)
我已修好它:
pyinstaller -F btcloot.py