James He 2018-12-27 16:39 采纳率: 100%
浏览 10148
已采纳

12306抢票打包exe报错json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

环境win7python3.7pyinstaller3.4代码是网上参考的,功能性不影响,但是在用pyinstaller打包的时候会报错。源代码如下:

# coding=utf-8
from splinter.browser import Browser
from time import sleep
import traceback
user_name = input("账号")
password = input("密码")
# 账号密码
d_time = u"2019-01-04"
starts = u"%u4E0A%u6D77%2CSHH"
ends = u"%u6606%u660E%2CKMM"
order = 1
ticket_url = u"https://kyfw.12306.cn/otn/leftTicket/init"
login_url = u"https://kyfw.12306.cn/otn/login/init"
initmy_url = u"https://kyfw.12306.cn/otn/view/index.html"


def login():
    b.find_by_text(u"登录").click()
    sleep(3)
    b.find_by_text(u"账号登录").click()
    sleep(0.5)
    b.find_by_id(u"J-userName").fill(user_name)
    sleep(1)
    b.find_by_id(u"J-password").fill(password)
    sleep(1)
    print(u"自己手动选择验证码图片并且点击登录")
    while True:
        if b.url != initmy_url:
            sleep(1)
        else:
            break


def huo_che():
    global b
    b = Browser(driver_name="chrome")
    b.visit(ticket_url)
    while b.is_text_present(u"登录"):
        sleep(1)
        login()
        if b.url == initmy_url:
            break
    try:
        print(u"购票页面...")
        # 跳回购票页面
        b.visit(ticket_url)
        # 加载查询信息
        b.cookies.add({u"_jc_save_fromStation": starts})
        b.cookies.add({u"_jc_save_toStation": ends})
        b.cookies.add({u"_jc_save_fromDate": d_time})
        b.reload()
        sleep(2)
        count = 0
        # 循环点击预订
        if order != 0:
            while b.url == ticket_url:
                b.find_by_text(u"查询").click()
                count += 1
                print(u"循环点击查询... 第 %s 次" % count)
                sleep(1)
                try:
                    b.find_by_text(u"预订")[order-1].click()
                    break
                except Exception as e:
                    print(e)
                    continue
        else:
            while b.url == ticket_url:
                b.find_by_text(u"查询").click()
                count += 1
                print(u"循环点击查询... 第 %s 次" % count)
                sleep(1)
                try:
                    for i in b.find_by_text(u"预订"):
                        i.click()
                except Exception as e:
                    print(e)
                    continue
        b.find_by_id(u"normalPassenger_0").click()
        b.find_by_id(u"submitOrder_id").click()
        sleep(0.5)
        b.find_by_id(u"qr_submit_id").click()
        print(u"自行支付")
    except Exception as e:
        print(e)
        print(traceback.print_exc())


if __name__ == "__main__":
    huo_che()

打包时候报错:
13737 WARNING: Cannot read QLibraryInfo output: raised Expecting value: line 1 column 1 (char 0) when decoding:
Traceback (most recent call last):
File "", line 11, in
ImportError: DLL load failed: 找不到指定的程序。
Traceback (most recent call last):
File "D:\python\Scripts\pyinstaller-script.py", line 11, in
load_entry_point('PyInstaller==3.4', 'console_scripts', 'pyinstaller')()
File "d:\python\lib\site-packages\PyInstaller__main__.py", line 111, in run
run_build(pyi_config, spec_file, **vars(args))
File "d:\python\lib\site-packages\PyInstaller__main__.py", line 63, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "d:\python\lib\site-packages\PyInstaller\building\build_main.py", line 838, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "d:\python\lib\site-packages\PyInstaller\building\build_main.py", line 784, in build
exec(text, spec_namespace)
File "", line 17, in
File "d:\python\lib\site-packages\PyInstaller\building\build_main.py", line 241, in init
self.__postinit__()
File "d:\python\lib\site-packages\PyInstaller\building\datastruct.py", line 158, in postinit
self.assemble()
File "d:\python\lib\site-packages\PyInstaller\building\build_main.py", line 500, in assemble
module_hook.post_graph()
File "d:\python\lib\site-packages\PyInstaller\building\imphook.py", line 410, in post_graph
self._load_hook_module()
File "d:\python\lib\site-packages\PyInstaller\building\imphook.py", line 377, in load_hook_module
self.hook_module_name, self.hook_filename)
File "d:\python\lib\site-packages\PyInstaller\compat.py", line 736, in importlib_load_source
return mod_loader.load_module()
File "", line 407, in _check_name_wrapper
File "", line 907, in load_module
File "", line 732, in load_module
File "", line 265, in _load_module_shim
File "", line 696, in _load
File "", line 677, in _load_unlocked
File "", line 728, in exec_module
File "", line 219, in _call_with_frames_removed
File "d:\python\lib\site-packages\PyInstaller\hooks\hook-PyQt5.py", line 23, in
collect_system_data_files(pyqt5_library_info.location['PrefixPath'],
File "d:\python\lib\site-packages\PyInstaller\utils\hooks\qt.py", line 67, in __getattr
_
qli = json.loads(json_str)
File "d:\python\lib\json__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "d:\python\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "d:\python\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

  • 写回答

2条回答 默认 最新

  • James He 2018-12-29 03:37
    关注

    新建一个虚拟环境重新安装pyinstaller就可以了

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 利用决策森林为什么会出现这样·的问题(关键词-情感分析)
  • ¥15 DispatcherServlet.noHandlerFound No mapping found for HTTP request with URI[/untitled30_war_e
  • ¥15 使用deepspeed训练,发现想要训练的参数没有梯度
  • ¥15 寻找一块做为智能割草机的驱动板(标签-stm32|关键词-m3)
  • ¥15 信息管理系统的查找和排序
  • ¥15 基于STM32,电机驱动模块为L298N,四路运放电磁传感器,三轮智能小车电磁组电磁循迹(两个电机,一个万向轮),怎么用读取的电磁传感器信号表示小车所在的位置
  • ¥15 如何解决y_true和y_predict数据类型不匹配的问题(相关搜索:机器学习)
  • ¥15 PB中矩阵文本型数据的总计问题。
  • ¥15 MATLAB卫星二体模型仿真
  • ¥15 怎么让数码管亮的同时让led执行流水灯代码