0

安装大全

 2 years ago
source link: https://www.codewoody.com/posts/16233/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

这篇文章主要记录各种工具软件的安装方法,供后续查阅。此文长期更新。

1 Python3 安装方法

1.1 Python 3 安装

参考:https://computingforgeeks.com/how-to-install-python-on-ubuntu-linux-system/

安装明令如下:

sudo apt install software-properties-common -y
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install -y python3.10

除了安装 Python3 本身之外,还需要安装 Python-pip

sudo apt install -y python3-pip

1.2 Pip 国内镜像配置

参考链接:https://www.runoob.com/w3cnote/pip-cn-mirror.html

我们可以通过 -i 选项在单个 Pip 命令中指定源地址,例如:

pip3 install numpy -i https://pypi.tuna.tsinghua.edu.cn/simple

如果要对当前用户进行全局配置,需要创建目录 ~/.pip 并创建文件(如果不存在) ~/.pip/pip.conf

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = https://pypi.tuna.tsinghua.edu.cn

可以通过 pip3 config list 命令查看当前镜像配置:

$ pip3 config list
global.index-url='https://pypi.tuna.tsinghua.edu.cn/simple'
install.trusted-host='https://pypi.tuna.tsinghua.edu.cn'

1.3 Python3 虚拟环境

参考链接:https://segmentfault.com/a/1190000014935970

安装 virtualenvwrapper

sudo pip3 install virtualenvwrapper

这个包也会一并安装上 virtualenv。

然后我们需要再当前 shell 的配置的文件中(.zshrc 或者 .bashrc,取决于你用的 shell 类型),在其中加入:

export VIRTUALENVWRAPPER_PYTHON=$(which python3)
# 打开终端自动启用
source /usr/local/bin/virtualenvwrapper.sh

使用 mkvirtualenv 明令创建虚拟环境,并通过 --python 选项设置 Python 的版本:

mkvirtualenv test --python=python3

1.4 常见问题

  1. Pip 安装时出现 ModuleNotFoundError: No module named 'distutils.cmd' 错误、

安装依赖:

sudo apt install -y python3-distutils

如果存在多个 Python 版本,可以指定更详细的依赖:

sudo apt install -y python3.10-distutils

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK