配置服务器:Linux 使用 conda 我所遇到的所有坑

简介: 配置服务器:Linux 使用 conda 我所遇到的所有坑

配置服务器:Linux 使用 conda 我所遇到的所有坑


熟悉三妹的小伙伴可能知道,三妹最近跳槽到了互联网,成为了 BAT 中的一个小小程序媛,因此 Mac 呀、服务器呀都是新的,如同一张白纸要被我配置成我喜欢的样子。

坦白说,我是相当不喜欢配置服务器环境的,坑太多。

但是,作为21世纪新时代程序媛,天不怕地不怕,坚决不能被 bug 打倒。

服务器基本上都是一个套路,大家共用一个服务器,但是每个人都有自己的路径,只能在有权限的路径下为所欲为,当然了,配置的东西也只限于自己用。

所以,本文记录了我配置服务器过程中,遇到的所有坑以及我如何最终填上坑的。

我目前接触到的项目是用 TensorFlow 训练模型,所以整体的配置服务器思路为:

安装 conda -> 新建虚拟环境 -> 安装 TensorFlow 和Python 等包。

一、安装 conda

1、Conda 官网

Installing on Linux — conda 4.10.3.post41+bc22d85c documentation

我其实做了两手准备,一个是使用 wget 命令直接在服务器安装,第二个是先把相应的包下载到 Mac 本地,再用 scp 命令传到服务器(公司限制,已经不能使用我最爱的 FileZilla 了,悲伤。。。)

所以第二种方法中提到的 Linux 版本的 Conda,就在上面的链接里下载就好。

2、官网地址的链接使用 wget 命令安装太慢,有没有啥办法?

答:有~ 可以使用清华大学镜像站中 Anaconda 的所有版本的网址:

https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/  

找到自己想要的那个版本,然后右键复制链接地址,之后在服务器端新建一个目录,比如我就叫它 conda,进入 conda 文件夹后,wget + 复制好的地址,运行即可。

 

如:

wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2021.05-Linux-x86_64.sh

3、坑

好吧,我就知道不可能这么顺利的让我安装成功。

坑 1:

ERROR: cannot verify mirrors.tuna.tsinghua.edu.cn's certificate, issued by ‘/C=US/O=Let's Encrypt/CN=R3’:
  Issued certificate has expired.
