conda虚拟环境的使用

昨天我们记录了如何安装conda和创建conda的虚拟环境,今天我们记录一下,怎么在conda的虚拟环境中,使用我们的对应的python框架。

 想要使用虚拟环境,首先我们要先激活这个虚拟环境,我们创建完这个虚拟环境之后,就已经显示了对应的命令行了:

# 激活虚拟环境 
# To activate this environment, use 
# $ conda activate playwright_tianmao 
# 若要退出环境 
# To deactivate an active environment, use 
# 
# $ conda deactivate
# 删除虚拟环境
# $ conda remove -p path --all# $ conda remove -n 虚拟环境名称 --all
我们激活一下我创建的虚拟环境: 
Last login: Fri Mar  3 11:26:47 on ttys000
(base) kaka@KakadeMacBook-Pro ~ % conda activate playwright_tianmao
(playwright_tianmao) kaka@KakadeMacBook-Pro ~ % 

 然后查看所有的虚拟环境:

(playwright_tianmao) kaka@KakadeMacBook-Pro ~ % conda env list
# conda environments:
#
base                     /Users/kaka/miniconda3
playwright_tianmao    *  /Users/kaka/miniconda3/envs/playwright_tianmao

(playwright_tianmao) kaka@KakadeMacBook-Pro ~ % 

然后,打开playwright官网,照着官网下载安装就可以。

pip install pytest-playwright

安装需要的浏览器:

playwright install

查看已安装的conda list:

(playwright_tianmao) kaka@KakadeMacBook-Pro ~ % conda list
# packages in environment at /Users/kaka/miniconda3/envs/playwright_tianmao:
#
# Name                    Version                   Build  Channel
attrs                     22.2.0                   pypi_0    pypi
bzip2                     1.0.8                h620ffc9_4  
ca-certificates           2023.01.10           hca03da5_0  
certifi                   2022.12.7       py310hca03da5_0  
charset-normalizer        3.0.1                    pypi_0    pypi
exceptiongroup            1.1.0                    pypi_0    pypi
greenlet                  2.0.1                    pypi_0    pypi
idna                      3.4                      pypi_0    pypi
iniconfig                 2.0.0                    pypi_0    pypi
libffi                    3.4.2                hca03da5_6  
ncurses                   6.4                  h313beb8_0  
openssl                   1.1.1t               h1a28f6b_0  
packaging                 23.0                     pypi_0    pypi
pip                       22.3.1          py310hca03da5_0  
playwright                1.31.1                   pypi_0    pypi
pluggy                    1.0.0                    pypi_0    pypi
pyee                      9.0.4                    pypi_0    pypi
pytest                    7.2.1                    pypi_0    pypi
pytest-base-url           2.0.0                    pypi_0    pypi
pytest-playwright         0.3.1                    pypi_0    pypi
python                    3.10.9               hc0d8a6c_1  
python-slugify            6.1.2                    pypi_0    pypi
readline                  8.2                  h1a28f6b_0  
requests                  2.28.2                   pypi_0    pypi
setuptools                65.6.3          py310hca03da5_0  
sqlite                    3.40.1               h7a7dc30_0  
text-unidecode            1.3                      pypi_0    pypi
tk                        8.6.12               hb8d0fd4_0  
tomli                     2.0.1                    pypi_0    pypi
typing-extensions         4.5.0                    pypi_0    pypi
tzdata                    2022g                h04d1e81_0  
urllib3                   1.26.14                  pypi_0    pypi
wheel                     0.38.4          py310hca03da5_0  
xz                        5.2.10               h80987f9_1  
zlib                      1.2.13               h5a0b063_0  
(playwright_tianmao) kaka@KakadeMacBook-Pro ~ %  

可以看到。我们的

playwright

已经安装好啦,然后就可以去配合pycharm使用啦:
注意,python的配置的要选择自己虚拟环境对应的运行配置:

 

 



 

posted @ 2023-03-03 11:43  爱家家的卡卡  阅读(315)  评论(0编辑  收藏  举报