专业编程基础技术教程

网站首页 > 基础教程 正文

语言教育项目实战之一:Ubuntu下安装Python环境

ccvgpt 2025-06-10 13:34:10 基础教程 5 ℃

如下项目,运行在#ubuntu#上,使用#pytho#,从最初环境开始,逐渐深入。此项目以语言学习为主要目的,实现听写、跟读、对话的服务,面向中小学生、大学生、涉外交流人员等。


语言教育项目实战之一:Ubuntu下安装Python环境

计划

通过pyenv管理不同版本的python,同一版本python环境使用python自带的venv来管理。

环境

这里使用的ubuntu版本24.04,如下所示。

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 24.04.2 LTS
Release:        24.04
Codename:       noble

安装pyenv的依赖

sudo apt update
sudo apt install -y build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python3-openssl git
curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash

修改.bash_profile,添加PATH环境参数

#!/bin/bash
set -o vi


# Load pyenv automatically by appending
# the following to
# ~/.bash_profile if it exists, otherwise ~/.profile (for login shells)
# and ~/.bashrc (for interactive shells) :

export PYENV_ROOT="$HOME/.pyenv"
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init - bash)"

# Restart your shell for the changes to take effect.

# Load pyenv-virtualenv automatically by adding
# the following to ~/.bashrc:

eval "$(pyenv virtualenv-init -)"

执行pyenv安装3.11.4的python版本

# 列出可以安装的python版本
 pyenv install --list
 pyenv install 3.11.4

创建coquis运行环境,#Coquis# #

mkdir -p code/tts/coquis/
cd code/tts/coquis
pyenv local 3.11.4 
python --version
pip --version
# 如果pip速度慢,可指定源 -i https://mirrors.aliyun.com/pypi/simple/
# 安装 PyTorch 2.3.1 + TTS 0.22.0 (严格版本锁定)
pip install torch==2.3.1 torchaudio==2.3.1 --index-url https://download.pytorch.org/whl/cpu
pip install TTS==0.22.0


下载模型,并测试#tts#coquis开源而且强大,是不错的选择

gauss@power-edge-r730:~/code/tts/coquis$ tts --model_name tts_models/multilingual/multi-dataset/xtts_v2 --text "hello ,你好!" --out_path hello.wav
 > You must confirm the following:
 | > "I have purchased a commercial license from Coqui: licensing@coqui.ai"
 | > "Otherwise, I agree to the terms of the non-commercial CPML: https://coqui.ai/cpml" - [y/n]
 | | > y
 > Downloading model to /home/gauss/.local/share/tts/tts_models--multilingual--multi-dataset--xtts_v2

如果速度很慢,可到镜像站下载后,将文件拷贝到上述目录。可只下载必需的文件,可从源码看到文件列表。


 wget https://hf-mirror.com/coqui/XTTS-v2/resolve/main/model.pth?download=true


问题:

  1. tranformers 版本升级造成的冲突
  1. 完整的pip list
$ pip list
Package                 Version
----------------------- -----------
absl-py                 2.2.2
aiohappyeyeballs        2.6.1
aiohttp                 3.11.18
aiosignal               1.3.2
annotated-types         0.7.0
anyascii                0.3.2
attrs                   25.3.0
audioread               3.0.1
babel                   2.17.0
bangla                  0.0.5
blinker                 1.9.0
blis                    1.2.1
bnnumerizer             0.0.2
bnunicodenormalizer     0.1.7
catalogue               2.0.10
certifi                 2025.4.26
cffi                    1.17.1
charset-normalizer      3.4.2
click                   8.1.8
cloudpathlib            0.21.1
confection              0.1.5
contourpy               1.3.2
coqpit                  0.0.17
cycler                  0.12.1
cymem                   2.0.11
Cython                  3.1.1
dateparser              1.1.8
decorator               5.2.1
docopt                  0.6.2
einops                  0.8.1
encodec                 0.1.1
filelock                3.13.1
Flask                   3.1.1
fonttools               4.58.0
frozenlist              1.6.0
fsspec                  2024.6.1
g2pkk                   0.1.2
grpcio                  1.71.0
gruut                   2.2.3
gruut-ipa               0.13.0
gruut_lang_de           2.0.1
gruut_lang_en           2.0.1
gruut_lang_es           2.0.1
gruut_lang_fr           2.0.2
hangul-romanize         0.1.0
huggingface-hub         0.31.4
idna                    3.10
inflect                 7.5.0
itsdangerous            2.2.0
jamo                    0.4.1
jieba                   0.42.1
Jinja2                  3.1.4
joblib                  1.5.0
jsonlines               1.2.0
kiwisolver              1.4.8
langcodes               3.5.0
language_data           1.3.0
lazy_loader             0.4
librosa                 0.11.0
llvmlite                0.44.0
marisa-trie             1.2.1
Markdown                3.8
markdown-it-py          3.0.0
MarkupSafe              2.1.5
matplotlib              3.10.3
mdurl                   0.1.2
more-itertools          10.7.0
mpmath                  1.3.0
msgpack                 1.1.0
multidict               6.4.4
murmurhash              1.0.12
networkx                2.8.8
nltk                    3.9.1
num2words               0.5.14
numba                   0.61.2
numpy                   1.26.4
packaging               25.0
pandas                  1.5.3
pillow                  11.2.1
pip                     25.1.1
platformdirs            4.3.8
pooch                   1.8.2
preshed                 3.0.9
propcache               0.3.1
protobuf                6.31.0
psutil                  7.0.0
pycparser               2.22
pydantic                2.11.4
pydantic_core           2.33.2
Pygments                2.19.1
pynndescent             0.5.13
pyparsing               3.2.3
pypinyin                0.54.0
pysbd                   0.3.4
python-crfsuite         0.9.11
python-dateutil         2.9.0.post0
pytz                    2025.2
PyYAML                  6.0.2
regex                   2024.11.6
requests                2.32.3
rich                    14.0.0
safetensors             0.5.3
scikit-learn            1.6.1
scipy                   1.15.3
setuptools              65.5.0
shellingham             1.5.4
six                     1.17.0
smart-open              7.1.0
soundfile               0.13.1
soxr                    0.5.0.post1
spacy                   3.8.6
spacy-legacy            3.0.12
spacy-loggers           1.0.5
srsly                   2.5.1
SudachiDict-core        20250515
SudachiPy               0.6.10
sympy                   1.13.3
tensorboard             2.19.0
tensorboard-data-server 0.7.2
thinc                   8.3.4
threadpoolctl           3.6.0
tokenizers              0.21.1
torch                   2.7.0+cpu
torchaudio              2.7.0+cpu
tqdm                    4.67.1
trainer                 0.0.36
transformers            4.49.0
TTS                     0.22.0
typeguard               4.4.2
typer                   0.15.4
typing_extensions       4.12.2
typing-inspection       0.4.1
tzlocal                 5.3.1
umap-learn              0.5.7
Unidecode               1.4.0
urllib3                 2.4.0
wasabi                  1.1.3
weasel                  0.4.1
Werkzeug                3.1.3
wrapt                   1.17.2
yarl                    1.20.0

最近发表
标签列表