conda 创建虚拟环境,安装tensorflow,PyQt5 绘制 GUI,Pyinstaller 打包 .py 为 exe
文章目录
- 一、使用conda创建Python虚拟环境
- 1. 常用conda命令
- 2.命令效果展示
- 二、安装tensorflow
- 三、Pycharm配置对应环境
- 四、补充安装项目所需包
- 1. 安装PIL、tqdm
- 2.(1)keras.xxx报错
- 2.(2)tensorflow has no attribute 'Python'报错
- 3.PyQt5安装
- 4.Pycharm External Tools 配置
- 5.tensorflow FutureWarning 解决
- 五、PyQt5 绘制 GUI
- 1.绘制技巧
- 2.功能关联
- 六、Pyinstaller 打包 .py 为 exe
- 第一步:安装`Pyinstaller`
- 第二步:使用`Pyinstaller`
- 总结
一、使用conda创建Python虚拟环境
1. 常用conda命令
conda info --env # 查看已有的虚拟环境
conda activate xxx # 激活虚拟环境,xxx为虚拟环境名称
conda deactivate xxx # 退出当前虚拟环境,退回到base环境
conda list # 查看当前环境下安装了哪些包
conda search xxx # 查找xxx包的版本信息
conda create -n xxx python=3.6 # 创建指定Python版本为3.6的虚拟环境,xxx为虚拟环境名称
conda remove -n xxx --all # 完全删除名为xxx的虚拟环境(可用于虚拟环境重命名)
注:创建虚拟环境时,一定要在base环境下输入conda create -n xxx python=3.6
2.命令效果展示
(1)查看已有的虚拟环境
# 查看已有的虚拟环境
(base) C:\Users\dekan>conda info --env
# conda environments:
#
base * D:\Python_Anaconda_Install_Path
tensorflow D:\Python_Anaconda_Install_Path\envs\tensorflow
tensorflow-1.15.2 D:\Python_Anaconda_Install_Path\envs\tensorflow-1.15.2
tensorflow-1.7.0 D:\Python_Anaconda_Install_Path\envs\tensorflow-1.7.0
(2)激活虚拟环境,xxx为虚拟环境名称
(base) C:\Users\dekan>conda activate tensorflow
(tensorflow) C:\Users\dekan>
(3)退出当前虚拟环境,退回到base环境
(tensorflow) C:\Users\dekan>conda deactivate
(base) C:\Users\dekan>
(4)查看当前环境下安装了哪些包
(base) C:\Users\dekan>conda list
# packages in environment at D:\Python_Anaconda_Install_Path:
#
# Name Version Build Channel
_anaconda_depends 2019.10 py37_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
_ipyw_jlab_nb_ext_conf 0.1.0 py37_0 defaults
alabaster 0.7.11 py37_0 defaults
altgraph 0.17 pypi_0 pypi
anaconda custom py37_1 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
...
... # 中间省略居多内容,全都是python包
...
zope 1.0 py37_1 defaults
zope.interface 4.5.0 py37hfa6e2cd_0 defaults
zstd 1.3.7 h508b16e_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
(5)查找xxx包的版本信息
(base) C:\Users\dekan>conda search tensorflow
Loading channels: done
# Name Version Build Channel
tensorflow 0.12.1 py35_1 anaconda/cloud/conda-forge
tensorflow 0.12.1 py35_2 anaconda/cloud/conda-forge
...
... # 中间省略巨多内容,全都是tensorflow的各个版本信息
...
tensorflow 2.1.0 mkl_py37ha977152_0 anaconda/pkgs/main
tensorflow 2.1.0 mkl_py37ha977152_0 pkgs/main
(6)创建Python版本为3.6的虚拟环境,xxx为虚拟环境名称
(base) C:\Users\dekan>conda create -n text_detector python=3.6
Collecting package metadata (repodata.json): done
Solving environment: |
## Package Plan ##environment location: D:\Python_Anaconda_Install_Path\envs\text_detectoradded / updated specs:- python=3.6The following packages will be downloaded:package | build---------------------------|-----------------pip-20.2.3 | py36_0 2.1 MB https://mirrors.ustc.edu.cn/anaconda/pkgs/mainpython-3.6.12 | h5500b2f_2 17.8 MB https://mirrors.ustc.edu.cn/anaconda/pkgs/mainsetuptools-49.6.0 | py36_1 957 KB https://mirrors.ustc.edu.cn/anaconda/pkgs/main------------------------------------------------------------Total: 20.8 MBThe following NEW packages will be INSTALLED:certifi anaconda/pkgs/main/win-64::certifi-2020.6.20-py36_0pip anaconda/pkgs/main/win-64::pip-20.2.3-py36_0python anaconda/pkgs/main/win-64::python-3.6.12-h5500b2f_2setuptools anaconda/pkgs/main/win-64::setuptools-49.6.0-py36_1sqlite anaconda/pkgs/main/win-64::sqlite-3.33.0-h2a8f88b_0vc anaconda/pkgs/main/win-64::vc-14.1-h0510ff6_4vs2015_runtime anaconda/pkgs/main/win-64::vs2015_runtime-14.16.27012-hf0eaf9b_3wheel anaconda/pkgs/main/noarch::wheel-0.35.1-py_0wincertstore anaconda/pkgs/main/win-64::wincertstore-0.2-py36h7fe50ca_0zlib anaconda/pkgs/main/win-64::zlib-1.2.11-h62dcd97_4Proceed ([y]/n)
当然是选择原谅,呸,当然是选择y,下载过程结束后,Anaconda Prompt 显示:
done
#
# To activate this environment, use
#
# $ conda activate text_detector
#
# To deactivate an active environment, use
#
# $ conda deactivate
激活新创建的虚拟环境,开始愉快的安装tensorflow
(7)虚拟环境重命名
Anaconda中并无具体的重命名命令,所谓的“重命名”是指先复制原虚拟环境,再删除。
如名为“zhizunbao
”的虚拟环境,我们想将其重命名为"zixiaxianzi
",可进行如下操作:
conda create -n zixiaxianzi --clone zhizunbao
# 使用 clone 命令,将名为'zhizunbao'的虚拟环境,“克隆”为名为'zixiaxianzi'的虚拟环境conda remove -n zhizunbao --all
# “克隆”过程结束后,将原虚拟环境连根拔起,彻底删除!
二、安装tensorflow
1.激活虚拟环境
base环境下输入conda activate text_detector
,其中text_detector为新创建的环境名称,视具体情况而定。我是为文本检测任务而创建的虚拟环境,故命名为此。
2.安装适合自己项目的tensorflow版本
(base) C:\Users\dekan>conda activate text_detector(text_detector) C:\Users\dekan>conda install tensorflow==1.14.0
Collecting package metadata (repodata.json): done
Solving environment: \## Package Plan ##environment location: D:\Python_Anaconda_Install_Path\envs\text_detectoradded / updated specs:- tensorflow==1.14.0The following packages will be downloaded:package | build---------------------------|-----------------absl-py-0.10.0 | py36_0 169 KB https://mirrors.ustc.edu.cn/anaconda/pkgs/mainmkl_fft-1.2.0 | py36h45dec08_0 135 KB https://mirrors.ustc.edu.cn/anaconda/pkgs/mainprotobuf-3.13.0 | py36h33f27b4_1 610 KB https://mirrors.ustc.edu.cn/anaconda/pkgs/maintensorboard-1.14.0 | py36he3c9ec2_0 3.3 MB https://mirrors.ustc.edu.cn/anaconda/pkgs/maintensorflow-1.14.0 |eigen_py36hf4fd08c_0 4 KB https://mirrors.ustc.edu.cn/anaconda/pkgs/maintensorflow-base-1.14.0 |eigen_py36hdbc3f0e_0 52.4 MB https://mirrors.ustc.edu.cn/anaconda/pkgs/main------------------------------------------------------------Total: 56.6 MBThe following NEW packages will be INSTALLED:_tflow_select anaconda/pkgs/main/win-64::_tflow_select-2.2.0-eigenabsl-py anaconda/pkgs/main/win-64::absl-py-0.10.0-py36_0astor anaconda/pkgs/main/win-64::astor-0.8.1-py36_0blas anaconda/pkgs/main/win-64::blas-1.0-mklca-certificates anaconda/pkgs/main/win-64::ca-certificates-2020.7.22-0gast anaconda/pkgs/main/noarch::gast-0.4.0-py_0grpcio anaconda/pkgs/main/win-64::grpcio-1.31.0-py36he7da953_0h5py anaconda/pkgs/main/win-64::h5py-2.10.0-py36h5e291fa_0hdf5 anaconda/pkgs/main/win-64::hdf5-1.10.4-h7ebc959_0icc_rt anaconda/pkgs/main/win-64::icc_rt-2019.0.0-h0cc432a_1importlib-metadata anaconda/pkgs/main/win-64::importlib-metadata-1.7.0-py36_0intel-openmp anaconda/pkgs/main/win-64::intel-openmp-2020.2-254keras-applications anaconda/pkgs/main/noarch::keras-applications-1.0.8-py_1keras-preprocessi~ anaconda/pkgs/main/noarch::keras-preprocessing-1.1.0-py_1libprotobuf anaconda/pkgs/main/win-64::libprotobuf-3.13.0-h200bbdf_0markdown anaconda/pkgs/main/win-64::markdown-3.2.2-py36_0mkl anaconda/pkgs/main/win-64::mkl-2020.2-256mkl-service anaconda/pkgs/main/win-64::mkl-service-2.3.0-py36hb782905_0mkl_fft anaconda/pkgs/main/win-64::mkl_fft-1.2.0-py36h45dec08_0mkl_random anaconda/pkgs/main/win-64::mkl_random-1.1.1-py36h47e9c7a_0numpy anaconda/pkgs/main/win-64::numpy-1.19.1-py36h5510c5b_0numpy-base anaconda/pkgs/main/win-64::numpy-base-1.19.1-py36ha3acd2a_0openssl anaconda/pkgs/main/win-64::openssl-1.1.1h-he774522_0protobuf anaconda/pkgs/main/win-64::protobuf-3.13.0-py36h33f27b4_1pyreadline anaconda/pkgs/main/win-64::pyreadline-2.1-py36_1scipy anaconda/pkgs/main/win-64::scipy-1.5.2-py36h9439919_0six anaconda/pkgs/main/noarch::six-1.15.0-py_0tensorboard anaconda/pkgs/main/win-64::tensorboard-1.14.0-py36he3c9ec2_0tensorflow anaconda/pkgs/main/win-64::tensorflow-1.14.0-eigen_py36hf4fd08c_0tensorflow-base anaconda/pkgs/main/win-64::tensorflow-base-1.14.0-eigen_py36hdbc3f0e_0tensorflow-estima~ anaconda/pkgs/main/noarch::tensorflow-estimator-1.14.0-py_0termcolor anaconda/pkgs/main/win-64::termcolor-1.1.0-py36_1werkzeug anaconda/pkgs/main/noarch::werkzeug-1.0.1-py_0wrapt anaconda/pkgs/main/win-64::wrapt-1.12.1-py36he774522_1zipp anaconda/pkgs/main/noarch::zipp-3.1.0-py_0Proceed ([y]/n)?
当然是再一次选择原谅,呸,再一次选择y,等待下载安装完成。这就涉及到conda配置镜像源的问题了,请参考。
三、Pycharm配置对应环境
创建虚拟环境后,还需对Pycharm进行简单配置,以使当前项目的Project Interpreter为特地为其创建的虚拟环境。 创建虚拟环境 首先打开Anaconda Prompt,创建虚拟环境 conda create -n tensorflow python=3.7 激活虚拟环境 激活虚拟环境tensorflow acti ... 在控制台查看pip的版本,看是否需要进行pip的版本更新: pip list --outdated 若需要更新,则输入如下命令: python -m pip install --upgrade pip ... python管理包管理工具pip使用,及使用pip创建虚拟环境 文章目录: 1 pip的使用 1.1 pip的基础使用 1.1.1 pip安装库包(pip install) 1.1.2 pip卸载库包 ... conda创建虚拟环境 和 用conda创建GPU的cuda.cudnn使用环境 1 conda在linux.windows上创建虚拟环境 1.1 首先在所在系统中安装Anaconda. 1.2 co ... 有时创建了新的虚拟环境之后才发现,有些包并不支持现有的python版本这就很麻烦.常用的改变这一窘境的方法就是重新建一个虚拟环境,但是之前花了很多时间装了那么多包,这不就浪费了嘛.最好的一种做法就 ... 1 启动Anaconda虚拟环境 安装Tensorflow与keras前,先启动Tensorflow的Anaconda虚拟环境. activate myTensorEnv 2 安装Tensorflow ... 目录 作者介绍 创建虚拟环境 虚拟环境的激活与切换 安装Pytorch 进行验证 虚拟环境的复制.复现与删除 Jupyter notebook的安装与使用 作者介绍 王世豪,男,西安工程大学电子信息学 ... (1)创建虚拟环境 https://blog.csdn.net/lyy14011305/article/details/59500819 (2)安装pytorch=0.3.1 conda instal ... 2.conda常用的命令 1)查看安装了哪些包 conda list 2)查看当前存在哪些虚拟环境 conda env list conda info -e 3)检查更新当前conda conda u ...
流水线:File→Settings→Project:xxxx→Project Interpreter→▼→show all
流水线:➕→Existing environment→...(选择路径)→
conda 创建虚拟环境,安装tensorflow,PyQt5 绘制 GUI,Pyinstaller 打包 .py 为 exe相关推荐
最新文章
热门文章