ipywidgets.embed 缺少依赖项? venv 中 运行 时的按键错误
ipywidgets.embed missing dependencies? Key error when run in venv
我正在编写一个脚本,它只向 google api 询问从 csv 文件读入的地址列表的纬度和经度,并输出 html 和google嵌入地图小部件。此外,我希望 运行 pyinstaller 将其转换为 .exe。
运行 我原来的 conda 环境中的代码它工作正常但是 pyinstaller 创建的 .exe 对于这么小的脚本来说是 massive (超过 300mb)。因此,我创建了一个新的虚拟环境,在其中工作并安装了我认为是必需的最低限度的包,并重写了代码以使用尽可能少的包,这对于代码的当前工作部分已删除它大大减少到刚刚超过 10 mb。 (没有 numpy 或 pandas 对我来说......嗯)。
代码在最后一步之前再次正常工作:
from ipywidgets.embed import embed_minimal_html
embed_minimal_html("exporttest.html", None)
上面的行应该包含任何小部件,特别是从
创建的图形
fig = gmaps.figure(layout=figure_layout)
markers = gmaps.marker_layer(coordinates)
fig.add_layer(markers)
fig
运行 我原来的 conda 环境中的当前修改版本,我所有常用的软件包都按预期安装了这个 运行s,没有错误。 运行 在虚拟环境中但是在上述行中我得到以下关键错误:
KeyError Traceback (most recent call last)
c:\programdata\anaconda3\envs\synod_environ\lib\sre_parse.py in
parse_template(source, pattern)
1020 try:
-> 1021 this = chr(ESCAPES[this][1])
1022 except KeyError:
KeyError: '\u'
During handling of the above exception, another exception occurred:
error Traceback (most recent call last)
<ipython-input-5-3359941239ab> in <module>
1 from ipywidgets.embed import embed_minimal_html
2
----> 3 embed_minimal_html("exporttest.html", None)
...
error: bad escape \u at position 0
(为澄清起见,关键错误在 u 之前有两个斜杠,将其正确 post 时有些挫折)
由于代码 运行 在一个环境中正确但在另一个环境中不正确,我只能假设我在 ipywidgets 需要的地方缺少一个包,但是 运行ning pip check
没有通知我任何遗漏。
pip list
returns 以下软件包:
altgraph 0.16.1
backcall 0.1.0
bleach 3.0.2
certifi 2018.10.15
chardet 3.0.4
colorama 0.4.0
decorator 4.3.0
defusedxml 0.5.0
entrypoints 0.2.3
future 0.17.1
geojson 2.4.1
gmaps 0.8.2
idna 2.7
ipykernel 5.1.0
ipython 7.1.1
ipython-genutils 0.2.0
ipywidgets 7.4.2
jedi 0.13.1
Jinja2 2.10
jsonschema 2.6.0
jupyter 1.0.0
jupyter-client 5.2.3
jupyter-console 6.0.0
jupyter-core 4.4.0
macholib 1.11
MarkupSafe 1.0
mistune 0.8.4
nbconvert 5.4.0
nbformat 4.4.0
notebook 5.7.0
pandocfilters 1.4.2
parso 0.3.1
pefile 2018.8.8
pickleshare 0.7.5
pip 10.0.1
prometheus-client 0.4.2
prompt-toolkit 2.0.7
Pygments 2.2.0
PyInstaller 3.4
python-dateutil 2.7.5
pywin32-ctypes 0.2.0
pywinpty 0.5.4
pyzmq 17.1.2
qtconsole 4.4.2
requests 2.20.0
Send2Trash 1.5.0
setuptools 40.4.3
six 1.11.0
terminado 0.8.1
testpath 0.4.2
tornado 5.1.1
traitlets 4.3.2
urllib3 1.24
wcwidth 0.1.7
webencodings 0.5.1
wheel 0.32.2
widgetsnbextension 3.4.2
wincertstore 0.2
关于如何进一步确定哪里出了问题、可能缺少什么包或如何解决问题的任何想法,and/or 保存 google 地图输出的替代方法?
摆弄它并从一个环境与另一个环境进行比较,我发现我的虚拟环境有 ipywidgets 7.4.2,而基础环境有 ipywidgets 7.2.1。降级版本解决了我遇到的问题。
我正在编写一个脚本,它只向 google api 询问从 csv 文件读入的地址列表的纬度和经度,并输出 html 和google嵌入地图小部件。此外,我希望 运行 pyinstaller 将其转换为 .exe。
运行 我原来的 conda 环境中的代码它工作正常但是 pyinstaller 创建的 .exe 对于这么小的脚本来说是 massive (超过 300mb)。因此,我创建了一个新的虚拟环境,在其中工作并安装了我认为是必需的最低限度的包,并重写了代码以使用尽可能少的包,这对于代码的当前工作部分已删除它大大减少到刚刚超过 10 mb。 (没有 numpy 或 pandas 对我来说......嗯)。
代码在最后一步之前再次正常工作:
from ipywidgets.embed import embed_minimal_html
embed_minimal_html("exporttest.html", None)
上面的行应该包含任何小部件,特别是从
创建的图形fig = gmaps.figure(layout=figure_layout)
markers = gmaps.marker_layer(coordinates)
fig.add_layer(markers)
fig
运行 我原来的 conda 环境中的当前修改版本,我所有常用的软件包都按预期安装了这个 运行s,没有错误。 运行 在虚拟环境中但是在上述行中我得到以下关键错误:
KeyError Traceback (most recent call last)
c:\programdata\anaconda3\envs\synod_environ\lib\sre_parse.py in
parse_template(source, pattern)
1020 try:
-> 1021 this = chr(ESCAPES[this][1])
1022 except KeyError:
KeyError: '\u'
During handling of the above exception, another exception occurred:
error Traceback (most recent call last)
<ipython-input-5-3359941239ab> in <module>
1 from ipywidgets.embed import embed_minimal_html
2
----> 3 embed_minimal_html("exporttest.html", None)
...
error: bad escape \u at position 0
(为澄清起见,关键错误在 u 之前有两个斜杠,将其正确 post 时有些挫折)
由于代码 运行 在一个环境中正确但在另一个环境中不正确,我只能假设我在 ipywidgets 需要的地方缺少一个包,但是 运行ning pip check
没有通知我任何遗漏。
pip list
returns 以下软件包:
altgraph 0.16.1 backcall 0.1.0 bleach 3.0.2 certifi 2018.10.15 chardet 3.0.4 colorama 0.4.0 decorator 4.3.0 defusedxml 0.5.0 entrypoints 0.2.3 future 0.17.1 geojson 2.4.1 gmaps 0.8.2 idna 2.7 ipykernel 5.1.0 ipython 7.1.1 ipython-genutils 0.2.0 ipywidgets 7.4.2 jedi 0.13.1 Jinja2 2.10 jsonschema 2.6.0 jupyter 1.0.0 jupyter-client 5.2.3 jupyter-console 6.0.0 jupyter-core 4.4.0 macholib 1.11 MarkupSafe 1.0 mistune 0.8.4 nbconvert 5.4.0 nbformat 4.4.0 notebook 5.7.0 pandocfilters 1.4.2 parso 0.3.1 pefile 2018.8.8 pickleshare 0.7.5 pip 10.0.1 prometheus-client 0.4.2 prompt-toolkit 2.0.7 Pygments 2.2.0 PyInstaller 3.4 python-dateutil 2.7.5 pywin32-ctypes 0.2.0 pywinpty 0.5.4 pyzmq 17.1.2 qtconsole 4.4.2 requests 2.20.0 Send2Trash 1.5.0 setuptools 40.4.3 six 1.11.0 terminado 0.8.1 testpath 0.4.2 tornado 5.1.1 traitlets 4.3.2 urllib3 1.24 wcwidth 0.1.7 webencodings 0.5.1 wheel 0.32.2 widgetsnbextension 3.4.2 wincertstore 0.2
关于如何进一步确定哪里出了问题、可能缺少什么包或如何解决问题的任何想法,and/or 保存 google 地图输出的替代方法?
摆弄它并从一个环境与另一个环境进行比较,我发现我的虚拟环境有 ipywidgets 7.4.2,而基础环境有 ipywidgets 7.2.1。降级版本解决了我遇到的问题。