How to know which is running in Jupyter notebook?

后端 未结 5 767
长发绾君心
长发绾君心 2020-12-04 15:59

I use Jupyter notebook in a browser for Python programming, I have installed Anaconda (Python 3.5). But I\'m quite sure that Jupyter in running my python commands with the n

5条回答
  •  鱼传尺愫
    2020-12-04 16:58

    import sys
    sys.executable
    

    will give you the interpreter. You can select the interpreter you want when you create a new notebook. Make sure the path to your anaconda interpreter is added to your path (somewhere in your bashrc/bash_profile most likely).

    For example I used to have the following line in my .bash_profile, that I added manually :

    export PATH="$HOME/anaconda3/bin:$PATH"
    

    EDIT: As mentioned in a comment, this is not the proper way to add anaconda to the path. Quoting Anaconda's doc, this should be done instead after install, using conda init:

    Should I add Anaconda to the macOS or Linux PATH?

    We do not recommend adding Anaconda to the PATH manually. During installation, you will be asked “Do you wish the installer to initialize Anaconda3 by running conda init?” We recommend “yes”. If you enter “no”, then conda will not modify your shell scripts at all. In order to initialize after the installation process is done, first run source /bin/activate and then run conda init

提交回复
热议问题