0

我想使用 py2exe 为我的 python 程序制作一个 .exe

安装程序.py

from distutils.core import setup
    import py2exe

    setup(console=['first.py'])

第一个.py

print "hello"

然后我运行这个命令:

python setup.py py2exe

first.exe 在我的 dist 文件夹中成功创建。

现在我想制作使用 PyMongo 的程序。(我已经安装了PyMongo,这个程序独立运行良好)

第一个.py

from pymongo import MongoClient
    client = MongoClient()

    db = client['configdb']

    x = db.Model.find_one()

    print x

并再次运行

python setup.py py2exe

但是当我运行 first.exe 时,出现以下错误:

Traceback (most recent call last):
      File "first.py", line 1, in <module>
      File "pymongo\__init__.pyc", line 80, in <module>
      File "pymongo\connection.pyc", line 39, in <module>
      File "pymongo\mongo_client.pyc", line 45, in <module>
      File "pymongo\pool.pyc", line 22, in <module>
      File "pymongo\thread_util.pyc", line 28, in <module>
      File "gevent\coros.pyc", line 5, in <module>
      File "gevent\lock.pyc", line 5, in <module>
      File "gevent\_semaphore.pyc", line 12, in <module>
      File "gevent\_semaphore.pyc", line 5, in __load
    AttributeError: 'module' object has no attribute 'path'

我是py2exe的初学者。我怎样才能使这项工作?

4

1 回答 1

0

just change my setup.py

from distutils.core import setup
import py2exe, sys, os

sys.argv.append('py2exe')

setup(
    options = {'py2exe': {'bundle_files': 1}},
    console = [{'script': "fisrt.py"}],
    zipfile = None,
)

and works fine now.

于 2013-10-08T13:23:39.943 回答