python 大杂烩

 

Python 环境大杂烩

https://tensorflow.google.cn/install/source?hl=zh_cn
http://hpc.pku.edu.cn/_book/guide/soft/case/case/vasp.html
https://blog.csdn.net/Mr_Cat123/article/details/82993357


yum install python3-dev python3-pip python3-venv

 yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel

设置pip 加速
http://www.zyglz.com/index.php/archives/18.html
--------------------------------------------------------------------------------------
mkdir ~/.pip
cat > ~/.pip/pip.conf << EOF
[global]
trusted-host=mirrors.aliyun.com
index-url=https://mirrors.aliyun.com/pypi/simple/
EOF
--------------------------------------------------------------------------------------

阿里云源:https://mirrors.aliyun.com/pypi/simple
腾讯云源:https://mirrors.cloud.tencent.com/pypi/simple
豆瓣源:https://pypi.doubanio.com/simple
清华源:https://pypi.tuna.tsinghua.edu.cn/simple
华为源:https://repo.huaweicloud.com/simple
./configure --prefix=/usr/local/mpich make && make install

python -m pip install --upgrade pip

pip 卸载全部包

pip freeze
pip freeze > packages.txt
pip uninstall -r packages.txt -y
pip install -r packages.txt

pip 安装依赖
2.生成requirements.txt文件:
3.安装requirements.txt依赖:

pip freeze > requirements.txt
pip install -r requirements.txt


pip 指定包的目录
方法一
指定安装numpy包到固定文件夹下,比如这里“文件夹”是安装路径

pip install -t 文件夹 numpy

方法2

查看目录
python -m site  
打开
\Programs\Python\Python37\Lib\
修改 USER_SITE 和 USER_BASE 两个字段的值(之前是null).

#自定义依赖安装包的路径
USER_SITE = null
#自定义的启用Python脚本的路径
USER_BASE = null
我这里修改为

USER_SITE = "D:\program\Anaconda\envs\py36\Lib\site-packages"
USER_BASE = "D:\program\Anaconda\envs\py36\Scripts"
验证
python -m site 




1.安装 Anaconda-Clean package
打开 Anaconda Prompt, 输入以下命令:
conda install anaconda-clean
输入以下命令卸载
anaconda-clean --yes
经过 Solution A 的方式卸载。

 

Conda 环境

 

yum install python3-dev python3-pip python3-venv

 yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel

设置pip 加速
http://www.zyglz.com/index.php/archives/18.html
--------------------------------------------------------------------------------------
mkdir ~/.pip
cat > ~/.pip/pip.conf << EOF
[global]
trusted-host=mirrors.aliyun.com
index-url=https://mirrors.aliyun.com/pypi/simple/
EOF
--------------------------------------------------------------------------------------


pip3 install tensorflow==2.0.0 -i https://pypi.tuna.tsinghua.edu.cn/simple



# 获得最新的miniconda安装包;
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
# 安装到自己的HOME目录software/miniconda3中,这个目录在安装前不能存在;
sh Miniconda3-latest-Linux-x86_64.sh -b -p ${HOME}/software/miniconda3
# 安装成功后删除安装包
rm -f Miniconda3-latest-Linux-x86_64.sh
# 将环境变量写入~/.bashrc文件中;
echo "export PATH=${HOME}/software/miniconda3/bin:\$PATH" >> ~/.bashrc
# 退出重新登录或者执行以下命令
source ~/.bashrc

#加速
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

conda config --set show_channel_urls yes

#GPU 版
conda create -n tf-gpu-2.3.0 tensorflow-gpu==2.3.0 -y


#CPU 版
conda create -n tf-2.3.0 tensorflow==2.3.0 -y
source activate tf-2.3.0
python -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"

import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
##保证sess.run()能够正常运行 2.0版本的
import tensorflow as tf
tf.__version__
tf.compat.v1.disable_eager_execution() 
hello = tf.constant('hello,tensorflow')
sess= tf.compat.v1.Session()
print(sess.run(hello))



#导入包
from hyperlpr import *
#导入OpenCV库
import cv2
#读入图片
image = cv2.imread("D:\\tensorflow\\lpr-master\\test-imgs\\1.jpg")
cv2.imshow("Image", image)
#识别结果
print(HyperLPR_plate_recognition(image))



source deactivate

win

pip install tensorflow-1.6.0-cp36-cp36m-win_amd64.whl

pip install tensorflow-2.3.0-cp38-cp38m-win_amd64.whl

Win 10 

1.python -m pip install --upgrade pip

临时使用:
pip install --trusted-host https://repo.huaweicloud.com -i https://repo.huaweicloud.com/repository/pypi/simple 安装的包名
或者
pip install -i https://repo.huaweicloud.com/simple/sqlalchemy


永久使用:
# Window
完整地址:C:\Users\%UserName%\pip\pip.ini
Ctrl + R 进入运行,地址栏输入:C:\Users\%UserName%,然后创建pip文件夹,然后创建pip.ini文件
内容:
[global]
index-url = https://repo.huaweicloud.com/repository/pypi/simple
trusted-host = repo.huaweicloud.com
timeout = 120
————————————————————————
# Linux
mkdir -p ~/.pip/
cat <<EOF >  ~/.pip/pip.conf
[global]
index-url = https://repo.huaweicloud.com/repository/pypi/simple
trusted-host = repo.huaweicloud.com
timeout = 120
EOF



pip freeze > requirements.txt
pip install -r requirements.txt

2.生成requirements.txt文件:
3.安装requirements.txt依赖:


import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
import tensorflow as tf
tf.__version__
tf.compat.v1.disable_eager_execution() #保证sess.run()能够正常运行
hello = tf.constant('hello,tensorflow')
sess= tf.compat.v1.Session()#版本2.0的函数
print(sess.run(hello))

 

posted @ 2021-06-24 17:49  一颗大白鲸  阅读(62)  评论(0编辑  收藏  举报