由于branca出错,无法在使用Python 2.7的Linux Mint上安装folium

2024-06-01 08:52:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我正试图在我的Linux机器上安装folium,它有Python2.7,但我一直收到依赖包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.

这里有什么问题?是不是因为我不能在Python2.7中使用branca,如果我想使用folium,我需要升级到3.x

还是有什么方法可以让folium和Python2.7一起使用

我在我的机器上使用了很多2.7 Python,所以如果可以避免的话,我真的不想升级。我是一个业余爱好者,这是一个小项目,所以如果我可以避免进入3.x多一点时间,我想(恕我直言,请不要告诉我为什么这不好,除非它与让folium运行相关……这不是我的问题,我知道Python 2.7正在成为历史……我的问题是如何在Python 2.7机器上安装branca和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)

Tags: installpipnopy机器egglinux错误
1条回答
网友
1楼 · 发布于 2024-06-01 08:52:26

github上的branca存储库包含一个名为“drop py2k”的commit,它从应用程序中删除了支持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

相关问题 更多 >