Skip to main content

3 posts tagged with "python"

View All Tags

· One min read

mkdir locales pybabel extract -o locales/base.pot .

pybabel init -i locales/base.pot -D base -d locales --locale zh_CN

pybabel update -i locales/base.pot -D base -d locales --locale zh_CN

pybabel compile -D base -d locales

mkdir locales

default:
cat Makefile

a:
pybabel extract -o ./base.pot ../temp

init:
pybabel init -i ./base.pot -D base -d . --locale en_US
pybabel init -i ./base.pot -D base -d . --locale zh_CN

b:
pybabel update -i ./base.pot -D base -d . --locale en_US
pybabel update -i ./base.pot -D base -d . --locale zh_CN

c:
pybabel compile -D base -d .

· One min read

notebook

cat > config.json
{
"NotebookApp": {
"password": "argon2:$argon2id$v=19$m=10240,t=10,p=8$TvqWSGeQsqj2qsztGA7rmw$k0YNPHZM/u8V67dVVst9pw"
}
}
pwd: 1~8
notebook --ip=0.0.0.0 --port=5000 --allow-root --config=./config.json
nohup jupyter notebook --ip=0.0.0.0 --port=5000 --allow-root --config=./config.json &
http://10.231.9.124:5000/tree
# 把 a.ipynb 提取出 a.py
jupyter nbconvert --to script a.ipynb
# 把 a.ipynb 提取出 a.html
jupyter nbconvert --to html a.ipynb

· One min read

python -m

cat b.json | python -m json.tool # json
python -m http.server 3333 # local file

pip加速

pip install tensorflow-gpu -i https://pypi.tuna.tsinghua.edu.cn/simple

mkdir ~/.pip
cat > ~/.pip/pip.conf << EOF
[global]
trusted-host=mirrors.aliyun.com
index-url=https://mirrors.aliyun.com/pypi/simple/
EOF
[global]
index-url=http://mirrors.cloud.aliyuncs.com/pypi/simple/

[install]
trusted-host=mirrors.cloud.aliyuncs.com

@deprecated

warnings.warn("弃用", DeprecationWarning)

venv

pip install virtualenv -i https://pypi.tuna.tsinghua.edu.cn/simple
virtualenv --no-site-packages venv

anaconda

conda create -n py39 python=3.9 anaconda

conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch

opencv