栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

【技术随记03】

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

【技术随记03】

在ubantu20.04下安装anocoda 1.下载anconda

首先在以下镜像网站上下载,你想要的anconda安装包。
https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/
我这次选择的版本是Anaconda3-5.2.0-Linux-x86_64.sh

2.安装anconda

在下载的地方打开终端,然后运行.sh文件

bash Anaconda3-5.2.0-Linux-x86_64.sh

接下来就一路yes或者enter傻瓜式安装。
询问Do you wish the installer to initialize Anaconda3 by running conda init? [yes|no],这里是把conda添加到PATH中,让你能使用conda命令,所以这个直接yes。所以这里选择了yes后续就不需要手动修改.bashrc 文件配置环境变量了。

3.conda添加清华镜像源

添加以下镜像源

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --set show_channel_urls yes

或者在根目录下ls -a显示所有文件,sudo gedit ./.condarc,编辑添加清华镜像源,删除.condarc文件中的defaults

在ubantu20.04下创建虚拟环境[理想情况]

1.创建虚拟环境

conda create -n pyspark_env python=3.8

2.查看虚拟环境

conda env list

3.激活虚拟环境

conda activate pyspark_env

4.安装pyspark

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyspark 

5.测试

cd /export/server/spark/bin
./pyspark --master local[*]
出现的问题

问题1:用sudo gedit ~/.condarc,打开文件修改镜像源。但是终端会出现关于gedit的警告。

(gedit:3389): Tepl-WARNING **: 08:51:59.760: GVfs metadata is not supported. Fallback to TeplMetadataManager. Either GVfs is not correctly installed or GVfs metadata are not supported on this platform. In the latter case, you should configure Tepl with --disable-gvfs-metadata.

解决方案一:我看到有博客说:改完东西后,最后还要执行

source ~/.bashrc 

解决方案二,用vi编辑器去打开修改,其实上面也就是一个警告而已,不会有太大影响。
问题2:就是在配置镜像源,打算使用conda create -n pyspark_env python=3.8创建虚拟环境的第一步就会出现这个问题,后期再解决吧!

Solving environment: failed

CondaHTTPError: HTTP 000 CONNECTION FAILED for url 
Elapsed: -

An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.
SSLError(MaxRetryError('HTTPSConnectionPool(host='mirrors.bfsu.edu.cn', port=443): Max retries exceeded with url: /anaconda/cloud/conda-forge/linux-64/repodata.json (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')])")))'))

参考了另外一篇博客https://blog.csdn.net/qq_31878083/article/details/122069771
方法简单来说就是
原本以为是清华镜像源的问题,但是后面更换了很多个源都没有解决。最后把channels里面的https改成http,这样就可以了。这个是网络安全的原因,https协议是有安全性的ssl加密传输协议,是浏览器和服务器之间的通信加密,这样来确保传输的安全。
最后我的condarc文件内容修改如下:

channels:
 - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
 - http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
show_channel_urls: true

成功的结果给大家看一下:

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/840768.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号