https://blog.csdn.net/submarineas/article/details/85289960

    Introduction
    jupyter notebook Introduction and Installation
    jupyter notebook use
        bug1: default browser other than Google Chrome
        jupyter tips
        bug2: matplotlib Chinese can not be displayed
        jupyter introduction of plug-in
        bug3: pdf Download issue
        co-development
        virtual environments switched
    summary

Introduction

this blog combines some of their own problems encountered during use, as well as some commonly used keyboard shortcuts, make a summary here.
jupyter notebook Introduction and Installation

in the field of scientific data, notes, codes, charts and comments are often indispensable complement each other, it came into being jupyter notebook meets all of the above requirements, the basic all students, whether or related practitioners We will go to use it, because it's easy to learn, simple operation, and anaconda as additional support with tools, very easy to download.

jupyter notebook installation:

The first option is to go to the official website to download the latest version directly on the line, may also occur version incompatibility say six months ago, for example, can only fit TensorFlow 3.5, the latest 3.6 may have to refund the environment or integrates a low version of the interpreter what, now seems to have not heard of such a small problem, basically a perfect run in 3.6. And the download process by checking directly added to the environment variables, and so long as the progress bar the installation, then all the integrated environment of anaconda on a good job. Official website as follows:
https://www.anaconda.com/

The second option is to enter the command line pip install jupyter notebook, I do not recommend using this scheme, although to a large extent reduce the use of volume, but if you want to add anything else on jupyter notebook, such as plug-ins, also there are some environmental problems caused, can cause very troublesome, and the other is above comparison, python version of the update speed is always faster than the anaconda, then other words, python can hold things anaconda can hold, but can hold anaconda not be able to install python things, where there is a date with a stable mechanism. I personally prefer stable.
jupyter notebook using the

installation is complete, the system starts, you can find the anaconda icon, we can directly jupyter icon to your desktop, then double-click to run, or I use the following in this way, open a terminal anaconda Prompt and enter jupyter notebook.

Insert picture described here

see the information shown above, the description has been launched successfully, as long as the wait for the browser to open the program will be able to start writing it. But here for the first point Benpian a bug occurs.
bug1: default browser other than Google browser

we know as a programmer, the most commonly used browser is the best course, is Google, and inside it is not just black and more technology, information access can also be put on the full. If the default browser is Google can ignore this bug.

OK, then the bug problem here is jupyter startup page is followed by the default browser becomes the default browser is valid and then start which browser page is to run, but do not know if I have win10 users, like me, it is in the control panel browser settings, the browser can not modify the default settings, resetting is useless, I may be a problem while downloading Google and QQ computer housekeeper forced to help me at home, chose QQ computer tube, and win10 application configuration again, and Qi is automatically updated as extremely pit, in my limited number of reloading the system, each will have this problem, but I always repeat the same mistakes. . So here the record about.

In the terminal type:

jupyter Notebook --generate-config

    1

and then we can see where the current configuration file:
insert here the picture described

input N indicates that no overwrite the old one, and then find the absolute path to jupyter_notebook_config us. py file, find the open with an editor, I recommend sublime text and notepad ++, I used here is notepad ++, open key ctrl + F, find c.NotebookApp.browser in this document

found after the previous comment removed, and then to add the following paragraph:

Import the WebBrowser
webbrowser.register (
    "Chrome", # defined names
    None,
    webbrowser.GenericBrowser (U "C: \\ \\ xuzhenggen the Users \\ AppData \\ Local \\ \\ Google Chrome \ \ application \\ chrome.exe ")) # specifying program location
c.NotebookApp.browser =" Chrome "

    . 1
    2
    . 3
    . 4
    . 5
    . 6

Note that the above can easily write a custom name, and the path is the location of your current Google browser of the computer, use the path \\ Note that, also I do not know why it is, in accordance with the regular terms, and in front of it u are the same as the escape character, with Windows / delimited files, u represents Unicode escape, but the system could be set up here all right, we just need to copy Google's path up along with a slash on the line.

Here Insert Picture description
jupyter tips

