说明

完全是为了记录自己的操作记录,换一台新机器真是免不了要装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
python3 -m venv env
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 show pkgname

不使用缓存

1
pip install --no-cache-dir --default-timeout=10000  pkgname  

更新包

1
pip install  -U  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:

1
pip install pipdeptree

生成requirements.txt

1
pipdeptree -f | sed 's/ //g' | sort -u > locked-requirements.txt

常用pip命令

  1. updata pip
1
python -m pip install --upgrade pip
  1. install package
1
pip install <package-name>
  1. Update Package
1
pip install -U <package name>
  1. Install Specific Version of a Package
1
pip install <package-name>==<version>
1
pip install <packagename>>=<version>
  1. Uninstall a Package
1
pip uninstall  <packagename>
  1. Information About an Installed Package
1
pip show <package name>
  1. List All Installed Packages
1
pip list
1
pip freeze
  1. Generate a requirements.txt File
1
pip freeze > requirements.txt
  1. Install All Dependencies From requirements.txt File
1
pip install -r requirements.txt
  1. Verify That Installed Packages Have Compatible Dependencies
1
pip check
  1. List All Installed Packages That Are Not Up to Date
1
pip list -o

常用pip pkg

数据库

  1. pip install mysql-connector-python
  2. pip install psycopg2
  3. pip install PyMongo

cmd

  1. pip install fire
  2. pip install thefuck

api

  1. pip install fastapi
  2. pip install pyforest

autoload

  1. pip install reloading

map

  1. pip install geemap

emoji

  1. pip install emot

data

  1. pip install dabl
  2. pip install sweetviz

nlp

  1. pip install spacy
  2. 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

参考

  1. Managing Multiple Versions of Python on Ubuntu
  2. https://medium.com/@itylergarrett.tag/setting-up-python-3-7-on-windows-10-a-non-developer-tutorial-e836639ca16
  3. Here’s a Quick Way to Learn About PIP in Python
  4. How to Setup a Virtual Environment with Different Python Versions (Windows)
  5. Why and How to make a Requirements.txt

欢迎关注

欢迎关注微信公众帐号:沉风网事(savewind)

沉风网事