没有名为内建模块的模块 [英] No module named builtins

查看:85
本文介绍了没有名为内建模块的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用py2exe将.py脚本转换为可执行文件。到目前为止,我遇到了许多问题,以下设置文件中的选项已解决了很多问题。但是现在我有一个问题,我无法找到解决方案,并且想知道其他人是否也遇到了同样的问题并加以解决。

I'm trying to convert my .py script into an executable using py2exe. I've had a number of issues so far that have been largely addressed by the "options" in the setup file below. But now I have a problem that I have not been able to find a solution for, and wondering if others have had this same issue and fixed it.

当我使用 python setup.py py2exe执行以下安装文件时,它为我提供了一个可执行文件,但是在我运行该文件时,它抱怨没有名为内置模块的模块。

When I execute the setup file below using "python setup.py py2exe" it gives me an executable but when I run it, it complains "No module named builtins".

我可以找到的关于该主题的唯一其他文章表明,内置是python3的东西,但我运行的是2.7。

The only other post I could find on this subject indicated that builtins is a python3 thing, but I'm running 2.7.

对此有任何建议或提示。

Appreciate any advice or tips on this.

from distutils.core import setup
import py2exe

from distutils.filelist import findall
import os
import matplotlib
matplotlibdatadir = matplotlib.get_data_path()
matplotlibdata = findall(matplotlibdatadir)



setup(
    console=['DET14.py'],
    options={
             'py2exe': {
                        'packages' : ['matplotlib', 'pytz'],
                        'dll_excludes':['MSVCP90.DLL',
                                        'libgdk-win32-2.0-0.dll',
                                        'libgobject-2.0-0.dll',
                                        'libgdk_pixbuf-2.0-0.dll'],
                        'includes':['scipy.sparse.csgraph._validation',
                            'scipy.special._ufuncs_cxx']
                       }
            },
#    data_files=matplotlibdata_files
    data_files=matplotlib.get_py2exe_datafiles()
)

以下是错误消息的完整列表:

Here is the full listing of what the error message looks like:

推荐答案

我终于成功了。原来,我在原始安装文件中存在一些错误,其中一些完全是愚蠢的,有些仅反映了我对setup命令的参数如何工作缺乏理解。我要补充一点,后一类错误只能通过一些Sherlock Holmes式侦查和简单的旧式试验和错误来解决。我的意思是,我还没有找到任何文件说明setup命令参数的含义和用法。如果有人拥有该信息并且可以通过它,将不胜感激。

I finally got this working. It turned out that I had some errors in the original setup file, some of which were outright dumb, and some simply reflected my lack of understanding of how the parameters of the setup command works. I will add that this latter class of errors was only resolved with some Sherlock Holmes-style sleuthing and plain old trial and error. By that I mean that I have still not found any documentation that calls out the meaning and usage of the parameters of the setup command. If anyone has that info and could pass it along that would be much appreciated.

以此为背景,答案是:

有2个基本问题:


  1. 上述安装文件中的软件包列表很不完整。我仍然不确定规则是否必须列出程序所依赖的每个程序包,以及可能不知道的程序(例如pytz)。但是当我这样做的时候,那时候我终于可以开始工作了。

  1. The list of packages in the above setup file was woefully incomplete. I am still not certain that the rule is that you have to list every single package that your program relies upon, and some which it may rely upon that you didn't know about (e.g. pytz). But when I did that, I had something at that point that I could eventually get to work.

上述原始问题中的错误消息看起来我的程序依赖于称为 patsy的东西。这让我感到困惑,因为我不知道那是什么。事实证明,statsmodels(这是我的项目的核心)对patsy具有依赖性,因此需要将其包含在statsmodels的 packages中。列表。

The error message in the above original question sort of looks like my program had a dependency on a thing called "patsy". This confused me because I had no idea what that was. It turns out that statsmodels (which is core to my project) has a dependency on patsy, so it needed to be included in the "packages" list.

下面是最终可用的安装文件。我希望对修补程序背后的逻辑的描述能对其他面临相同问题的人有所帮助。

Below is the setup file that ended up working. I hope this description of the logic behind the fix turns out to be helpful to others facing the same kind of problem.

from distutils.core import setup
import py2exe

from distutils.filelist import findall
import os
import matplotlib
matplotlibdatadir = matplotlib.get_data_path()
matplotlibdata = findall(matplotlibdatadir)



setup(
    console=['DET14.py'],
    options={
             'py2exe': {
                    'packages' : ['matplotlib', 'pytz','easygui',\
                                  'statsmodels','pandas','patsy'],
                    'dll_excludes':['MSVCP90.DLL',
                                    'libgdk-win32-2.0-0.dll',
                                    'libgobject-2.0-0.dll',
                                    'libgdk_pixbuf-2.0-0.dll'],
                    'includes':['scipy.sparse.csgraph._validation',
                        'scipy.special._ufuncs_cxx']
                   }
        },
    data_files=matplotlib.get_py2exe_datafiles()
)

这篇关于没有名为内建模块的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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