kernel on how to add the alternative to Jupyter notebook

kernel on how to add the alternative to Jupyter notebook

1.Anaconda knowledge preheat

Management of virtual environments

Anaconda on how to install, it is not going to repeat them here, complete installation Anaconda, Anaconda then we can use to create a separate python us the environment.

activate

We can activate the introduction of a virtual environment anaconda set, if you are behind what parameters do not add so will enter anaconda comes with base environment,

You can enter python try, it will enter the python interpreter base environment, is not your original python if you put the original environment to get rid of python environment will appreciate better, this time using the command line but python in a base environment and the command line will be preceded by one more (base) Description we are in the current environment is the next base.

Create your own virtual environment

We certainly do not satisfy a base environment, we should install a separate virtual environment for their program.

Create a name for the virtual environment Python2.7 and specify python version 2.7 (here conda 2.7 will automatically find the latest version download)

conda  create -n Python2.7  python=2.7

Or conda create --name Python2.7 python = 2.7

 So we have a Python2.7 virtual environment, and then we switch to this environment, with the same or later activae command with the name of the environment to be switched

Switching environment

activate Python2.7

If you forget the name we can first use

conda env list

 To view all environments

Now Python2.7 environment in addition to some official package comes with python is no other package, a cleaner environment, we can try

Open to enter python python interpreter and enter

>>> import requests

Requests will complain can not find the package, normal. Next, we will demonstrate how to install package requests

exit()

Exit python interpreter

Uninstall environment

conda remove --name test --all

About Environmental summary

# Create an environment called python2.7 specify Python version 2.7 (Never mind 2.7.x, conda will automatically find the latest versions 2.7.x of us)

Conda the Create --name = python2.7 Python 2.7

# after installation, use activate activate an environment

activate python2.7 # for Windows

Source activate python2.7 # for Linux & Mac

# after activation, you will find more local input terminal python2.7 words, in fact, at this time thing to do is change the default system 2.7 environment is removed from the PATH, then the corresponding command added 3.4 PATH

# in this case, re-enter

Python --version

# can get the words `Python 2.7.17, that the system has switched to 2.7 environmental

# If you want to return to the default setting, run

deactivate   # for Windows
Source deactivate  # for Linux & Mac
# delete an existing environment

conda remove --name python2.7 --all
install third-party packages
input

conda install requests

or

pip install requests

Requests to install the package.

After the installation is complete, we enter into the python interpreter and import requests package, this is certainly a success.

Uninstall third-party package
then how to uninstall a package of it

conda remove requests

or

pip uninstall requests

Come.

Check environmental package information
To view the current environment, all the packages installed can be used

conda list

Import and export environment
if you want to export the current package information environment can be used

conda env export > environment.yaml

The package information into yaml file.

When you need to re-create a virtual environment can use the same

conda env create -f environment.yaml

Command Summary

of an activate // switch to the base environment

Python2.7 of an activate // switch to Python2.7 environment

python = -n Python2.7 the Create Conda 2.7  // create an environment called Python2.7 and specify python version to the latest version 2.7

List env conda // listed conda manage all environments

List Conda // lists all current environmental package

install requests Conda  // installation package requests

Requests the Remove Conda  // unload requets package

--all -n python2.7 the Remove Conda // delete environment and learn all subordinate packages

conda update requests //更新requests包

env Export Conda> environment.yaml // export the current information environment package

env the Create -f environment.yaml Conda // configuration file to create a new virtual environment

2. Jupyter notebook to add an optional kernel to python2.7

1. Create a virtual environment Python2.7

First find below the Start menu shown Anaconda Prompt

 

 

 Click Anaconda Prompt into the terminal as shown below, enter Conda the Create -n Python2.7 python = 2.7  // create the environment and specify a named Python2.7 python version 2.7

 

 

The installation process will appear as shown below, where y input on it.

 

After installation test whether the installation was successful, enter it here activate Python2.7, Python2.7 I had installed name of the environment, where the name changes according to their own circumstances, withdraw Python2.7, with exit () can be.

 

 

2. How is added in an optional kernel

In Python2.7 environment, enter the pip install ipykernel

 

 Red explosion can occur during installation, where re-enter PIP install ipykernel .

 

 It appears as shown, the installation is successful.

 

 Then enter Python -m ipykernel install --name python2.7 .

 

Anaconda Prompt start a new input jupyter Notebook .

 

 Change kernel appear in the kernel Jupyter notebook in the newly added Python2.7 description that is added successfully.

 

Exit Python2.7 environmental inputs deactivate command.

 

 

 Jupyter notebook to see what kernel installed input jupyter kernelspec list can be.

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/zhangchenchuan/p/11840961.html