当前位置:网站首页>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.
边栏推荐
- 通过一个案例轻松入门OAuth协议
- 2022 T Elevator Repair Exam Questions and Mock Exams
- `id` bigint(20) unsigned NOT NULL COMMENT '数据库主键',
- Hezhou ESP32C3 +1.8"tft network clock under Arduino framework
- 十年架构五年生活-06 离职的冲动
- FPGA engineer interview questions collection 31~40
- 转型做产品,考NPDP靠谱吗?
- pytorch 学习
- canvas 画布绘制时钟
- I have a dream for Career .
猜你喜欢

【LeetCode】41. The first missing positive number

oracle rac 11g安装执行root.sh时报错

Pulsar中游标的工作原理

2022 security officer C certificate test and simulation test in shandong province

Rpc interface stress test

通过一个案例轻松入门OAuth协议

什么是“大小端字节序”存储模式?

Order table delete, insert and search operations

文献 | 关于心理活动符号学,你知道多少?

2022 T Elevator Repair Exam Questions and Mock Exams
随机推荐
线程(下):读写者模型\环形队列\线程池
一文带你搞懂OAuth2.0
Nexus_仓库类型
Introduction to curl command
【Pei Shu Theorem】CF1055C Lucky Days
【无标题】
Become a language that hackers have to learn. Do you think it's okay after reading it?
oracle rac 11g安装执行root.sh时报错
咨询cdc 2.0 for mysql不执行flush with read lock.怎么保证bin
The time for flinkcdc to read pgsql is enlarged. Does anyone know what happened? gmt_create':1
leetcode每天5题-Day10
I have a dream for Career .
解决“#231-D declaration is not visible outside of function”告警方法
2022 T Elevator Repair Exam Questions and Mock Exams
Linear Algebra (4)
剑指Offer 033.变位数组
OAuth2的使用场景、常见误区、使用案例
FPGA工程师面试试题集锦31~40
Ask you guys.The FlinkCDC2.2.0 version in the CDC community has a description of the supported sqlserver version, please
canvas 画布绘制时钟