简体   繁体   中英

Running different kernels (e.g. Python 2.7) on Juypter

I have Python 2.7.10 (which I just installed) and I recently installed Jupyter . However the only kind of notebook I can create when I open Jupyter is iTorch and Python 3 .

How can I create a notebook in Python 2.7 ?

I'm attempting to complete a TensorFlow tutorial and that is written in Python 2.7.

The best way to run multiple versions of Python is with virtual environments . Then you can run whatever version you like whenever you like. A great way to do this for people who don't want to spend a lot of time working on it (like me) is with Continuum's Anaconda distribution of Python. I couldn't get the hang of virtual environments till this came along.

Before going any further, I recommend uninstalling the Python 2.7 you installed, and reverting to your system's Python as far as possible.

Then install Anaconda . Install the Python 3.5 version since you'll want to use that most of the time. Almost all libraries I use support it now. Google App Engine and TensorFlow are the only things I use that don't.

Now you should be able to create a Python 2.7 environment like so:

conda create -n python2 python=2.7 anaconda

The python2 is just the name; call it whatever you like. The anaconda bit installs the scientific Python stack; you can leave that off if you want a very basic environment.

Creating the environment doesn't start it. Start the environment with:

source activate python2

Add it to the notebook with:

ipython kernelspec install-self --user

Now install TensorFlow using whichever command Google recommends for your system.

Whenever you want to use that environment, do the source activate command again. To leave it, start another environment or type source deactivate . You can make as many environments as you like, with whatever versions of Python and whatever other packages you want.

Read more about managing environments.

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