我正在尝试为我使用的笔记本安装
如果存在已知冲突,这里是完整的导入语句:
plotnine
。 我已完成以下操作:
使用Python 3.6创建了一个
conda
环境,并添加了plotnine
启动已激活上述环境的
jupyter lab
在笔记本中,我添加了以下行:
!conda install -c conda-forge --yes plotnine
然而,我的输出没有意义。 首先它说所有请求的软件包都已安装,然后它说找不到该模块。
!conda install -c conda-forge --yes plotnine
from plotnine import *
Solving environment: done
# All requested packages already installed.
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-386ef81e08ff> in <module>()
11 get_ipython().system('conda install -c conda-forge --yes plotnine')
12 ######
---> 13 from plotnine import * # python clone of ggplot2
14 matplotlib.rcParams['figure.figsize'] = [12, 8]
15 matplotlib.rcParams['lines.linewidth'] = 2
ImportError: No module named 'plotnine'
如果存在已知冲突,这里是完整的导入语句:
import gsc # proprietary module
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import pandas as pd
from ipywidgets import interact, FloatSlider
from util_demo import *
# adding installation of plotnine, which is not included by default
# import sys
!conda install -c conda-forge --yes plotnine
######
from plotnine import * # python clone of ggplot2
matplotlib.rcParams['figure.figsize'] = [12, 8]
matplotlib.rcParams['lines.linewidth'] = 2
matplotlib.rcParams['xtick.labelsize'] = 24
matplotlib.rcParams['ytick.labelsize'] = 24
matplotlib.rcParams['legend.fontsize'] = 24
matplotlib.rcParams['axes.labelsize'] = 24
编辑:我还在jupyter笔记本中检查了sys.path
,得到了以下结果。我没有看到任何关于conda
的信息。我应该更新PATH
或PYTHONPATH
吗?
['',
'/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python35.zip',
'/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5',
'/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/plat-darwin',
'/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/lib-dynload',
'/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages',
'/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/IPython/extensions',
'/Users/adamg/.ipython']
jupyterlab
包(其中包括ipykernel)添加到环境中,但这并没有解决问题。当我加载jupyter lab时,我没有选择将内核更改为该环境的选项。它只列出了Python 2和3。 - undefinedplotnine
更广泛。例如,我在statsmodels
中也遇到了类似的问题。 - undefined