1

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'
4

0 回答 0