Centos7安装minnconda和常用命令

下载

mkdir -p ~/miniconda3
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
rm ~/miniconda3/miniconda.sh


使用

常用命令

source ~/miniconda3/bin/activate
conda --version

conda install package_name 例如:conda install numpy

conda install package_name=versio 例如:conda install numpy=1.18.1

conda update package_name例如: conda update numpy

conda remove package_name # 例如:conda remove numpy

conda list

conda env list

conda create --name new_env_name --clone old_env_name

conda activate new_env

conda search python

虚拟环境

conda create --name makeimg python=3.12

The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    expat-2.6.3                |       h6a678d5_0         176 KB
    openssl-3.0.15             |       h5eee18b_0         5.2 MB
    python-3.12.5              |       h5148396_1        34.6 MB
    wheel-0.44.0               |  py312h06a4308_0         141 KB
    ------------------------------------------------------------
                                           Total:        40.1 MB

The following NEW packages will be INSTALLED:

  _libgcc_mutex      pkgs/main/linux-64::_libgcc_mutex-0.1-main 
  _openmp_mutex      pkgs/main/linux-64::_openmp_mutex-5.1-1_gnu 
  bzip2              pkgs/main/linux-64::bzip2-1.0.8-h5eee18b_6 
  ca-certificates    pkgs/main/linux-64::ca-certificates-2024.7.2-h06a4308_0 
  expat              pkgs/main/linux-64::expat-2.6.3-h6a678d5_0 
  ld_impl_linux-64   pkgs/main/linux-64::ld_impl_linux-64-2.38-h1181459_1 
  libffi             pkgs/main/linux-64::libffi-3.4.4-h6a678d5_1 
  libgcc-ng          pkgs/main/linux-64::libgcc-ng-11.2.0-h1234567_1 
  libgomp            pkgs/main/linux-64::libgomp-11.2.0-h1234567_1 
  libstdcxx-ng       pkgs/main/linux-64::libstdcxx-ng-11.2.0-h1234567_1 
  libuuid            pkgs/main/linux-64::libuuid-1.41.5-h5eee18b_0 
  ncurses            pkgs/main/linux-64::ncurses-6.4-h6a678d5_0 
  openssl            pkgs/main/linux-64::openssl-3.0.15-h5eee18b_0 
  pip                pkgs/main/linux-64::pip-24.2-py312h06a4308_0 
  python             pkgs/main/linux-64::python-3.12.5-h5148396_1 
  readline           pkgs/main/linux-64::readline-8.2-h5eee18b_0 
  setuptools         pkgs/main/linux-64::setuptools-72.1.0-py312h06a4308_0 
  sqlite             pkgs/main/linux-64::sqlite-3.45.3-h5eee18b_0 
  tk                 pkgs/main/linux-64::tk-8.6.14-h39e8969_0 
  tzdata             pkgs/main/noarch::tzdata-2024a-h04d1e81_0 
  wheel              pkgs/main/linux-64::wheel-0.44.0-py312h06a4308_0 
  xz                 pkgs/main/linux-64::xz-5.4.6-h5eee18b_1 
  zlib               pkgs/main/linux-64::zlib-1.2.13-h5eee18b_1 


Proceed ([y]/n)? y


Downloading and Extracting Packages:
                                                                                                                                                                                                                                                                                                        
Preparing transaction: done                                                                                                                                                                                                                                                                             
Verifying transaction: done                                                                                                                                                                                                                                                                             
Executing transaction: done                                                                                                                                                                                                                                                                             
#
# To activate this environment, use
#
#     $ conda activate makeimg
#
# To deactivate an active environment, use
#
#     $ conda deactivate

source ~/miniconda3/bin/activate conda activate makeimg

pip install 模块名 -i https://pypi.tuna.tsinghua.edu.cn/simple

conda deactivate

conda env remove -n makeimg

补充:centos7上直接安装python3.12

准备工作

yum groupinstall -y "Development Tools"
yum install -y openssl-devel bzip2-devel libffi-devel
mkdir /usr/local/python312

更新到openssl到1.1版本

openssl version
OpenSSL 1.0.2k-fips  26 Jan 2017
wget https://openssl.org/source/old/1.1.1/openssl-1.1.1w.tar.gz
#如果上面的地址不可用了,到这里找:https://openssl.org/source/old/1.1.1/index.html
tar -zxvf openssl-1.1.1w.tar.gz
cd openssl-1.1.1w/
./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl shared zlib
 make -j$(nproc)
 make install

报错:openssl: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory

ln -s /usr/local/openssl/lib/libssl.so.1.1 /usr/lib64/libssl.so.1.1
ln -s /usr/local/openssl/lib/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1
cd /usr/bin/
mv openssl openssl.bak2024
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
openssl version
OpenSSL 1.1.1w  11 Sep 2023

# 成功

安装python3.12

cd /usr/local/python312
wget https://www.python.org/ftp/python/3.12.6/Python-3.12.6.tar.xz
tar xvf Python-3.12.6.tar.xz
cd Python-3.12.6
 ./configure --enable-optimizations --with-openssl=/usr/local/openssl
 make -j$(nproc)
 make install  #make altinstall -->为了避免覆盖系统默认的 Python 版本。

 python3.12 --version

whereis pip
ln -s /usr/local/bin/pip3.12 /usr/local/bin/pip3


pip3 install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple
>> Home

51ak

2024/09/12

Categories: centos python Tags: 整理

《数据库工作笔记》公众号
扫描上面的二维码,关注我的《数据库工作笔记》公众号