程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

How to install [Python] and [Jupiter notebook] correctly?

編輯:Python

I've been learning for so long Python, Yours Python Is the installation method correct ?
Today I'll show you what is Python The right way to install , The tutorial is placed below , Like it, like it .

Python install

Python answer Q Group :660193417####
You can install Anaconda To install python
Anaconda Refers to an open source Python Release version , It contains conda、Python etc. 180 Multiple science packs and their dependencies . In this way, you can no longer install many libraries by yourself , Save time .

Baidu search anaconda Mirror image , The first one is

Here's how it works :

Then click the installation package folder , Turn to the newer version , Find a suitable version of your operating system to download .


After downloading, it is actually installed by a fool , Pay attention to two places :

  • First of all , Installation in is not recommended C disc , It can be installed in D Set a place ;
  • second , To check add environment variable , It will be more convenient to use .

Click on Next

Never mind , Click on I Agree

Don't worry, , Whichever you choose , Click on Next

Change the installation path , Click on Next


This step is more important , Be sure to check the first one , Add environment variables , Otherwise, you need to add it manually after installation , And then click Install

Then don't worry , When it is installed , Never mind what pops up in the middle , Finally, click Finish

Once installed , open cmd, Input "python", enter , You can see python Version of , Now python Just install it



Now that we have reached this stage , No hello,world It's not good , We type after the next three arrows print(“hello,world”) Then press enter to confirm


At this time, an "hello,world".



Give Way python pip Use domestic image

• Temporary use :

Can be used in pip When adding parameters -i https://pypi.tuna.tsinghua.edu.cn/simple
for example :pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyspider, In this way, you can install the image from Tsinghua pyspider library .

• Permanent modification , Once and for all :

windows Next , Directly in user Create a pip Catalog , Create a new file pip.ini.( for example :C:\Users\WQP\pip\pip.ini)

The contents are as follows :

[global]

index-url = https://pypi.tuna.tsinghua.edu.cn/simple

[install]

trusted-host=https://pypi.tuna.tsinghua.edu.cn

jupyter notebook brief introduction

Jupyter notebook Is a very powerful interactive editing interpreter , It can be used as a development document , Include code 、 Explanatory text 、 Code run results . When you're building a project prototype ,Jupyter Notebooks It's really easy to use , Because your code is written in a separate unit and executed separately . This allows the user to test specific blocks of code in the project , Instead of executing the code from the beginning of the script .

In layman's terms ,Jupyter notebook Is a very powerful interpreter that can run code , At present, I use Jpuyter notebook.

start-up jupyter notebook

We installed anaconda It has been installed at the same time Jupyter, We use a command window to open Jupyter notebook.

Create a new folder , Used to store python Script , Enter folder , Hold down shift, Right click , choice “ Open command window here ” perhaps “ Open here powershell window ”, Input jupyter notebook


Click enter , You can open a file called... From the default browser home Of web page .( Never close the command window )


Sometimes different windows may pop up , You need to enter a passwords for token


This opens the command window , There is such a string of characters


hold ”token=“ The following characters are copied to passwords for token The input box of , Click on login, You can go to the previous page .

But each computer has a different interface after it is opened , If you look closely, you will find , Some of the folders shown here are folders under the computer user directory , Why is that ? That's because jupyter notebook There is always a default directory at startup , In general , Use the user's default directory .

How to view the default directory , Or what should I do if I want to change the default directory ?

actually ,jupyter Some of the default settings are set in a default configuration file , We can view and modify the contents of the configuration file

(1) View the configuration file

stay cmd Use the following command in :jupyter-notebook --generate-config

(base) C:\Users\lenovo>jupyter-notebook --generate-config
Writing default config to: C:\Users\lenovo\.jupyter\jupyter_notebook_config.py

It can be seen that my default configuration file is in :C:\Users\lenovo.jupyter\jupyter_notebook_config.py in , Now let's look at the information of the configuration file . Get the following :


Open and find , This should essentially be a python Of py file , But in fact, they all use well numbers # At the beginning , Doesn't that mean it's all comments ? You can say that , But in fact, observation will find that , Some start with two pound signs ##, This is the annotation text , And those with a pound sign # The beginning is actually the default configuration information , That's what we're going to modify . Of course, this file is very long , I won't explain what each configuration information means one by one , I'll just talk about how to customize the default directory .

We use the editor , Search for directory Locate in the following position :

##The directory to use for notebooks and kernels.
#c.NotebookApp.notebook_dir = ''

This sentence is to set up jupyter Of , It can be seen that the default value is not , Now, for example, we want to assign it to our own directory , For example, I want it to be assigned to F On the plate myjupyter Folder , Then modify as follows :

##The directory to use for notebooks and kernels.
c.NotebookApp.notebook_dir = 'F:\myjupyter'

Save the modified file and close ! Then open it again , Find the following information , From the following information, we can see such a sentence :

Serving notebooks from local directory: F:\myjupyter

