问题
I have already installed quandl library at command prompt using command:
pip3 install quandl
And I am able to use various quandl methods.
But in my Jupyter Notebook, when I do "import quandl", it says:
No module named 'quandl'
I have restarted Jupyter notebook, even then the same results.
Other modules like Numpy, Pandas, Matplotlib work fine for me at the command-prompt and also in Jupyter Notebooks.
I have already gone through other posts mentioning the same issue, but all of them just mention the pip3 install
command - which I have already done from command prompt.
回答1:
This happens because the active env on your command line is not the same as your Jupyter Notebook's.
The solution is to make your Notebook use the same env
as your command line's active env
. You do that by changing the IPython Kernel in your Jupyter Notebook to one that uses the intended env
:
- Go to Menu options /
Kernel
Change kernel
<Select the kernel>
If you don't see an appropriate kernel, you'll need to create a new one. To do that, from your command line (where you installed quandl
), run this command:
python -m ipykernel install --user --name finance --display-name "Python (finance)"
This creates a kernel with the name of finance
(as stored in the file system) and the display name of Python (finance)
(as shown on the Kernel menu in Jupyter Notebooks).
Note: you'll need to restart the kernel in your Notebook (Menu / Kernel / Restart
) to see the new one.
Here's more info on IPython Kernels.
来源:https://stackoverflow.com/questions/58543374/quandl-not-working-in-jupyter-notebook-but-working-at-command-prompt