Ubuntu安装sagemath环境搭建

Ubuntu安装sagemath环境搭建

  • 实现Ubuntu篇Crypto常见工具

Ubuntu篇Crypto常见工具

  • Ubuntu 安装 conda

Ubuntu 安装 conda

  • pip 换源

pip 换源

  • Ubuntu 安装 sage

安装sagemath

  • ubuntu 22.04中安装和使用 sagemath

使用 sagemath

  • 扩充Ubuntu虚拟机的磁盘容量

扩充Ubuntu虚拟机的磁盘容量

  • GParted给ubuntu系统磁盘resize大小时候出现cannot resize read-only file system解决办法

解决办法

Ubuntu 安装 conda

安装 conda

# conda安装
wget https://mirrors.bfsu.edu.cn/anaconda/archive/Anaconda3-2023.03-Linux-x86_64.sh  --no-check-certificate

bash Anaconda3-2023.03-Linux-x86_64.sh

source ~/.bashrc

管理虚拟环境的命令

#查看当前存在哪些虚拟环境
conda env list 
conda info -e     #或 
conda info --envs #或 
#创建虚拟环境
conda create -n your_env_name python=X.X(3.63.7等)
#激活虚拟环境
source activate your_env_name(虚拟环境名称)
#退出虚拟环境
source deactivate your_env_name(虚拟环境名称)
#删除虚拟环境
conda remove -n your_env_name(虚拟环境名称) --all

# 举例
conda create -n py39 python=3.9
source activate py39
source deactivate py39

python包的管理命令

#查看安装了哪些包
conda list
#安装包
conda install package_name(包名)
conda install scrapy==1.3 # 安装指定版本的包
conda install -n 环境名 包名 # 在conda指定的某个环境中安装包
 
pip install -i http://mirrors.aliyun.com/pypi/simple Pillow

管理镜像源的命令

#检查更新当前conda
conda update conda
#更新anaconda
conda update anaconda
#更新所有库
conda update --all
#更新python
conda update python
#查看conda的源
conda config --show channels
#添加conda的源
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/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

pip的常用命令

管理镜像源的命令

# 升级pip
pip install pip -U
# 显示目前pip的数据源有哪些
pip config list
# 设置默认的全局镜像源
pip config --global set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple/
pip config --global set install.trusted-host mirrors.aliyun.com
# 临时下载
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple xxx-package  
#删除
pip config unset key
#例如
pip config unset global.index-url
pip config unset global.trusted-host

#搜索
pip search flask  # 搜素flask安装包
# 安装一次
pip install --index-url https://pypi.tuna.tsinghua.edu.cn/simple/ oracle
pip install --index-url https://mirrors.aliyun.com/pypi/simple/ oracle

管理python包的命令

pip list #列出当前缓存的包
pip purge #清除缓存
pip remove #删除对应的缓存
pip help #帮助
pip install xxx #安装xxx包
pip uninstall xxx #删除xxx包
pip show xxx #展示指定的已安装的xxx包
pip check xxx #检查xxx包的依赖是否合适 
pip freeze > requirements.txt  # pip批量导出包含环境中所有组件的requirements.txt文件
pip install -r requirements.txt # pip批量安装requirements.txt文件中包含的组件依赖
# 安装一次
pip install --index-url https://pypi.tuna.tsinghua.edu.cn/simple/ oracle
# pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple  PyQt5==5.15.4

Sagemath安装及使用

安装sagemath安装

安装sagemath

sudo -i
apt update
apt-get update
apt install sagemath

sage安装第三方库

sage安装第三方库

sage --pip install [第三方库]
sage --pip list

创建脚本

touch test.py
touch test.sage

运行脚本

sage test.py
sage test.sage

Sagemath使用

# sagemath
x = var('x')
factor(x^5 - 1)
# (x^4 + x^3 + x^2 + x + 1)*(x - 1)

# euler_phi 实现Euler的phi函数
phi = euler_phi(n)

# 把数字写成平方和的方法
n = x**2 + y**2
x,y = two_squares(n)
注分解网站:https://www.alpertron.com.ar/ECM.HTM

sagemath中文文档参见

sagemath源文档

Sage入门常见用法一个Blog

CSDNsagemath常用函数

  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值