Jupyter notebook, wrong sys.path and sys.executable

后端 未结 3 531
野趣味
野趣味 2021-02-04 12:01

I\'m trying to run the anaconda distribution of python libraries in a Jupyter Notebook, but when I run the notebook I keep getting ImportErrors because the python path is set to

相关标签:
3条回答
  • 2021-02-04 12:40

    For me, I installed Jupyter after creating an environment, but then was trying to run a module installed from the base env. I found by "jupyter kernelspec list" (https://github.com/jupyter/notebook/issues/2563), my kernel.json at C:\Users\username\Anaconda37\share\jupyter\kernels\python3\kernel.json was pointing to the python.exe in my working env. Changed the path and solved it.

    This was an exhaustive description of python path setting.

    0 讨论(0)
  • 2021-02-04 12:42

    I had this problem when I used Anaconda Navigator and the command line. I typed 'source activate ' into the console and then used Anaconda Navigator to open Jupyter. In Anaconda Navigator, however, I wasn't in the right environment which caused the problem. This is because Anaconda Navigator comes with its own activation for virtual environments (when you click on them). So you either need to activate the virtual environment from the console and then start Jupyter from the console or you need to activate the virtual environment in Anaconda Navigator and start Jupyter from the Navigator. Both ways work but not in combination. :-)

    0 讨论(0)
  • 2021-02-04 12:50

    I figured out the solution, since the kernel was set to use the default mac os x's python I fixed it by using the commands

    python2 -m pip install ipykernel

    python2 -m ipykernel install --user

    0 讨论(0)
提交回复
热议问题