This indicates that the modification was successful .

(base) C:\Users\lenovo>jupyter-notebook
[I 14:17:57.432 NotebookApp] JupyterLab beta preview extension loaded from D:\ProgramData\Anaconda3\lib\site-packages\jupyterlab
[I 14:17:57.432 NotebookApp] JupyterLab application directory is D:\ProgramData\Anaconda3\share\jupyter\lab
[I 14:18:00.231 NotebookApp] Serving notebooks from local directory: F:\myjupyter
[I 14:18:00.232 NotebookApp] 0 active kernels
[I 14:18:00.232 NotebookApp] The Jupyter Notebook is running at:
[I 14:18:00.232 NotebookApp] http://localhost:8888/?token=ad2aa0097b0687bbd8b5b11909101533630e781e7c28753b
[I 14:18:00.232 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 14:18:00.234 NotebookApp]
Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://localhost:8888/?token=ad2aa0097b0687bbd8b5b11909101533630e781e7c28753b&token=ad2aa0097b0687bbd8b5b11909101533630e781e7c28753b
[I 14:18:00.786 NotebookApp] Accepting one-time-token-authenticated connection from ::1

matters needing attention : (https://jq.qq.com/?_wv=1027&k=Ap5XvyNN)

  • First of all 、 The folder must be created first , Here, for example. F Under the plate myjupyter The folder should be created first ; Otherwise jupyter The directory cannot be found during initialization
  • second 、 To uncomment ,c Ahead # To get rid of
  • Third 、 Note that the file name cannot be a number

besides , These operations above , It is recommended to use anaconda Self contained Anaconda Promp To operate , Because it provides very good environmental management functions , And in the system itself cmd In the operation , It may be due to some related reasons such as environment variable setting , You don't succeed . For example, I have installed... In multiple environments jupyter, however cmd The environment variable in points to A, What we may modify is B Configuration file for , This way cmd start-up jupyter The discovery remains unchanged .

Now open , Then we found that web The interface becomes as follows :

Create a new file

Click in the upper right corner of the open interface New, At this point, you can create any one you want to edit Notebook type


Click on Python establish Python notebook, Web Programming

Use of shortcut keys (https://jq.qq.com/?_wv=1027&k=Ap5XvyNN)

1 Command mode

Enter : Switch to edit mode

Shift-Enter : Run this unit , Select the next unit

Ctrl-Enter : Run this unit

Alt-Enter : Run this unit , Insert a new cell under it

Y : Unit goes to code state

M : Unit transferred to markdown state

R : Unit transferred to raw state

1 : Set up 1 Level title

2 : Set up 2 Level title

3 : Set up 3 Level title

4 : Set up 4 Level title

5 : Set up 5 Level title

6 : Set up 6 Level title

Up : Select the upper cell

K : Select the upper cell

Down : Select the cell below

J : Select the cell below

Shift-K : Enlarge and select the upper cell

Shift-J : Enlarge and select the lower cell

A : Insert a new cell above

B : Insert a new unit below

X : Cut the selected cell

C : Copy the selected cell

Shift-V : Paste to the top unit

V : Paste to the lower unit

Z : Restore the last deleted unit

D,D : Delete the selected cell

Shift-M : Merge selected cells

Ctrl-S : File on file

S : File on file

L : Convert line number

O : Conversion output

Shift-O : Conversion output scrolling

Esc : Close page

Q : Close page

H : Show shortcut help

I,I : interrupt Notebook kernel

0,0 : restart Notebook kernel

Shift : Ignore

Shift-Space : Scroll up

Space : Scroll down

2 Edit mode

Tab : Code completion or indentation

Shift-Tab : Tips

Ctrl-] : Indent

Ctrl-[ : Undo indent

Ctrl-A : Future generations

Ctrl-Z : Restore

Ctrl-Shift-Z : Do it again

Ctrl-Y : Do it again

Ctrl-Home : Jump to the beginning of the unit

Ctrl-Up : Jump to the beginning of the unit

Ctrl-End : Jump to the end of the unit

Ctrl-Down : Jump to the end of the unit

Ctrl-Left : Jump to the left with a prefix

Ctrl-Right : Jump to a prefix on the right

Ctrl-Backspace : Delete the previous word

Ctrl-Delete : Delete the next word

Esc : Enter command mode

Ctrl-M : Enter command mode

Shift-Enter : Run this unit , Select the next unit

Ctrl-Enter : Run this unit

Alt-Enter : Run this unit , Insert a unit below

Ctrl-Shift– : Split unit

Ctrl-Shift-Subtract : Split unit

Ctrl-S : File on file

Shift : Ignore

Up : Move the cursor up or forward to the previous unit

Down : Move the cursor down or forward to the next unit

5 export

Jupyter notebook Support to export multiple format files

HTML

Markdown

ReST

PDF(Through LaTex)

Raw Python

Last

Python and Jupyter notebook The installation tutorial of is on the top , And I shared some Python How to use shortcut keys , In this way, we can improve our work efficiency in our daily life . Remember the praise. , This chapter ends here .

I'm a panda , I'll see you next (*◡‿◡)

【Python】 and 【Jupyter notebook】 The correct installation method ? More articles about

  1. Python - build Jupyter notebook Environmental Science

    1- Jupyter brief introduction HomePage:https://jupyter.org/ Installation guide :https://jupyter.org/install.html Official documents :https://jupyte ...

  2. be based on Ubuntu+Python+Tensorflow+Jupyter notebook Build a deep learning environment

    be based on Ubuntu+Python+Tensorflow+Jupyter notebook Build a deep learning environment Preface 1 . Environment preparation environment introduction software download VMware Lower installation UbuntuUbuntu Next Anaconda Safety of ...

  3. Jane said Python And Jupyter Notebook

    Catalog Jane said Python And Jupyter Notebook 1.Jupyter Notebook System environment :Ubuntu 18.04.1 LTS Python Using a virtual environment :virutalenv Py ...

  4. The remote access Jupyter Notebook Two ways : Command line and configuration files

    The remote access Jupyter Notebook Two ways : Command line and configuration files Related configuration :Ubuntu 16.04 The server , Local Win10, Used Xshell,Xftp Tools . The related configuration is mainly divided into three steps : On the server J ...

  5. jupyter notebook Plug in installation and text format modification

    jupyter notebook Plug in installation and text format modification 1.jupyter notebook Expand plug-in installation start-up jupyter notebook : Open the console and enter the command jupyter noteboo ...

  6. install python Of jupyter notebook Tools

    jupyter notebook It's a web page run python Tools for Support segmented python function , And can intuitively view the results Support more python Environment is running , We need to install (conda) Installation steps 1. install python ...

  7. stay jupyter notebook Install different versions of python kernel - So you can switch

    In the installation anaconda When , The default installation is python3.6 however cs231n The homework is in py2.7 Operating in the environment . So you need to be in jupyter notebook Install and enable python2.7 edition Method : ...

  8. Python Artifact Jupyter Notebook

    What is? Jupyter Notebook? brief introduction Jupyter Notebook Is a web based application for interactive computing . It can be applied to the whole process of calculation : Development . Documentation . Run the code and display the results . Jupyter Not ...

  9. python And jupyter notebook

    jupyter Is an interactive computing and development environment ,ipython The command line is better than native python The command line is more friendly and efficient , It also works web Version of the interface , Support for multiple languages , Output graph . Audio . Video and other functions . install pip inst ...

  10. Jupyter NoteBook Series of Installation startup and common settings

    Introduce Jupyter Notebook( Previously known as IPython notebook) It's an interactive notebook , Currently supported 40 Multiple programming languages . Jupyter Notebook The essence of Web Should be ...

Random recommendation

  1. Android Customize View Collection

    Custom control learning  https://github.com/GcsSloop/AndroidNote/tree/master/CustomView  Xiaoliang custom control collection  https://github.com/ ...

  2. jquery.cookie.js && java Background code operation cookie The implementation remembers the current user input information code

    download jquery.cookie.js Address look here :http://pan.baidu.com/s/1gdCPaN5 // Verify that the password is remembered when initializing the page $(document).ready(function ...

  3. ubuntu Check port usage

    View port number sudo netstat -ltnp | The end of the process sudo kill pid

  4. About delphi in Sender Learning from

    sender yes The trigger of the event , I found all the component events It's basically Pass on Sender. Example renderings : Code : Come on , since TButton It's a class , And publish Where is the incident , We can also look at the prototype of this event .

  5. Remote Desktop Organizer The basic use and introduction of remote desktop management software

    <Remote Desktop Organizer> Is a software for remote desktop management . Software support windows Platform operation . Remote Desktop Organizer Is a Windows ...

  6. Customize Window service

    Customize window service The process from development to use : 1. After completing the corresponding code ( The code is at the bottom ), Right click MyService.cs Add setup 2. add to window The service installer opens Service1.cs[ Design ] page , ...

  7. problem 202,263、232、21、231

    [263]Ugly Number Write a program to check whether a given number is an ugly number. Ugly numbers are ...

  8. noip simulation The mayoral election

    Title Description Luan City in the kingdom of liebel was arrested for the mayor's arrest some time ago , There's no mayor to run the city . They need a new mayor . There are two people running for office . One is Norman , Be supported by supporters for supporting tourism . One is Bordeaux , It represents Lu an's traditional industry ...

  9. ie8 Compatible fillet

    ie8 Compatible fillet PIE.HTC Download address :http://css3pie.com/ compatible ie8 The code is as follows : <!DOCTYPE html> <html> <head> ...

  10. servlet Rewriting of

    package app02a;import java.io.IOException;import java.io.PrintWriter;import java.util.ArrayList;impo ...


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved