Anaconda 安装各种包遇到的一些坑(个人总结)

由于学习和做与神经网络和图像处理相关的项目和工作

[En]

Due to learning and doing projects and work related to neural network and image processing

一直在用Anaconda, 遇到了很多坑,想着不如把它们记录下来,也是挺好的

xlrd的坑

import pandas as pd
df = pd.read_excel('xx.xlsx')

会报错,提示找不到xlrd还是什么的
原因在于较高版本的xlrd不再支持xlsx格式, 很无语。。。。。。
较为好的 解决办法就是将.xlsx格式的excel表格另存为.xls格式的excel表格即可
当然,你也可以尝试将xlrd的版本降低一下,看看能不能用

安装Tensorflow的坑

https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
https://mirrors.ustc.edu.cn/anaconda/pkgs/free/

首先新建一个虚拟环境

conda create -n ML python=3.6

激活该环境

conda activate ML

安装tensorflow

conda install tensorflow

输出一下版本号


import tensorflow
print('tensorflow: %s' % tensorflow.__version__)

tensorflow: 1.14.0
但是报错了

FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.

  np_resource = np.dtype([("resource", np.ubyte, 1)])

查查原因,tensorflow和numpy版本不对应,导致了冲突
再查查两者关系
tensorflow: 1.14.0 对应numpy 1.16.0
然后先卸载numpy

conda uninstall numpy

再重装对应版本

conda install numpy==1.16.0

重新装tensorflow

conda install tensorflow

输出一下版本号
tensorflow:1.2.1
终于,我没有犯错,我可以开始工作了。

[En]

Finally, I didn’t make a mistake, and I can get to work.

然而,据说安装过程非常繁琐,各种错误报告导致心态爆炸。

[En]

However, it is said that the installation process is very tedious, and all kinds of error reports lead to mentality explosion.

呜呼哀哉,Tensorflow 狗看了都摇头

安装Pytorch

conda create -n pytorch python=3.7

激活环境

conda activate pytorch

安装Pytorch之前配置一下国内镜像源,速度快不用说

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/

Pytorch官网找安装命令

Anaconda 安装各种包遇到的一些坑(个人总结)
Anaconda 安装各种包遇到的一些坑(个人总结)
复制conda安装命令,本来回到Prompt中粘贴运行即可
但是会发现安装速度很慢,问题出在该命令最后的 -c pytorch
如果你不把还在使用的外源去掉,它自然会很慢。去掉后,用国内源码下载,直接起飞。
[En]

If you don’t get rid of the foreign source that is still used, it is naturally very slow. After you get rid of it, use the domestic source to download, and take off directly.

因此,最后命令如下

conda install pytorch torchvision torchaudio cudatoolkit=11.3

在Jupyter Notebook中使用Python虚拟环境

conda activate pytorch

为了让Jupyter Notebook支持虚拟运行环境,需要在Anaconda里安装一个插件

conda install nb_conda

开启Jupyter Notebook

创建的虚拟环境可以找到,并且可以愉快地使用。

[En]

The virtual environment created can be found and can be used happily.

Anaconda 安装各种包遇到的一些坑(个人总结)
jupyter notebook

测试一下装好的Pytorch,成功了

import torch
print(torch.__version__)

Anaconda 安装各种包遇到的一些坑(个人总结)
还是Pytorch香啊

Jupyter Notebook的坑

本来电脑默认浏览器是Edge浏览器,所以jupyter notebook默认在Edge浏览器打开

但是使用过程中发现老是崩溃,终端报错404 GET
简单来说 就是页面能正常打开,但是网页总是卡住,提示”网页没有影响”

上网搜索没有一个可靠的答案,认为换成谷歌浏览器运行会更好。

[En]

Searching the Internet does not have a reliable answer, thinking that it would be better to change to Google browser and run.

参考了这篇文章换的默认浏览器jupyter notebook更改默认打开浏览器

相反,它不存在任何坍塌问题。我是个好人。

[En]

On the contrary, it doesn’t have any collapse problem. I’m a good guy.

最后希望Edge浏览器能解决这个问题。

Original: https://blog.csdn.net/qq_41873311/article/details/122146756
Author: 爱学习的诸葛铁锤
Title: Anaconda 安装各种包遇到的一些坑(个人总结)

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/511566/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球