我正在尝试使用一些Quandl数据集创建一个数据科学项目,但是在导入时遇到错误。
据我所知,quandl应该全部以小写形式导入,如文档中所述here和here,我的导入过程如下:
import quandl
错误:
ModuleNotFoundError: No module named 'quandl'
我使用pip install quandl
安装了quandl。我的点列表输出为:
Package Version
--------------- ---------
asn1crypto 0.24.0
certifi 2019.6.16
cffi 1.12.3
chardet 3.0.4
cryptography 2.7
idna 2.8
inflection 0.3.1
more-itertools 5.0.0
ndg-httpsclient 0.5.1
numpy 1.16.4
pandas 0.24.2
pip 19.1.1
pyasn1 0.4.5
pycparser 2.19
pyOpenSSL 19.0.0
python-dateutil 2.8.0
pytz 2019.1
Quandl 3.4.8
requests 2.22.0
setuptools 41.0.1
six 1.12.0
urllib3 1.25.3
wheel 0.33.4
wincertstore 0.2
我没有pip3,因为我是通过Anaconda安装程序安装的。我正在为此项目创建的虚拟环境中运行Jupyter Notebook。请注意,python --version
的输出为:
Python 3.7.3
当我尝试使用import quandl
运行单行python脚本时,发生了奇怪的部分。这次程序运行没有错误,这意味着ModuleNotFoundError: No module named 'quandl'
的原因是jupyter笔记本,无法正确找到quandl模块。
作为最后的资源,我尝试在jupyter笔记本中安装quandl:
!pip install quandl
import quandl
输出:
Requirement already satisfied: quandl in c:\users\not_me\.conda\envs\quant\lib\site-packages (3.4.8)
Requirement already satisfied: pandas>=0.14 in c:\users\not_me\.conda\envs\quant\lib\site-packages (from quandl) (0.24.2)
Requirement already satisfied: pyOpenSSL in c:\users\not_me\.conda\envs\quant\lib\site-packages (from quandl) (19.0.0)
Requirement already satisfied: inflection>=0.3.1 in c:\users\not_me\.conda\envs\quant\lib\site-packages (from quandl) (0.3.1)
Requirement already satisfied: numpy>=1.8 in c:\users\not_me\.conda\envs\quant\lib\site-packages (from quandl) (1.16.4)
Requirement already satisfied: more-itertools<=5.0.0 in c:\users\not_me\.conda\envs\quant\lib\site-packages (from quandl) (5.0.0)
Requirement already satisfied: pyasn1 in c:\users\not_me\.conda\envs\quant\lib\site-packages (from quandl) (0.4.5)
Requirement already satisfied: python-dateutil in c:\users\not_me\.conda\envs\quant\lib\site-packages (from quandl) (2.8.0)
Requirement already satisfied: six in c:\users\not_me\.conda\envs\quant\lib\site-packages (from quandl) (1.12.0)
Requirement already satisfied: ndg-httpsclient in c:\users\not_me\.conda\envs\quant\lib\site-packages (from quandl) (0.5.1)
Requirement already satisfied: requests>=2.7.0 in c:\users\not_me\.conda\envs\quant\lib\site-packages (from quandl) (2.22.0)
Requirement already satisfied: pytz>=2011k in c:\users\not_me\.conda\envs\quant\lib\site-packages (from pandas>=0.14->quandl) (2019.1)
Requirement already satisfied: cryptography>=2.3 in c:\users\not_me\.conda\envs\quant\lib\site-packages (from pyOpenSSL->quandl) (2.7)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:\users\not_me\.conda\envs\quant\lib\site-packages (from requests>=2.7.0->quandl) (3.0.4)
Requirement already satisfied: idna<2.9,>=2.5 in c:\users\not_me\.conda\envs\quant\lib\site-packages (from requests>=2.7.0->quandl) (2.8)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\not_me\.conda\envs\quant\lib\site-packages (from requests>=2.7.0->quandl) (2019.6.16)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in c:\users\not_me\.conda\envs\quant\lib\site-packages (from requests>=2.7.0->quandl) (1.25.3)
Requirement already satisfied: asn1crypto>=0.21.0 in c:\users\not_me\.conda\envs\quant\lib\site-packages (from cryptography>=2.3->pyOpenSSL->quandl) (0.24.0)
Requirement already satisfied: cffi!=1.11.3,>=1.8 in c:\users\not_me\.conda\envs\quant\lib\site-packages (from cryptography>=2.3->pyOpenSSL->quandl) (1.12.3)
Requirement already satisfied: pycparser in c:\users\not_me\.conda\envs\quant\lib\site-packages (from cffi!=1.11.3,>=1.8->cryptography>=2.3->pyOpenSSL->quandl) (2.19)
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-614264e6071a> in <module>
1 get_ipython().system('pip install quandl')
----> 3 import quandl
ModuleNotFoundError: No module named 'quandl'
答案 0 :(得分:0)
尝试pip3 install quandl
。通常适用于Python 3.x
答案 1 :(得分:0)
尝试通过运行安装它
!pip install quandl
在Jupyter笔记本中的单元格中。如果您的设置正确,则可能会需要与您所需的pip版本相同。
答案 2 :(得分:0)
当您要确保使用与该解释程序关联的pip
版本时,可以使用模块语法而不是独立的CLI使用pip。
python -m pip install quandl
或者,由于您使用的是Conda,因此您也可以尝试使用quandl
CLI安装conda
。
conda install quandl
(或任何conda
包名称)。
答案 3 :(得分:0)
问题是Jupyter无法正确识别我的虚拟环境。我找到了答案here,解决方法很容易解释。