Win10 和Win11 安装ubuntu和更换国内源,安装gfortran

搜集网上各类教程,把台式机和笔记本都搞定了

系统默认安装路径为C:\Users\%user_name%\AppData\Local\lxss,无法更改

在microsoft store中,搜索ubuntu,安装即可,会提示重启。

一般来说,这次开始菜单里打开ubuntu,会提示错误

Case 1:报错WslRegisterDistribution failed with error: 0x8007019e

Installing, this may take a few minutes...

Installation Failed! Error: 0x8007019e

Press any key to continue...

2.原因:未安装Windows子系统支持。

3.解决办法:

1.win+x,选择Windows PowerShell(管理员)

2.输入:Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

3.回车,输入Y,重启!

4.重新打开已经安装的子系统,等几分钟,输入账户和密码。

Case 2 win11 

对于win11,需要在win+X,打开powershell(管理员),输入wsl --set-default-version 1,回车

如果要运行WSL2,缺少WSL更新包

https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi

安装完成,开始使用

默认进入地址为/home/username

window系统内容在 /mnt/下, c d e f 正常操作即可。

运行fortran和python,但是资源包速度太慢,建议换源

Ubuntu系统中,软件源文件地址为:/etc/apt/sources.list

1.备份原来的源,将以前的源备份一下,以防以后可以用的。

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

2.打开/etc/apt/sources.list文件,在前面添加如下条目,并保存。

sudo vim /etc/apt/sources.list

(可将vim更换为自己熟悉的编辑器)

#添加阿里源

deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

#添加清华源

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse multiverse

3.更新

更新源

sudo apt-get update

如出现依赖问题,解决方式如下:

sudo apt-get -f install

更新软件:

sudo apt-get upgrade

如何安装gfortran,并可使用makefile,与服务器上一致

sudo apt-get install gcc
sudo apt-get install build-ensential
sudo apt-get install gfortran 

安装完成后,可以检查版本

gcc -v
g++ -v
gfortran -v

如果需要使用netcdf文件,输入ncdump,会提示如何安装

隐约记得是sodu apt-get install netcdf-bin 之类的,挺人性化的,按提示操作即可

你可能感兴趣的:(Fortran,ubuntu,linux,windows,fortran)