after startup is complete, we can see our page, and then we can start we write our program, here are some common shortcuts record:
command mode (Esc button open) Description editing mode (start Enter key) Description
Enter into edit mode Tab completion codes or retracted
Shift-Enter to run this module, select the next prompt units Shift-Tab
Ctrl-Enter operation of this unit Ctrl-] indented
Alt-Enter operation this unit, which is inserted in the new cell Ctrl- [releasing indent
Y unit into code status Ctrl-A Select
M unit into markdown state restoring Ctrl-Z
R units into raw state do Ctrl-Shift-Z
1 level 1 is set Ctrl-Y do title
second setting level 2 title Ctrl-Home skip ahead unit
skip ahead unit 3 is set to three title Ctrl-Up
4 Set the Level 4 title Ctrl-End to jump to the end of unit
5 to set five headline Ctrl-Down skip to the end unit
6 is set 6 title Ctrl-Left jump to the left a prefix
Up above the selected cell Ctrl-Right jumps the right of a prefix
K above the selected cell Ctrl-Backspace to delete the word in front of a
Down below the selected cell Ctrl-delete to delete a word behind
J under the selected unit Esc to enter command mode
Shift-K to expand above the selected cell Ctrl-M to enter the command mode
Shift-J under the selected expansion unit Shift-Enter operation of this unit, select the next unit
a new insert unit Ctrl-Enter run above this unit
B is inserted into Alt-Enter a new unit operation of this unit below, in a following insertion unit
X cut selected Ctrl-Shift- unit dividing unit
cells C to copy the selected Ctrl-Shift-Subtract division unit
Shift-V to paste the above unit Ctrl-S file save
V to paste the below Shift ignored unit
Z recover deleted last cell cursor Up Or a shift into the unit
D, D delete the selected cell Down cursor down into the next cell or
Shift-M merging the selected cell         
Ctrl-S save file         
S File Save         
L line number converter         
O converter output         
Shift-O converter output scroll         
Esc Close         
Q Close page         
H show shortcut help         
I, I interrupted Notebook kernel         
0,0 restart Notebook kernel         
Shift ignored         
Shift-Space scroll up         
Space scroll down         

organize shortcuts Jupyter Notebook from the
bug2: matplotlib Chinese can not be displayed

in Windows, usually the default encoding format for the GB2312 and GBK, and various Unix and Linux, and jupyter the environment should be UTF-8, and some fonts are not fully loaded, so we draw with matplotlib in the Windows system will be the case:

insert here the picture description
We found that the above Chinese garbled format, so the first one way and above bug1 similar, then reloaded by changing the configuration file, but this only applies to users of non-win10, win10 users can use the second, is the time to draw before introducing two codes. So now to introduce the first.

Enter \ anaconda \ Lib \ site-packages \ matplotlib \ mpl-data folder, we will see a matplotlibrc file with notepad ++ or sublime text open it and look font.family, and then replaced with the following two lines of code:

font.family: Sans-serif
font.sans serif-: the Microsoft YaHei, the Bitstream Vera Sans, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, Sans-serif

    . 1
    2

the above two codes corresponding to code added font and font size are not performed, under normal circumstances, you can show Chinese legend.
Here Insert Picture description

but in win10 in this way does not work, I found win10 seemed to lack a lot of the above-mentioned font formats, such as Microsoft YaHei (Microsoft elegant black), as if this was not the official package ttf format, it may be necessary to add their own text library, but I was too lazy to find, first of all I have linux and Windows as well as kaggle are using, there is no idea to fix it, so the following is a kind of temporary solution, but the time-tested method , plus two lines of code on the line:

plt.rcParams [ 'serif-font.sans'] = [ 'SimHei'] Chinese font set #  
plt.rcParams [ 'axes.unicode_minus'] = False

    1
    2

here Insert Picture description
jupyter introduction of plug-in

in front of me said, why should Google browser? In fact, if just from the academic aspects to consider, then, what the browser can find information key to see there is nothing without a ladder. Google may have to Google Scholar, corresponding looks too quickly. QQ browser for more HowNet. But where Google is also best to use that plug-in, all-inclusive plug-in library inside it, a lot of time and only you can not think without it missing. And as jupyter, there are many plug-ins. We need to run the following command:

PIP install jupyter_contrib_nbextensions && jupyter contrib nbextension install

    1

here Insert Picture Description

After a successful installation, we can enter the list of plugins, choose our favorite type of plug-in, here are some plugins I loaded:
insert here Image Caption

ExecuteTime: display the cell uptime and time-consuming
in this type of IDE pycharm in, each time you run the program, if we want to know the specific running time or the current execution time of the program, it may take time to bring up the module, set a start and the end value, although the line, it should not be more convenient than the plug jupyter follows:

the insert image is described herein

Codefolding in editor: collapsed code

enable CodeMirror feature to allow folding Jupyter code file editor view. In the band corresponding to the code folding jupyter as pycharm, sublime text, the following is an example of official, that I do not open:
Here insert a picture described
here Insert Picture Description

Table of Contents (2)

This is equivalent to csdn and like every time I write a blog post to add customary TOC will be a link to display the directory, the concept is the same, as the official case:
here insert a picture described

here insert the picture described

above is some recommended plug-ins, the so-called plug-in is to solve problems and raw, some may say that the plug will affect the speed, not as their own writing, this can not be denied, plug-ins and more startup items to more naturally slow, this can refer to wordpress, plugins strange background, if you want to as a web developer, depends only on the plug-in, so be sure that your website is unsuccessful, the front desk will eventually attached background together it slow card, Google is the same, but the speed is within our acceptable range, but I think jupyter as data mining, machine learning practitioners classic editor, load-ins but instead greatly reduced we need time, perhaps you say slow start, but that it 1,2 seconds, total You run a program more than a couple of weeks, no TOC link next day to sort out the code from scratch, wasting less time.
bug3: pdf Download issue

well, know the shortcuts, plug-in also loaded over, and then we happy Qiaowan code, you want to save as PDF format in order to send someone to check or acceptance, but suddenly found it will be reported to this error:
insert here the picture description
I anaconda3.6 version, there is no such problem before do not know, then I need to download two things:

pandoc: https://github.com/jgm/pandoc/releases
MiKTeX : https://miktex.org/download

Here Dir Without a ladder, it may be very slow speed, to have a 10k are quite good, and the proposal directly to Baidu to find resources or csdn site there, the second does not need a ladder.

After the installation is successful, we need to find a path through the article file, here my path is F: \ anaconda \ pkgs \ nbconvert -5.3.1-py36h8dc0fde_0 \ Lib \ site-packages \ nbconvert \ templates \ latex, would have a direct search article in pkgs keyword on the line, and then modify the \ documentclass {ctexart}

here insert a picture description

and far will be able to download a pdf file containing in addition to other than Chinese, the Chinese have if you want to download the PDF, then when we choose to download as PDF when it will pop up the following pop, here for the first time to look at whether we need mark is China http, as for the upper and lower, should be nothing much different.

Here insert a picture described

here insert a picture description

and then we will install a series of such xeCJK.sty, ulem.sty, environ.sty, trimspaces.sty etc. files, there will be about a dozen to dozens of unequal the document, if we do not want to know what is downloaded, you can always pop up before downloading the option to uncheck the box.

So after all the installation is successful, we can see the PDF file is successfully printed out, then this, from installation to successfully print out a PDF file is such a simple matter.
Here Insert Picture description
collaborative development

jupyter notebook Although the installed plug-ins and all sorts of things, but it still can not make up for the fact that as a browser editor, the editor will have a python pycharm, spyder and other equally famous IDE, but my last few You suddenly see qubit a message, and said jupyter pycharm like can develop with it. Only need to install Jupytext:

PIP install jupytext

    1

here Insert Picture Description

time and I was writing this blog is installed, specific functions have not used, but can share the author's blog links jupytext how to play and in the end, look:
here insert a picture describing

blog links (may take over the wall):

Introducing Jupytext
virtual environment to switch

on a virtual environment, or Pycharm undeniably excellent, it comes with a virtual environment loaded features, and installation on a virtual environment, you can see below me two blog describes:

build a virtual environment under Windows
build under linux virtual environment

is recommended best to create a virtual environment in the terminal, stable and easy to manage. Once you have created a virtual environment, pycharm switch directly on startup, here I do not have much to say, but jupyter notebook some trouble, as follows:

First, enter anaconda Prompt, and then enter:

Conda of an activate Test2 (virtual environment name)

    1

entered after pip list can conda list and look at the current into the virtual environment what the package, and then find a package called ipykernel, if not, then you need to install:

PIP install ipykernel

    1

success following information is displayed:
here Description inserted pictures

can then be loaded into the virtual environment jupyter notebook, the command is as follows:

Python -m ipykernel install --name Test2

    1

then you can choose to enter it in the upper right corner of jupyter notebook:

in here insert a picture description
summarizes

questions about jupyter, in the process I use is roughly like to summarize it so much, there may be some I have not encountered other aspects, I am currently learning level is relatively shallow, aspects of the model algorithm is deduced also I have it, but the code also takes real effort to improve the lot the other end of the fast, ready to write year-end summary, there is time to build personal websites and knock code, also need time to be with.
----------------
Disclaimer: This article is CSDN blogger original article "submarineas", and follow CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement. .
Original link: https: //blog.csdn.net/submarineas/article/details/85289960

 

 

 

jupyter notebook installation and use of summary

Guess you like

Origin www.cnblogs.com/anovana/p/12094833.html