I am trying to install folium on my Linux machine which has Python2.7 but I keep getting this error for the dependency package branca (copy pasted from terminal, I get this error if I try to install folium as well, I've done the --no-cache-dir so you can see the error is the same even if I don't use the one pip has now cached on my machine):
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.
What's the problem here? Is it because I can't use branca with Python 2.7 and I need to upgrade to 3.x IF I want to use folium?
Or is there some way to still use folium with Python2.7?
I use a lot of 2.7 Python on my machine so I don't really want to upgrade if I can avoid it. I am a hobbyist and this is a small side-project so if I can avoid getting into 3.x a bit longer I'd like to (with all respect, please don't tell me about why that's bad unless it's relevant to getting folium going... that's not my question, and I know Python 2.7 is becoming history... my question is really just how do I get branca and folium installed on a Python 2.7 machine with minimum fuss).
I just wanna make some maps :)
Thank you.
EDIT:
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)
The branca repository on github includes a commit named "drop py2k" which removed code that supported Python2 from the application. Among the code removed was this 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
So you need to specify an earlier version when installing, like this:
pip install branca<0.4.0