2021年11月7日 20:54 by wst
anaconda昨天帮同事解决问题,在装airtest的过程中,老是不成功。
使用的环境为conda,操作系统为win10-64bit的。
由于中间有过很多次修改,已记不清channels被改成啥样了。
解决问题的步骤如下:
1查看conda信息:
C:\Users\dell>conda info
Current conda install:
platform : win-64
conda version : 4.3.30
conda is private : False
conda-env version : 4.3.30
conda-build version : 2.0.2
python version : 3.5.2.final.0
requests version : 2.14.2
root environment : d:\Program Files\Anaconda3 (writable)
default environment : d:\Program Files\Anaconda3
envs directories : d:\Program Files\Anaconda3\envs
C:\Users\dell\AppData\Local\conda\conda\envs
C:\Users\dell\.conda\envs
package cache : d:\Program Files\Anaconda3\pkgs
C:\Users\dell\AppData\Local\conda\conda\pkgs
channel URLs : https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/win-64
https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/noarch
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/noarch
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/noarch
https://conda.anaconda.org/'https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/'/win-64
https://conda.anaconda.org/'https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/'/noarch
https://conda.anaconda.org/'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/'/win-64
https://conda.anaconda.org/'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/'/noarch
https://repo.continuum.io/pkgs/main/win-64
https://repo.continuum.io/pkgs/main/noarch
https://repo.continuum.io/pkgs/free/win-64
https://repo.continuum.io/pkgs/free/noarch
https://repo.continuum.io/pkgs/r/win-64
https://repo.continuum.io/pkgs/r/noarch
https://repo.continuum.io/pkgs/pro/win-64
https://repo.continuum.io/pkgs/pro/noarch
https://repo.continuum.io/pkgs/msys2/win-64
https://repo.continuum.io/pkgs/msys2/noarch
config file : C:\Users\dell\.condarc
netrc file : None
offline mode : False
user-agent : conda/4.3.30 requests/2.14.2 CPython/3.5.2 Windows/10 Windows/10.0.19041
administrator : False
C:\Users\dell>conda config --remove channels "https://conda.anaconda.org/'https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/'/win-64"
CondaKeyError: 'channels': "https://conda.anaconda.org/'https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/'/win-64" is not in the 'channels' key of the config file
通过查看channels URL发现有些地址不正常。于是想能不删掉错误的地址。
2列出已有的channel
C:\Users\dell>conda config --get channels
--add channels 'defaults' # lowest priority
--add channels "'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/'"
--add channels "'https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/'"
--add channels 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/'
--add channels 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/'
--add channels 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/' # highest priority
3 删除错误的channel
C:\Users\dell>conda config --remove channels "'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/'"
C:\Users\dell>conda config --remove channels "'https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/'"
4 再次查看channel,发现已经正常
C:\Users\dell>conda config --get channels
--add channels 'defaults' # lowest priority
--add channels 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/'
--add channels 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/'
--add channels 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/' # highest priority
5 查看info,发现已经正常
C:\Users\dell>conda info
Current conda install:
platform : win-64
conda version : 4.3.30
conda is private : False
conda-env version : 4.3.30
conda-build version : 2.0.2
python version : 3.5.2.final.0
requests version : 2.14.2
root environment : d:\Program Files\Anaconda3 (writable)
default environment : d:\Program Files\Anaconda3
envs directories : d:\Program Files\Anaconda3\envs
C:\Users\dell\AppData\Local\conda\conda\envs
C:\Users\dell\.conda\envs
package cache : d:\Program Files\Anaconda3\pkgs
C:\Users\dell\AppData\Local\conda\conda\pkgs
channel URLs : https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/win-64
https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/noarch
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/noarch
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/noarch
https://repo.continuum.io/pkgs/main/win-64
https://repo.continuum.io/pkgs/main/noarch
https://repo.continuum.io/pkgs/free/win-64
https://repo.continuum.io/pkgs/free/noarch
https://repo.continuum.io/pkgs/r/win-64
https://repo.continuum.io/pkgs/r/noarch
https://repo.continuum.io/pkgs/pro/win-64
https://repo.continuum.io/pkgs/pro/noarch
https://repo.continuum.io/pkgs/msys2/win-64
https://repo.continuum.io/pkgs/msys2/noarch
config file : C:\Users\dell\.condarc
netrc file : None
offline mode : False
user-agent : conda/4.3.30 requests/2.14.2 CPython/3.5.2 Windows/10 Windows/10.0.19041
administrator : False
6升级pip
python -m pip install --upgrade pip
猜测airtest安装不成功和pip的版本有关系
7再次安装airtest, 成功
(auto_env) C:\Users\dell>pip install airtest
Collecting airtest
Using cached airtest-1.2.3.tar.gz (20.4 MB)
Preparing metadata (setup.py) ... done
Requirement already satisfied: Jinja2>=2.8 in d:\program files\anaconda3\envs\auto_env\lib\site-packages (from airtest) (3.0.2)
Requirement already satisfied: Pillow>=3.4.0 in d:\program files\anaconda3\envs\auto_env\lib\site-packages (from airtest) (8.4.0)
Requirement already satisfied: requests>=2.11.1 in d:\program files\anaconda3\envs\auto_env\lib\site-packages (from airtest) (2.26.0)
Requirement already satisfied: six in d:\program files\anaconda3\envs\auto_env\lib\site-packages (from airtest) (1.16.0)
Requirement already satisfied: mss==4.0.3 in d:\program files\anaconda3\envs\auto_env\lib\site-packages (from airtest) (4.0.3)
Requirement already satisfied: numpy<=1.19.3 in d:\program files\anaconda3\envs\auto_env\lib\site-packages (from airtest) (1.19.3)
Requirement already satisfied: opencv-contrib-python in d:\program files\anaconda3\envs\auto_env\lib\site-packages (from airtest) (3.2.0.7)
Requirement already satisfied: facebook-wda>=1.3.3 in d:\program files\anaconda3\envs\auto_env\lib\site-packages (from airtest) (1.4.3)
Collecting pywinauto==0.6.3
Using cached pywinauto-0.6.3.zip (515 kB)
Preparing metadata (setup.py) ... done
Collecting pywin32
Using cached pywin32-302-cp36-cp36m-win_amd64.whl (11.5 MB)
Requirement already satisfied: comtypes in d:\program files\anaconda3\envs\auto_env\lib\site-packages (from pywinauto==0.6.3->airtest) (1.1.10)
Collecting pypiwin32
Using cached pypiwin32-223-py3-none-any.whl (1.7 kB)
Requirement already satisfied: Deprecated~=1.2.6 in d:\program files\anaconda3\envs\auto_env\lib\site-packages (from facebook-wda>=1.3.3->airtest) (1.2.13)
Requirement already satisfied: retry in d:\program files\anaconda3\envs\auto_env\lib\site-packages (from facebook-wda>=1.3.3->airtest) (0.9.2)
Requirement already satisfied: cached-property~=1.5.1 in d:\program files\anaconda3\envs\auto_env\lib\site-packages (from facebook-wda>=1.3.3->airtest) (1.5.2)
Requirement already satisfied: MarkupSafe>=2.0 in d:\program files\anaconda3\envs\auto_env\lib\site-packages (from Jinja2>=2.8->airtest) (2.0.1)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in d:\program files\anaconda3\envs\auto_env\lib\site-packages (from requests>=2.11.1->airtest) (1.26.7)
Requirement already satisfied: charset-normalizer~=2.0.0 in d:\program files\anaconda3\envs\auto_env\lib\site-packages (from requests>=2.11.1->airtest) (2.0.7)
Requirement already satisfied: certifi>=2017.4.17 in d:\program files\anaconda3\envs\auto_env\lib\site-packages (from requests>=2.11.1->airtest) (2021.10.8)
Requirement already satisfied: idna<4,>=2.5 in d:\program files\anaconda3\envs\auto_env\lib\site-packages (from requests>=2.11.1->airtest) (3.3)
Requirement already satisfied: wrapt<2,>=1.10 in d:\program files\anaconda3\envs\auto_env\lib\site-packages (from Deprecated~=1.2.6->facebook-wda>=1.3.3->airtest) (1.13.3)
Requirement already satisfied: py<2.0.0,>=1.4.26 in d:\program files\anaconda3\envs\auto_env\lib\site-packages (from retry->facebook-wda>=1.3.3->airtest) (1.11.0)
Requirement already satisfied: decorator>=3.4.2 in d:\program files\anaconda3\envs\auto_env\lib\site-packages (from retry->facebook-wda>=1.3.3->airtest) (5.1.0)
Building wheels for collected packages: airtest, pywinauto
Building wheel for airtest (setup.py) ... done
Created wheel for airtest: filename=airtest-1.2.3-py3-none-any.whl size=20653032 sha256=2b3528924e0d2c2984a8c835be44e38eaa0072132187224760f19c9374fb7d4a
Stored in directory: c:\users\dell\appdata\local\pip\cache\wheels\ae\66\ff\496af7a94ff5fd98083752de1dde507fcc419611b868b2fb36
Building wheel for pywinauto (setup.py) ... done
Created wheel for pywinauto: filename=pywinauto-0.6.3-py3-none-any.whl size=355372 sha256=02ca15370e9e28490b4bc831321fd57b2d49e5337ecd24a9865a5b865416cddd
Stored in directory: c:\users\dell\appdata\local\pip\cache\wheels\4f\00\ef\c6921b9d856a6e4aa81fe0a262987aed00a046fc7bc3215b37
Successfully built airtest pywinauto
Installing collected packages: pywin32, pypiwin32, pywinauto, airtest
Successfully installed airtest-1.2.3 pypiwin32-223 pywin32-302 pywinauto-0.6.3
总结
包安装不成功,大概和如下因素有关:
1. conda 源有问题;
2. pip 版本太低
通过这个过程,我们同时掌握了channels的查看、添加和删除技巧;
anaconda快速下载方法:
wget --user-agent="Mozilla" https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2024.02-1-Linux-x86_64.sh
要在不同机器之间迁移conda环境,可以使用以下步骤:
在源机器上激活并导出环境:
conda activate myenv
conda env export > environment.yml
这会在当前目录下创建一个environment.yml
文件,其中包含了当前环境的所有依赖关系。
将environment.yml
文件复制到目标机器上。
在目标机器上使用以下命令来创建一个新环境:
conda env create -f environment.yml
这会在目标机器上创建一个与源机器上的环境相同的环境。
注意:
如果目标机器上已经有了相同名称的环境,它会被覆盖。
如果有特定于操作系统的依赖关系或路径,可能需要在不同机器上调整environment.yml
文件。
如果目标机器上缺少某些包,可能需要手动安装或者修改environment.yml
文件来指定适合目标机器的包版本。