ipywidgets.embed缺少依赖项?在venv中运行时出现关键错误

时间:2018-10-31 19:36:52

标签: python google-maps ipywidgets

我正在编写一个脚本,该脚本仅向google api询问从csv文件读取的地址列表的纬度和经度,并输出嵌入了googlemap小部件的html。此外,我希望运行pyinstaller以便使其成为.exe。

在我的原始conda环境上运行代码可以正常工作,但是pyinstaller创建的.exe对于如此小的脚本(超过300mb )来说,是 massive 。因此,我创建了一个新的虚拟环境,可以在其中工作并安装了我认为是必需的最低限度的软件包,并重写了代码以使用尽可能少的软件包,以删除当前工作的代码部分。它大大下降到刚刚超过10 mb。 (对我来说,没有numpy或熊猫……嗯)。

代码再次正常运行,直到最后一步:

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环境中运行当前已修改的版本,并安装了我所有的常规软件包,这可以按预期运行,没有错误。在虚拟环境中运行,但是在上面提到的行上,我遇到以下关键错误:

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之前有两个斜杠,使它无法正确发布会有些挫败感

由于代码可以在一个环境中正常运行,而不能在另一个环境中正常运行,因此我只能假设我在ipywidgets所需的某个地方缺少了一个软件包,但是运行pip check并不会将任何丢失通知我。 / p>

pip list返回以下包:

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

关于如何进一步确定出了什么问题,可能缺少哪些软件包或如何解决此问题以及/或保存googlemaps输出的其他方法的任何想法?

1 个答案:

答案 0 :(得分:0)

摆弄它,并从一个环境与另一个环境进行比较,我发现我的虚拟环境具有ipywidgets 7.4.2,而基本环境具有ipywidgets 7.2.1。降级可以解决我遇到的问题。