说明
完全是为了记录自己的操作记录,换一台新机器真是免不了要装python。记录下来,便于以后操作。
apt-get安装
| 1
2
3
4
5
6
7
8
 | apt update
apt install software-properties-common
add-apt-repository ppa:deadsnakes/ppa
apt install python3.7
 | 
 
源码安装
| 1
2
3
4
5
6
7
8
9
 | sudo apt update
sudo apt install  -y build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget
wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tar.xz
tar -xf Python-3.7.3.tar.xz
cd Python-3.7.3
./configure --enable-optimizations
make
make altinstall
 | 
 
更新python3.9
| 1
2
3
 | $ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt update
$ sudo apt install python3.9
 | 
 
install pip
| 1
 | apt-get install python3-pip
 | 
 
install virutalenv
| 1
 | pip3 install virtualenv
 | 
 
| 1
 | python3 -m pip install --user virtualenv
 | 
 
| 1
 | source venv/bin/activate
 | 
 
install  pipenv
| 1
 | pip install --user pipenvd
 | 
 
| 1
 | pipenv install tweepy python-dotenv
 | 
 
| 1
 | pipenv run python twitter_client.py
 | 
 
install jupyter
| 1
2
 | python3 -m pip install --upgrade pip
python3 -m pip install jupyter
 | 
 
pip basic
查看包状态
不使用缓存
| 1
 | pip install --no-cache-dir --default-timeout=10000  pkgname  
 | 
 
更新包
指定源
有时候安装一些依赖包,网不好,直接超时,或者这个包就是死都下不下来的时候,可以指定国内源镜像。
pip install -i 国内镜像地址 包名
e.g. pip install -i  https://mirrors.aliyun.com/pypi/simple/  这是临时指定镜像地址
清华:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云:https://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
华中理工大学:https://pypi.hustunique.com/
山东理工大学:https://pypi.sdutlinux.org/
豆瓣:https://pypi.douban.com/simple/
修改配置参考:https://cloud.tencent.com/developer/article/1566247
pipdeptree
安装pipdeptree:
生成requirements.txt
| 1
 | pipdeptree -f | sed 's/ //g' | sort -u > locked-requirements.txt
 | 
 
常用pip命令
- updata pip
| 1
 | python -m pip install --upgrade pip
 | 
 
- install package
| 1
 | pip install <package-name>
 | 
 
- Update Package
| 1
 | pip install -U <package name>
 | 
 
- Install Specific Version of a Package
| 1
 | pip install <package-name>==<version>
 | 
 
| 1
 | pip install <packagename>>=<version>
 | 
 
- Uninstall a Package
| 1
 | pip uninstall  <packagename>
 | 
 
- Information About an Installed Package
| 1
 | pip show <package name>
 | 
 
- List All Installed Packages
- Generate a requirements.txt File
| 1
 | pip freeze > requirements.txt
 | 
 
- Install All Dependencies From requirements.txt File
| 1
 | pip install -r requirements.txt
 | 
 
- Verify That Installed Packages Have Compatible Dependencies
- List All Installed Packages That Are Not Up to Date
常用pip pkg
数据库
- pip install mysql-connector-python
- pip install psycopg2
- pip install PyMongo
cmd
- pip install fire
- pip install thefuck
api
- pip install fastapi
- pip install pyforest
autoload
- pip install reloading
map
- pip install geemap
emoji
- pip install  emot
data
- pip install dabl
- pip install sweetviz
nlp
- pip install  spacy
- pip install nltk
reqirements
make reqirements
| 1
 | pip freeze > requirements.txt
 | 
 
install reqirements
| 1
 | pip install -r requirements.txt
 | 
 
wsl
| 1
2
3
4
 | sudo apt update && upgrade
sudo apt install python3 python3-pip ipython3
sudo apt install python3-pip
pip3 install jupyter
 | 
 
misc
How to install Ta-Lib in python on Windows
参考
- Managing Multiple Versions of Python on Ubuntu
- https://medium.com/@itylergarrett.tag/setting-up-python-3-7-on-windows-10-a-non-developer-tutorial-e836639ca16
- Here’s a Quick Way to Learn About PIP in Python
- How to Setup a Virtual Environment with Different Python Versions (Windows)
- Why and How to make a Requirements.txt