大家也可以直接体验jupyter.org/try-jupyter…
环境安装
可以使用下面命令安装miniconda:
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh | sh
复制代码
安装完成miniconda后可以这样创建和使用虚拟环境:
# Best practice, use an environment rather than install in the base env
conda create -n my-env
conda activate my-env
# If you want to install from conda-forge
conda config --env --add channels conda-forge
# The actual install command
conda install numpy
复制代码
这使用起来和Python的虚拟环境类似:
python3 -m venv .venv
source .venv/bin/activate
pip install numpy
复制代码
当然,你可以在conda环境中直接使用pip:
(my-env) [game404@y ~]$ pip list
Package Version
---------- -------
numpy 1.24.1
pip 22.3.1
setuptools 65.6.3
wheel 0.38.4
复制代码
我们可以使用下面两个命令之一安装jupyterlab:
conda install jupyterlab
或者
pip install jupyterlab
复制代码
- conda命令是从anaconda源安装;pip是用PyPi源安装,两个命令异曲同工,就看谁网速快
启动jupyter-lab
安装完jupyter-lab后,可以使用下面命令打开它:
(my-env) [game404@y ~]$jupyter-lab
[I 2023-01-08 21:26:50.250 ServerApp] jupyter_server_terminals | extension was successfully linked.
[I 2023-01-08 21:26:50.257 ServerApp] jupyterlab | extension was successfully linked.
[I 2023-01-08 21:26:50.262 ServerApp] nbclassic | extension was successfully linked.
...
[I 2023-01-08 21:26:50.842 ServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 2023-01-08 21:26:50.847 ServerApp] No web browser found: could not locate runnable browser.
[C 2023-01-08 21:26:50.848 ServerApp]
To access the server, open this file in a browser:
file:///home/yuanzuxiang/.local/share/jupyter/runtime/jpserver-3540-open.html
Or copy and paste one of these URLs:
http://localhost:8889/lab?token=f5028b1978baa74512cec56cff7c4f9e2dbbc4592cdf5b69
or http://127.0.0.1:8889/lab?token=f5028b1978baa74512cec56cff7c4f9e2dbbc4592cdf5b69
复制代码
- 注意这里的token,是权限访问的token, 初次访问首页需要使用
然后我们通过浏览器访问jupyter-lab,创建Notebook,直接测试python环境:
- 红色的Notebook Icon和引导界面一致
- 使用顶部工具栏【->】执行代码
- notebook主要是可以按照cell执行代码
安装常用库
安装好Python环境和Jupyter-lab工具后,接下来我们开始安装常用库,主要涉及下面7个库:
- numpy The fundamental package for scientific computing with Python
- pandas is a fast, powerful, flexible and easy to use open source data analysis and manipulation tool, built on top of the Python programming language.
- matplotlib Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations in Python. Matplotlib makes easy things easy and hard things possible.
- seaborn is a Python data visualization library based on matplotlib.
- scipy Fundamental algorithms for scientific computing in Python
- statsmodels statistical models, hypothesis tests, and data exploration
感谢每一个认真阅读我文章的人,看着粉丝一路的上涨和关注,礼尚往来总是要有的:
① 2000多本Python电子书(主流和经典的书籍应该都有了)
② Python标准库资料(最全中文版)
③ 项目源码(四五十个有趣且经典的练手项目及源码)
④ Python基础入门、爬虫、web开发、大数据分析方面的视频(适合小白学习)
⑤ Python学习路线图(告别不入流的学习)
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!