python - 由于布兰卡错误,无法在 Linux Mint 上使用 Python 2.7 安装 folium
问题描述
我正在尝试在具有 Python2.7 的 Linux 机器上安装 folium,但我不断收到依赖包 branca 的此错误(从终端复制粘贴,如果我也尝试安装 folium,我会收到此错误,我已经完成了--no-cache-dir 所以你可以看到错误是相同的,即使我不使用现在缓存在我的机器上的一个 pip):
user@linux_mint ~/Desktop/map $ pip install branca --no-cache-dir
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.
warnings.warn(warning, RequestsDependencyWarning)
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Defaulting to user installation because normal site-packages is not writeable
Collecting branca
Downloading branca-0.4.0.tar.gz (41 kB)
|████████████████████████████████| 41 kB 263 kB/s
ERROR: Command errored out with exit status 1:
command: /usr/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-gK2ddq/branca/setup.py'"'"'; __file__='"'"'/tmp/pip-install-gK2ddq/branca/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-gK2ddq/branca/pip-egg-info
cwd: /tmp/pip-install-gK2ddq/branca/
Complete output (6 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-gK2ddq/branca/setup.py", line 41
print(error, file=sys.stderr) # noqa
^
SyntaxError: invalid syntax
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
这里有什么问题?是因为我不能在 Python 2.7 中使用 branca,如果我想使用 folium,我需要升级到 3.x?
或者有什么方法可以在 Python2.7 中使用 folium?
我在我的机器上使用了很多 2.7 Python,所以如果可以避免的话,我真的不想升级。我是一个业余爱好者,这是一个小的副项目,所以如果我能避免进入 3.x 的时间更长一点,我想(恕我直言,请不要告诉我为什么这很糟糕,除非它与获取 folium 相关去......这不是我的问题,而且我知道 Python 2.7 正在成为历史......我的问题实际上是我如何在 Python 2.7 机器上安装布兰卡和 folium 以最少的麻烦)。
我只是想做一些地图:)
谢谢你。
编辑:
user@linux_mint ~/Desktop/map $ python -V
Python 2.7.12
user@linux_mint ~/Desktop/map $ pip -V
pip 20.0.2 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)
解决方案
github 上的 branca 存储库包含一个名为“drop py2k”的提交,它从应用程序中删除了支持 Python2 的代码。删除的代码是这样的ImportError
:
if sys.version_info < (3, 0):
raise ImportError(
"""You are running branca {} on Python 2
branca 0.4 and above are no longer compatible with Python 2, but somehow
you got this version anyway. Make sure you have pip >= 9.0 to avoid this
kind of issue, as well as setuptools >= 24.2:
$ pip install pip setuptools --upgrade
Your choices:
- Upgrade to Python 3.
- Install an older version of branca:
$ pip install 'branca<0.4.0'
""".format(__version__)) # noqa
所以安装的时候需要指定一个较早的版本,像这样:
pip install branca<0.4.0