使用pyinstaller编译shitil时出错

时间:2013-07-01 06:18:33

标签: python python-2.7 pyinstaller ioerror shutil

Pyinstaller& shutil [功能复制]问题!

嗨,我正在尝试将.py代码转换为.exe 实际上我的代码类似于:

 dr  = os.environ['WINDIR']
    current = os.path.abspath(__file__)
    shutil.copy(current, dr)

因为我们可以看到代码将当前的精确复制到Windows文件(这只是一个例子);代码实际上工作正常,但如果我们将它编译成exe并运行它我们会看到。

Traceback (most recent call last):
  File "<string>", line 13, in <module>
  File "C:\Documents and Settings\john\Desktop\pyinstaller\pyinstaller-2.0\test
\build\pyi.win32\test\out00-PYZ.pyz\shutil", line 119, in copy
  File "C:\Documents and Settings\john\Desktop\pyinstaller\pyinstaller-2.0\test
\build\pyi.win32\test\out00-PYZ.pyz\shutil", line 82, in copyfile
IOError: [Errno 2] No such file or directory: 'C:\\Documents and Settings\\john
\\Desktop\\pyinstaller\\pyinstaller-2.0\\test\\dist\\test.py'

错误来自函数副本,因为它在\ test \ dist \ test.py中找不到test.py.

任何解决方案?

我试过了:

 dr  = os.environ['WINDIR']
    current = os.path.abspath(__file__)
    newfile = current.replace('py','exe')
    shutil.copy(current, dr)

但仍然说

IOError: [Errno 2] No such file or directory: 'C:\\Documents and Settings\\john
\\Desktop\\exeinstaller\\exeinstaller-2.0\\test\\dist\\test.exe'

0 个答案:

没有答案