当前位置:网站首页>Conda creates a virtual environment method and pqi uses a domestic mirror source to install a third-party library method tutorial
Conda creates a virtual environment method and pqi uses a domestic mirror source to install a third-party library method tutorial
2022-08-10 05:17:00 【Programming enthusiast-Axin】
文章目录
condaCreate a virtual environment method and pqiTutorial on how to install third-party libraries using domestic mirror sources
一、conda创建虚拟环境
1.1、创建环境
create : 创建
environment_name 环境名字
package_names 包名字
conda create --name <env_name> <package_names>
conda create --name test_env python=3.7.11
<env_name>
即创建的环境名.建议以英文命名,且不加空格,名称两边不加尖括号“<>”.<package_names>
即安装在环境中的包名.名称两边不加尖括号“<>”.- 如果要安装指定的版本号,则只需要在包名后面以
=
和版本号的形式执行.如:conda create --name python3 python=3.6
,即创建一个名为“python3”的环境,环境中安装版本为2.7的python.
- 如果要安装指定的版本号,则只需要在包名后面以
- 如果要在新创建的环境中创建多个包,则直接在
<package_names>
后以空格隔开,添加多个包名即可.如:conda create -n python3 python=3.6 numpy pandas
,即创建一个名为“python3”的环境,环境中安装版本为3.6的python,同时也安装了numpy和pandas.
- 如果要在新创建的环境中创建多个包,则直接在
--name
同样可以替换为-n
.
1.2、Routines for creating virtual environments
- 创建spider虚拟环境
打开Pycharm
点开terminal,如下所示
输入创建虚拟环境的命令:conda create --name spider python=3.7
The following code prompt appears:
(venv) E:\Document\programmLanguageExper\Python\ProjectFirst>conda create --name spider python=3.7
Solving environment: done
==> WARNING: A newer version of conda exists. <==
current version: 4.5.11
latest version: 4.13.0
Please update conda by running
$ conda update -n base -c defaults conda
## Package Plan ##
environment location: D:\SoftWare\Python\Anaconda3\envs\spider
added / updated specs:
- python=3.7
The following packages will be downloaded:
package | build
---------------------------|-----------------
vc-14.2 | h21ff451_1 8 KB
pip-22.1.2 | py37haa95532_0 2.9 MB
openssl-1.1.1q | h2bbff1b_0 5.7 MB
sqlite-3.39.2 | h2bbff1b_0 1.2 MB
certifi-2022.6.15 | py37haa95532_0 157 KB
wheel-0.37.1 | pyhd3eb1b0_0 31 KB
ca-certificates-2022.07.19 | haa95532_0 162 KB
vs2015_runtime-14.27.29016 | h5e58377_2 2.2 MB
wincertstore-0.2 | py37haa95532_2 15 KB
setuptools-61.2.0 | py37haa95532_0 1.3 MB
python-3.7.13 | h6244533_0 17.9 MB
------------------------------------------------------------
Total: 31.7 MB
The following NEW packages will be INSTALLED:
ca-certificates: 2022.07.19-haa95532_0
certifi: 2022.6.15-py37haa95532_0
openssl: 1.1.1q-h2bbff1b_0
pip: 22.1.2-py37haa95532_0
python: 3.7.13-h6244533_0
setuptools: 61.2.0-py37haa95532_0
sqlite: 3.39.2-h2bbff1b_0
vc: 14.2-h21ff451_1
vs2015_runtime: 14.27.29016-h5e58377_2
wheel: 0.37.1-pyhd3eb1b0_0
wincertstore: 0.2-py37haa95532_2
Proceed ([y]/n)?
- 选择y,进行安装
- The code for the installation process appears:
Downloading and Extracting Packages
vc-14.2 | 8 KB | ################################################################################################################################################################### | 100%
pip-22.1.2 | 2.9 MB | ################################################################################################################################################################### | 100%
openssl-1.1.1q | 5.7 MB | ################################################################################################################################################################### | 100%
sqlite-3.39.2 | 1.2 MB | ################################################################################################################################################################### | 100%
certifi-2022.6.15 | 157 KB | ################################################################################################################################################################### | 100%
wheel-0.37.1 | 31 KB | ################################################################################################################################################################### | 100%
ca-certificates-2022 | 162 KB | ################################################################################################################################################################### | 100%
vs2015_runtime-14.27 | 2.2 MB | ################################################################################################################################################################### | 100%
wincertstore-0.2 | 15 KB | ################################################################################################################################################################### | 100%
setuptools-61.2.0 | 1.3 MB | ################################################################################################################################################################### | 100%
python-3.7.13 | 17.9 MB | ################################################################################################################################################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use:
# > activate spider
#
# To deactivate an active environment, use:
# > deactivate
#
# * for power-users using bash, you must source
#
当出现
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
Indicates that the installation of the virtual environment was successful.
- 使用activate spider命令激活condavirtual environment command
- 如下所示
C:\WINDOWS\system32>activate spider
(spider) C:\WINDOWS\system32>conda list
Now enter the virtual environment we created,现在使用conda list to see what is installed in the virtual environmentPython库
(spider) C:\WINDOWS\system32>conda list
# packages in environment at D:\SoftWare\Python\Anaconda3\envs\spider:
#
# Name Version Build Channel
ca-certificates 2022.07.19 haa95532_0
certifi 2022.6.15 py37haa95532_0
openssl 1.1.1q h2bbff1b_0
pip 22.1.2 py37haa95532_0
python 3.7.13 h6244533_0
setuptools 61.2.0 py37haa95532_0
sqlite 3.39.2 h2bbff1b_0
vc 14.2 h21ff451_1
vs2015_runtime 14.27.29016 h5e58377_2
wheel 0.37.1 pyhd3eb1b0_0
wincertstore 0.2 py37haa95532_2
(spider) C:\WINDOWS\system32>
- appears as shown above,Explain that the virtual environment has these installedPython库.If we want to be in this virtual environment,安装其他的Python第三方库,可以使用pip安装命令进行安装.
- But domesticallypip下载pythonPacking is really slow,It's easy to fail with a timeout.从而使用pqi可以把PyPiThe source is quickly switched to a domestic sourcetuna, douban, aliyun, ustc从而加快pythonPackage installation speed.接下来介绍pqi的安装方法,and related instructions for use.
二、pqi安装Python第三方库
2.1、安装pqi库
- 使用pip命令即可安装pqi库
pip install pqi
2.2、pqi的使用方法
- 命令行输入 pqi 回车
(spider) E:\Document\programmLanguageExper\Python\ProjectFirst>pqi
Usage:
pqi ls
pqi use <name>
pqi show
pqi add <name> <url>
pqi remove <name>
pqi (-h | --help)
pqi (-v | --version)
Options:
-h --help Show this screen.
-v --version Show version.
(spider) E:\Document\programmLanguageExper\Python\ProjectFirst>
如上所示,列出了一些pqi常用的命令
列举所有支持的Ppqi
(spider) E:\Document\programmLanguageExper\Python\ProjectFirst>pqi ls
pypi https://pypi.python.org/simple/
tuna https://pypi.tuna.tsinghua.edu.cn/simple
douban http://pypi.douban.com/simple/
aliyun https://mirrors.aliyun.com/pypi/simple/
ustc https://mirrors.ustc.edu.cn/pypi/web/simple
It can be seen that there are five domestic mirror sources
- pqi use :使用镜像源
(spider) E:\Document\programmLanguageExper\Python\ProjectFirst>pqi use tuna
Source is changed to tuna(https://pypi.tuna.tsinghua.edu.cn/simple).
- pqi use tuna 即把当前PyPiSource changed to Tsinghua UniversityPyPi源
- 现在输入pip命令就可以使用tunaMirror source for installationPython第三方库了
- 比如安装requests库
(spider) E:\Document\programmLanguageExper\Python\ProjectFirst>pip install requests;
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting requests
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/ca/91/6d9b8ccacd0412c08820f72cebaa4f0c0441b5cda699c90f618b6f8a1b42/requests-2.28.1-py3-none-any.whl (62 kB)
Requirement already satisfied: certifi>=2017.4.17 in d:\software\python\anaconda3\envs\spider\lib\site-packages (from requests) (2022.6.15)
Collecting idna<4,>=2.5
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/04/a2/d918dcd22354d8958fe113e1a3630137e0fc8b44859ade3063982eacd2a4/idna-3.3-py3-none-any.whl (61 kB)
Collecting charset-normalizer<3,>=2
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/94/69/64b11e8c2fb21f08634468caef885112e682b0ebe2908e74d3616eb1c113/charset_normalizer-2.1.0-py3-none-any.whl (39 kB)
Collecting urllib3<1.27,>=1.21.1
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/d1/cb/4783c8f1a90f89e260dbf72ebbcf25931f3a28f8f80e2e90f8a589941b19/urllib3-1.26.11-py2.py3-none-any.whl (139 kB)
---------------------------------------- 139.9/139.9 kB 693.4 kB/s eta 0:00:00
Installing collected packages: urllib3, idna, charset-normalizer, requests
Successfully installed charset-normalizer-2.1.0 idna-3.3 requests-2.28.1 urllib3-1.26.11
可以看到,现在pipInstalling third-party libraries is very fast.
This tutorial is over,I hope the tutorials in this article can be helpful to you.
边栏推荐
- Pulsar中游标的工作原理
- Concurrency tool class - introduction and use of CountDownLatch, CyclicBarrier, Semaphore, Exchanger
- flinkcdc 读取pgsql 的时间被放大了 有大佬知道咋回事吗 gmt_create':1
- 在vscode中屏蔽Alt热键
- Order table delete, insert and search operations
- 大佬们,运行cdc后oracle归档日志20分钟增长3G是正常现象吗
- 剑指Offer 033.变位数组
- 深度学习——循环神经网络RNN 未完待续
- How to improve product quality from the code layer
- 十年架构五年生活-07 年轻气盛的蜕变
猜你喜欢
随机推荐
Zhongang Mining: Strong downstream demand for fluorite
抽象问题方法论
You can‘t specify target table ‘kms_report_reportinfo‘ for update in FROM clause
leetcode每天5题-Day10
Attention candidates for the soft exam! The detailed registration process for the second half of 2022 is coming!
Abstract problem methodology
大佬们,运行cdc后oracle归档日志20分钟增长3G是正常现象吗
接口调试还能这么玩?
MySQL simple tutorial
Joomla漏洞复现
线程(下):读写者模型\环形队列\线程池
FPGA engineer interview questions collection 41~50
strongest brain (1)
【LeetCode】Day111-字母异位词分组
Stacks and Queues | Valid parentheses, delete all adjacent elements in a string, reverse Polish expression evaluation, maximum sliding window, top K high frequency elements | leecode brush questions
并发工具类——CountDownLatch、CyclicBarrier、Semaphore、Exchanger的介绍与使用
oracle rac 11g安装执行root.sh时报错
【静态代理】
[Thesis Notes] Prototypical Contrast Adaptation for Domain Adaptive Semantic Segmentation
Rpc interface stress test