新手小白自己动手安装Anaconda+Jupyter Notebook全记录
这两天在家学Python+mathine learning,在我刚刚入手python的时候,我写了一篇新手的入手文章,是基于Vs code编译器的入手指南,里面包括如何安装python,以及如何在Vs code中安装一些最为常见的python库。
最近两天在看MIT的公开课,无意中刷到一个面向本科生undergraduate开的基于Python的编程课。再加上那个老师的讲课风格我也比较喜欢,就稍微听了一下。我看她用的就是Anaconda,这东西好像属于一条龙安装包,里面会包含很多基本的python常用库。不再需要像我之前在VS code里面那样,用哪个包安哪个包,今天我打算学习一下,并记录一下安装过程。
这里我在这里也安利一下这门课,讲课的老师叫Ana Bell,这是一门针对没人任何编程经验的人开的课。
1,这是2016年秋的视频
https://www.youtube.com/playlist?list=PLUl4u3cNGP63WbdFxL8giv4yhgdMGaZNA
这是与之对应的课程资料
2,这是2022年的最新视频
https://www.youtube.com/watch?v=xAcTmDO6NTI&t=300s
下面是我安装的过程,从anaconda的官网开始。
Unleash AI Innovation and Value | Anaconda
1,选择Free download

2,在弹出的新窗口中输入email

后续anaconda会把下载链接发到你的邮箱里

例如这样

选择你的工作平台,下载相应的安装包

3,安装



注意,在安装anaconda的时候,不要把anaconda装到有带空格的文件夹中,也不要安到是中文文件夹中(包括安装路径)。我自己是在D盘新增了一个空文件夹。






4,启动anaconda navigator
安装好了以后,因为我在上一步已经在"Lanuch Anaconda Navigator"上打勾了,所以,当我点击"Finish"后,他就会自动启动Anaconda的主程序,就是下图中停留在屏幕中央的绿圈好像跟死机了一样,屏幕中间一直有这么一个东西。 先不要管他,他还在动,要等很久才会消失。

但屏幕中的绿圈消失了以后,我通过应用来启动,我发现还是启动不了。因为系统提示,你已经打开了一个navigator了。



我的话是按照chatGPT推荐的第一种方法,终于成功启动了。我注册了一个新的账户,也就是他这里的"sign in now"。

同时,我也把我的Navigator更新到了最新的版本。




现在你可以启动最新的anaconda了,建议你注册一个账号,并联网使用。

5,开始尝试Jupyter notebook
首先,我发现anaconda里面也有Vs code。。。然后,之所以要用Jupyter notebook,是因为我看到很多人都在用,后面如果觉得不好用,再说。

我的Jupter是通过chrome打开的,打开之后的默认界面如下。

6,导入之前在VS CODE中写好的py文件,并通过jupyter Notebook编译。
我这里就拿我以前写"通过kNN分类器对鸢尾花分类"一文中所使用的code举例。
首先,在网页的右边选择新建一个python3文件。

然后通过下面这个命令把之前的py文件导进来。
%load /path/to/your/python/file/example.py

只要你的文件路径和文件名没错,选择run,文件就能导进来了。

选择这个模块,就好出现绿色的边框,然后再次选择Run,就能跑了。

运行结果会直接出现在该模块的下面。

此外,如果你要看运行结束后的变量中所保存的内容,或数据。可以直接再下面的模块里面输入变量名就好了。比如说我随便试两个变量:




我发现这个Jupyter的强项应该是分块运行,类似于断点。后面我打算把我的py文件拆成一个个的小块去跑。
此外,你可以单击这个地方就能对notebook中的文件命名。

重命名后的文件会出现在home中

就目前看来,Jupyter notebook和vs code是各有千秋,Jupyter notebook在交互上会好一些,相当于"自带断点",每一步的结果都能看到,包括查看变量也不用打print就会显示结果。但作为一个Python的新手,我觉得Vs code更有利于我去coding,因为他有函数的提示功能,但jupyter里面没有。

我觉得后面熟悉了以后两者可能都会经常用到。
最后,你不用每次都通过anaconda navigator去启动Jupyter,这样毕竟麻烦。我现在是直接把Jupyter notebook放到chrome的收藏夹中直接调用。

(全文完)
作者 --- 松下J27

(配图与本文无关)
**版权声明:**文中的部分图片,文字或者其他素材,可能来自很多不同的网站和说明,在此没法一一列出,如有侵权,请告知,立即删除。欢迎大家转载,但是,如果有人引用或者COPY我的文章,必须在你的文章中注明你所使用的图片或者文字来自于我的文章,否则,侵权必究。 ----松下J27