简体   繁体   中英

How can I know that which python my jupyter notebook is using and how can I change to use conda python?

Im trying to use torch in Jupyter notebook, but am not able to No module named 'torch' I found this This is most certainly because your notebook is not using the same python as anaconda , and checked my python_version in Jupyter and got: 3.7.6 but am not sure how to check the version of python that anaconda is using.

How can I check this? And then how can I make sure they are both using the same version?

You can locate Jupyter startup script and check what interpreter it uses:

user@pc:~$ which jupyter
/home/user/.local/bin/jupyter
user@pc:~$ cat /home/user/.local/bin/jupyter
#!/usr/bin/python3
# -*- coding: utf-8 -*-

In my case it is /usr/bin/python3 , so it uses Python 3.

You can uninstall current version and install Jupyter for another python installation by executing

pip3 uninstall jupyter
/path/to/another/python -m pip install jupyter

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM