我使用pyqt4编写程序以从网站获取一些数据并保存为json
import json
import sys
from PyQt4 import QtGui
from PyQt4 import QtCore
from pip._vendor.requests import RequestException
import requests
...
content_debt = requests.get(debt_url+self.name)
debt_str= content_debt.text
debtf = open(self.name+".json",'wb')
debtf.write(debt_str)
debtf.close()
content_ind = requests.get(ind_url+self.name)
ind_str = content_ind.text
indf = open(self.name+".json",'wb')
indf.write(ind_str)
indf.close()
运行良好,所以我试着把它放到py2exe的一个exe中
from distutils.core import setup
import py2exe
import sys
#this allows to run it with a simple double click.
sys.argv.append('py2exe')
py2exe_options = {
"includes": ["sip"],
"dll_excludes": ["MSVCP90.dll",],
"compressed": 1,
"optimize": 2,
"ascii": 0,
"bundle_files": 1
}
setup(
name = 'Search',
version = '1.0',
windows = ['main.py',],
zipfile = None,
options = {'py2exe': py2exe_options}
)
打开main.exe,在我的电脑中它运行良好,但另一台计算机出错
Traceback (most recent call last):
File "main.py", line 6, in <module>
File "zipextimporter.pyo", line 82, in load_module
File "pip\__init__.pyo", line 15, in <module>
File "zipextimporter.pyo", line 82, in load_module
File "pip\vcs\subversion.pyo", line 9, in <module>
File "zipextimporter.pyo", line 82, in load_module
File "pip\index.pyo", line 30, in <module>
File "zipextimporter.pyo", line 82, in load_module
File "pip\wheel.pyo", line 35, in <module>
File "zipextimporter.pyo", line 82, in load_module
File "pip\_vendor\distlib\scripts.pyo", line 14, in <module>
File "zipextimporter.pyo", line 82, in load_module
File "pip\_vendor\distlib\compat.pyo", line 31, in <module>
ImportError: cannot import name HTTPSHandler
任何人都知道如何解决这个问题?