To connect to mirrors.tuna.tsinghua.edu.cn insecurely, use `--no-check-certificate'.

上面报错的意思是:

连接到 mirrors.tuna.tsinghua.edu.cn 不安全,使用“不检查证书”,即在 wget 后加入no-check-certificate 即可解决。

坑 2:

Anaconda3-2021.05-Linux-x86_64.sh: Permission denied
Cannot write to ‘Anaconda3-2021.05-Linux-x86_64.sh’ (Success).

上面报错的意思是:

普通用户没有写入权限。应该切换到该用户家目录下,用户具有写入权限。

好吧,我切换, cd /home/自己路径。

坑 2 解决。

经过上述两个问题,我成功的下载了 Conda,效果如下:

4、bash 命令

安装好了 .sh 脚本之后需要运行,命令如下:

bash Anaconda3-2021.05-Linux-x86_64.sh

会出现如下:

Welcome to Anaconda3 2021.05
In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue

按照要求点击回车键就行。

===================================
End User License Agreement - Anaconda Individual Edition
===================================
Copyright 2015-2021, Anaconda, Inc.
All rights reserved under the 3-clause BSD License:
This End User License Agreement (the "Agreement") is a legal agreement between y
ou and Anaconda, Inc. ("Anaconda") and governs your use of Anaconda Individual E
dition (which was formerly known as Anaconda Distribution).
Subject to the terms of this Agreement, Anaconda hereby grants you a non-exclusi
ve, non-transferable license to:
  * Install and use the Anaconda Individual Edition (which was formerly known as
 Anaconda Distribution),
  * Modify and create derivative works of sample source code delivered in Anacon
da Individual Edition from Anaconda's repository; and
  * Redistribute code files in source (if provided to you by Anaconda as source)
 and binary forms, with or without modification subject to the requirements set
forth below.
Anaconda may, at its option, make available patches, workarounds or other update
s to Anaconda Individual Edition. Unless the updates are provided with their sep
arate governing terms, they are deemed part of Anaconda Individual Edition licen
sed to you as provided in this Agreement. This Agreement does not entitle you to
 any support for Anaconda Individual Edition.
Anaconda reserves all rights not expressly granted to you in this Agreement.
Redistribution and use in source and binary forms, with or without modification,
 are permitted provided that the following conditions are met:
  * Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
  * Redistributions in binary form must reproduce the above copyright notice, th
is list of conditions and the following disclaimer in the documentation and/or o
--More--

上述这一坨,就不停点击 空格键 就行。

You must comply with all domestic and international export laws and regulations
that apply to the software, which include restrictions on destinations, end user
s, and end use. Anaconda Individual Edition includes cryptographic software. The
 country in which you currently reside may have restrictions on the import, poss
ession, use, and/or re-export to another country, of encryption software. BEFORE
 using any encryption software, please check your country's laws, regulations an
d policies concerning the import, possession, or use, and re-export of encryptio
n software, to see if this is permitted. See the Wassenaar Arrangement http://ww
w.wassenaar.org/ for more information.
Anaconda has self-classified this software as Export Commodity Control Number (E
CCN) 5D992.c, which includes mass market information security software using or
performing cryptographic functions with asymmetric algorithms. No license is req
uired for export of this software to non-embargoed countries.
The Intel Math Kernel Library contained in Anaconda Individual Edition is classi
fied by Intel as ECCN 5D992.c with no license required for export to non-embargo
ed countries.
The following packages listed on https://www.anaconda.com/cryptography are inclu
ded in the repository accessible through Anaconda Individual Edition that relate
 to cryptography.
Last updated April 5, 2021
Do you accept the license terms? [yes|no]
[no] >>> yes

上面这个步骤,都不用问,肯定写 yes 呀,不然费这么大劲安装是因为工作量不饱和吗?

Anaconda3 will now be installed into this location:
*************
  - Press ENTER to confirm the location
  - Press CTRL-C to abort the installation
  - Or specify a different location below

上边的 ************* 是我伪装的打码,其实就是问题把 Anaconda3 安装在下边路径行不行,行的话就按回车键。

Preparing transaction: done
Executing transaction: done
installation finished.
Do you wish the installer to initialize Anaconda3
by running conda init? [yes|no]
[no] >>> yes

安装好了初始化一下,继续无脑填 yes。

==> For changes to take effect, close and re-open your current shell. <==
If you'd prefer that conda's base environment not be activated on startup,
   set the auto_activate_base parameter to false:
conda config --set auto_activate_base false
Thank you for installing Anaconda3!

最后,重启终端就行啦。

补充:

升级 conda 版本:

conda update -n base -c defaults conda

二、创建虚拟环境

1、检查已有虚拟环境

conda env list

2、创建虚拟环境

conda create -n tensorflow_dev

坑 3:

一开始使用下边命令:

conda env create -n tensorflow_dev

报错:

SpecNotFound: Invalid name, try the format: user/package

去掉 env 即可。

3、启动虚拟环境

conda activate tensorflow_dev

4、安装包

conda install 包名

还可以指定版本:

conda install python=3.8

5、退出虚拟环境

conda deactivate

P.S. 我竟然才知道 Linux 图标是它:

相关文章
|
弹性计算 ice
阿里云4核8G云服务器配置价格:热门ECS实例及CPU处理器型号说明
阿里云2025年4核8G服务器配置价格汇总,涵盖经济型e实例、计算型c9i等热门ECS实例,CPU含Intel Xeon及AMD EPYC系列,月费159元起,年付低至1578元,按小时计费0.45元起,实际购买享折扣优惠。
4495 1
|
弹性计算 定位技术 数据中心
阿里云服务器配置选择方法:付费类型、地域及CPU内存配置全解析
阿里云服务器怎么选?2025最新指南:就近选择地域,降低延迟;长期使用选包年包月,短期灵活选按量付费;企业选2核4G5M仅199元/年,个人选2核2G3M低至99元/年,高性价比爆款推荐,轻松上云。
1466 11
|
存储 Linux 开发工具
Linux环境下使用Buildroot配置软件包
使用Buildroot可以大大简化嵌入式Linux系统的开发和维护工作,但它需要对Linux系统和交叉编译有深入的理解。通过上述步骤,可以有效地配置和定制软件包,为特定的嵌入式应用构建高效、稳定的系统。
1524 11
|
存储 弹性计算 网络协议
超详细的阿里云服务器购买流程,ECS自定义购买配置教程
本文详细图解阿里云ECS服务器自定义购买全流程,涵盖付费模式、地域选择、网络配置、实例规格、镜像、存储、安全组及登录设置等核心步骤,助您轻松掌握专业级云服务器搭建方法。
|
存储 弹性计算 监控
阿里云渠道商:如何挑选阿里云服务器配置?
本文详解通用型、计算型、内存型等实例适用场景,结合性能评估与成本优化策略,助力用户按需选择。以日均1万访问企业网站为例,2核4G+3M带宽月费约200元,性价比高。合理配置更省钱。
|
弹性计算
阿里云ECS云服务器8核16G配置收费价格,多种ECS实例CPU及费用清单
阿里云8核16G云服务器价格因实例类型而异。计算型c9i约743元/月,一年6450元(7折);通用算力型u1仅673元/月,一年4225元(5.1折)。实际价格享时长折扣,详情见ECS官网。
|
弹性计算 Windows
阿里云香港服务器收费价格:香港ECS和轻量应用服务器配置介绍
2025年阿里云香港服务器优惠汇总:ECS 2核4G+5M带宽仅199元/年;轻量服务器30M带宽24元/月起,200M峰值带宽25元/月起。轻量性价比高,适合个人及中小企业建站、跨境业务,具体配置价格详见官方活动页。
6447 1
|
弹性计算 定位技术 数据中心
阿里云服务器选择方法:配置、地域及付费模式全解析
2025阿里云服务器选购指南:就近选择地域以降低延迟,企业用户优选2核4G5M带宽u1实例,仅199元/年;个人用户可选2核2G3M带宽ECS,99元/年起。长期稳定业务选包年包月,短期或波动场景用按量付费,轻松搭建网站首选高性价比配置。