Python-cxfreeze一直说文件/目录不存在 [英] Python - cxfreeze keeps saying file/directory non-existant

查看:297
本文介绍了Python-cxfreeze一直说文件/目录不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些非常基本的代码可以工作,并且我想将其转换为exe.

I've got some very basic code which works, and I want to turn it into an exe.

由于我使用的是Python 3,因为它看起来比其他Python版本干净得多,所以我无法使用Py2Exe,因此我安装了cxfreeze.

Since I'm using Python 3 because it seems so much cleaner than other Python editions, I've not been able to use Py2Exe, so I installed cxfreeze instead.

一旦我使用以下命令运行cxfreeze:

Once I run cxfreeze with the following command:

cxfreeze "C:\Users\pc user\Documents\Python\First project\Main.py"

它说明目录/文件不存在.这是尽可能深入的.确切的错误类似于找不到指定的路径"

It says something about the directory/file not existing. That's about as in-depth as it goes. The exact error is something like "Could not find the path specified"

cxfreeze本身被cmd检测到",因为当我只运行"cxfreeze"时,我没有得到无法识别的错误. cxfreeze和python都在我的PATH环境变量中.

cxfreeze itself is 'detected' by cmd because I don't get a non-recognised error when I just run "cxfreeze". Both cxfreeze and python are on my PATH environment variable.

自然,我已经对目录进行了三遍检查,它是正确的.

Naturally I've triple-checked the directory and it is correct.

我已经尝试过此命令的变体,包括

I've tried variations of this command, including

python cxfreeze "C:\Users\pc user\Documents\Python\First project\Main.py"
cxfreeze C:\Users\pc user\Documents\Python\First project\Main.py
python cxfreeze C:\Users\pc user\Documents\Python\First project\Main.py

任何人都可以发现这种情况吗?

Can anyone bring light to this situation?

推荐答案

  • 获取cxfreeze二进制文件.我来自此处.该文件是 cx_Freeze-4.2.3.win-amd64-py3.2.‌exe(我的PC是带有64b Python的win7 64位).
  • 将其安装在Python 3.2上.在以下位置创建文件cxfreeze.bat C:\Python32\Scripts.
  • 打开.bat文件.更改内容:

    • Get cxfreeze binary. I got mine from here. The file is cx_Freeze-4.2.3.win-amd64-py3.2.‌exe (my PC is win7 64-bit with 64b Python).
    • Install it on Python 3.2. A file cxfreeze.bat is created in C:\Python32\Scripts.
    • Open the .bat file. Change the contents:

      @echo off
      X:\Python32\python.exe X:\Python32\Scripts\cxfreeze %*

      使用

      @echo off
      C:\Python32\python.exe C:\Python32\Scripts\cxfreeze %*

      或对应于您的特定路径的

      or equivalent for your particular path

      Microsoft Windows [Versión 6.1.7601]
      Copyright (c) 2009 Microsoft Corporation. Reservados todos los derechos.
      
      C:\>cd c:\Python32\Scripts
      
      c:\Python32\Scripts>cxfreeze.bat "C:\Users\pc user\Documents\First project\Main.py"
      copying C:\Python32\lib\site-packages\cx_Freeze\bases\Console.exe -> c:\Python32\Scripts\d
      ist\Main.exe
      copying C:\Windows\system32\python32.dll -> c:\Python32\Scripts\dist\python32.dll
      ...............................................
      ................................................. 
      m zipimport
      m zlib
      
      copying C:\Python32\DLLs\bz2.pyd -> c:\Python32\Scripts\dist\bz2.pyd
      copying C:\Python32\DLLs\unicodedata.pyd -> c:\Python32\Scripts\dist\unicodedata.pyd
      
      c:\Python32\Scripts>
      

      • C:\Python32\Scripts\中创建了一个dist文件夹,其中包括您的 Main.exe文件
        • A dist folder is created in C:\Python32\Scripts\ that includes your Main.exe file
        • 这篇关于Python-cxfreeze一直说文件/目录不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