feling.net/_posts/2021-11-30-python-config.md

1.4 KiB

layout title categories tags
pages python 开发环境 的填坑与备忘
装机必备
python

安装多版本

apt install openssl # 坑 1/4
apt install libssl-dev # 坑 2/4
apt install libffi-dev # 坑 3/4

wget https://www.python.org/ftp/python/3.9.6/Python-3.9.6.tgz
wget https://www.python.org/ftp/python/3.7.11/Python-3.7.11.tgz

extract Python-3.9.6.tgz

cd Python-3.9.6

./configure --with-ssl # 坑 4/4

make

make install

虚拟环境

pipenv install --python 3  # 根据 Pipfile 创建虚拟环境(没有 Pipfile 的话就创建空白的虚拟环境)
pipenv shell  # 进入虚拟环境
pipenv --rm  # 删除当前虚拟环境

修改仓库源

可以用清华或阿里的镜像地址, 替换 Pipfile 中的源地址。

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple some-package # 临时使用清华源

http://mirrors.aliyun.com/pypi/simple/

打包、上传 pypi

pip install twine

pipenv shell

python setup.py install # 本地试安装

rm -r dist && python setup.py bdist_wheel # 打包

twine upload dist/*

配置密码,免得每次都要输入

vi ~/.pypirc

[pypi]
repository: https://upload.pypi.org/legacy/
username: chenyan
password: 密码

mypy 源码错误检查

pip install mypy

vscode 配置

"python.linting.mypyEnabled": true 
  • 文章目录 {:toc}