Jupyter Notebook 无法打包 folium

Jupiter Notebook cannot package folium

我尝试将软件包 folium 安装到 Jupyter Notebook 中。我不得不尝试很多方法,例如添加系统路径,升级pip,安装steuptools,但我无法做到。我的笔记本电脑是 MaxBook pro,系统:Catalina 10.15.3,来自 Anaconda 的 Jupter NoteBook。 Python 版本:3.7.4

System.exectutable:

'/opt/anaconda3/bin/python'

系统路径:

['/Users/scott/Documents/Untitled Folder',
 '/opt/anaconda3/lib/python37.zip',
 '/opt/anaconda3/lib/python3.7',
 '/opt/anaconda3/lib/python3.7/lib-dynload',
 '',
 '/opt/anaconda3/lib/python3.7/site-packages',
 '/opt/anaconda3/lib/python3.7/site-packages/aeosa',
 '/opt/anaconda3/lib/python3.7/site-packages/IPython/extensions',
 '/Users/scott/.ipython']

我写的代码是:

import numpy as np
import pandas as pd
import collections
import re
import matplotlib.pyplot as plt
import matplotlib
from collections import OrderedDict
from math import ceil
#!python3 -m pip install folium --user
#!python3 -m pip install branca --user
#!python3 -m pip install jinja2 --user
#!python3 -m pip install requests --user
#!pip install --user scipy
#!python -m pip install --upgrade pip
import scipy
#import branca
! pip install --user folium
import tqdm
import folium

但是,我得到了这样的错误:

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
Collecting folium
  Using cached folium-0.8.3-py2.py3-none-any.whl (87 kB)
Requirement already satisfied: six in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from folium) (1.12.0)
Collecting jinja2
  Using cached Jinja2-2.11.1-py2.py3-none-any.whl (126 kB)
Requirement already satisfied: numpy in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from folium) (1.8.0rc1)
Collecting requests
  Using cached requests-2.23.0-py2.py3-none-any.whl (58 kB)
Collecting branca>=0.3.0
  Using cached branca-0.4.0.tar.gz (41 kB)
    ERROR: Command errored out with exit status 1:
     command: /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/zm/pks1_crj5d7d7wp4x_4sr5rm0000gn/T/pip-install-r8yciP/branca/setup.py'"'"'; __file__='"'"'/private/var/folders/zm/pks1_crj5d7d7wp4x_4sr5rm0000gn/T/pip-install-r8yciP/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 /private/var/folders/zm/pks1_crj5d7d7wp4x_4sr5rm0000gn/T/pip-install-r8yciP/branca/pip-egg-info
         cwd: /private/var/folders/zm/pks1_crj5d7d7wp4x_4sr5rm0000gn/T/pip-install-r8yciP/branca/
    Complete output (6 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/zm/pks1_crj5d7d7wp4x_4sr5rm0000gn/T/pip-install-r8yciP/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.
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-201-2c07c456259d> in <module>
     17 get_ipython().system(' pip install --user folium')
     18 import tqdm
---> 19 import folium

ModuleNotFoundError: No module named 'folium'

几天来我一直对这个错误感到困惑,谁能帮帮我?提前致谢!

看起来您正在尝试在 anaconda 3.7 环境中工作,但您的错误消息抱怨是 python 2.7,并且抱怨找不到 folium。

您在 anaconda 3.7 环境之外工作时是否以某种方式 pip install folium 模块?

也许您可以尝试使用 conda navigator 工具并以这种方式获取 folium 包...