conda安装opencv
conda install -c menpo opencv
conda批量导出包含环境中所有组件的requirements.txt文件
conda list -e > d:\requirements.txt
conda安装三方包的镜像源地址保存在这里:
C:\Users\Administrator\.condarc
**- *channels:
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64/
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/win-64/
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64/
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64/
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
- defaults*
show_channel_urls: true
ssl_verify: true
auto_activate_base: true
default_python:**
将gitHub中的代码下载到本地:
- 新建一个文件夹
- 右键->git bash here
- git clone https://github.com/***/***.git (如果下载速度太慢了,看这里:https://zhuanlan.zhihu.com/p/102409790)
python调用opencv中的cv2.imread() 和cv2.imwrite()对于中文路径不兼容,修改为如下方式:
## 读取图像,解决imread不能读取中文路径的问题
#filePath和filename:图片的全路径(读取、保存)
def cv_imread(filePath):
cv_img=cv2.imdecode(np.fromfile(filePath,dtype=np.uint8),-1)
## imdecode读取的是rgb,如果后续需要opencv处理的话,需要转换成bgr,转换后图片颜色会变化
##cv_img=cv2.cvtColor(cv_img,cv2.COLOR_RGB2BGR)
return cv_img
cv2.imencode('.jpg', img)[1].tofile(filename)
问题描述
在用conda创建的虚拟环境中,使用pip安装包,包仍被安装到全局,或者显示权限不足。
问题查找
使用which pip会发现使用的pip仍为全局路径下的pip
解决方案:在虚拟环境下运行以下代码
python -m pip install <package>
eg:
python -m pip install tqdm