WSL installation and WSL installation Ubuntu, WSL/Ubuntu installation anaconda3
Article directory
- WSL installation and WSL installation Ubuntu, WSL/Ubuntu installation anaconda3
- 1. wsl installation
-
- Problems that may arise
- 2. Install anaconda3 on WSL/Ubuntu
1. wsl installation
1. Win + R Enter winver to check whether the windows version can install wsl
2. Open the three options of Windows function: Enable Hyper-V, Windows Subsystem for Linux, and Virtual Machine Platform.
?
3. Run powershell with administrator rights and enter wsl –set-default-version 2
4. You can download wsl from the Microsoft store, download it from the wsl official website or download it through wsl –install -d Ubuntu-22.04
5. Edit vim interface
Enter
vim /etc/vim/vimrc
Just copy the code below and enter it!
You can also copy and paste directly in the Windows operation interface!
"""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""" " Show related """""""""""""""""""""""""""""""""""""""""""""""" """"""""""""""""""""""""""""""""""""""" "set shortmess=atI " does not display the prompt to assist Ugandan children when starting "winpos 5 5 " sets the window position "set lines=40 columns=155 " Set window size "set nu " displays line numbers set go= "No graphic buttons "color asmanian2 " Set background theme set guifont=Courier_New:h10:cANSI " Set font "syntax on " syntax highlighting autocmd InsertLeave * se nocul " Highlight the current line with a light color autocmd InsertEnter * se cul " Highlight the current line with a light color "set ruler "show ruler set showcmd "Display the entered command so you can see it more clearly. "set cmdheight=1 "The height of the command line (under the status line), set to 1 "set whichwrap + =<,>,h,l " allows backspace and cursor keys to cross line boundaries (not recommended) "set scrolloff=3 " maintain a distance of 3 lines when the cursor moves to the top and bottom of the buffer set novisualbell "Don't blink (don't understand) set statusline=%F%m%r%h%w\ [FORMAT=%{ & amp;ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ % {strftime("%d/%m/%y\ -\ %H:%M")} "Content displayed in the status line set laststatus=1 " Start displaying the status line (1), always display the status line (2) set foldenable "Allow folding set foldmethod=manual " Manual folding "set background=dark "use black for background set nocompatible "Remove the annoying vi consistency mode and avoid some bugs and limitations of previous versions "Show Chinese help if version >= 603 set helplang=cn set encoding=utf-8 endif " Set color scheme "colorscheme murphy "Font "if (has("gui_running")) " set guifont=Bitstream\ Vera\ Sans\ Mono\ 10 "endif set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936 set termencoding=utf-8 set encoding=utf-8 set fileencodings=ucs-bom,utf-8,cp936 set fileencoding=utf-8 """""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""" """""New file title""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""" """" "Create new .c, .h, .sh, .java files and automatically insert file headers autocmd BufNewFile *.cpp,*.[ch],*.sh,*.java exec ":call SetTitle()" ""Define the function SetTitle to automatically insert the file header func SetTitle() "If the file type is a .sh file if &filetype == 'sh' call setline(1,"\########################################## ##############################") call append(line("."), "\# File Name: ".expand("%")) call append(line(".") + 1, "\# Author: ma6174") call append(line(".") + 2, "\# mail: [email protected]") call append(line(".") + 3, "\# Created Time: ".strftime("%c")) call append(line(".") + 4, "\################################### ####################################") call append(line(".") + 5, "\#!/bin/bash") call append(line(".") + 6, "") else call setline(1, "/******************************************* ******************************") call append(line("."), " > File Name: ".expand("%")) call append(line(".") + 1, " > Author: ma6174") call append(line(".") + 2, " > Mail: [email protected] ") call append(line(".") + 3, " > Created Time: ".strftime("%c")) call append(line(".") + 4, " ************************************* *************************************/") call append(line(".") + 5, "") endif if &filetype == 'cpp' call append(line(".") + 6, "#include<iostream>") call append(line(".") + 7, "using namespace std;") call append(line(".") + 8, "") endif if &filetype == 'c' call append(line(".") + 6, "#include<stdio.h>") call append(line(".") + 7, "") endif "After creating a new file, it will automatically be positioned at the end of the file. autocmd BufNewFile * normal G endfunc """""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""" "" "Keyboard commands """""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""" "" nmap <leader>w :w!<cr> nmap <leader>f :find<cr> " Map select all + copy ctrl + a map <C-A> ggVGY map! <C-A> <Esc>ggVGY map <F12> gg=G "Ctrl + c to copy when selected vmap <C-c> " + y "Go to empty line nnoremap <F2> :g/^\s*$/d<CR> "Compare files nnoremap <C-F2> :vert diffsplit "New label map <M-F2> :tabnew<CR> "List files in the current directory map <F3> :tabnew .<CR> "Open the tree file directory map <C-F3> \be "C, C++ press F5 to compile and run map <F5> :call CompileRunGcc()<CR> func!CompileRunGcc() exec "w" if &filetype == 'c' exec "!g + + % -o %<" exec "! ./%<" elseif &filetype == 'cpp' exec "!g + + % -o %<" exec "! ./%<" elseif &filetype == 'java' exec "!javac %" exec "!java %<" elseif &filetype == 'sh' :!./% endif endfunc "Debugging in C,C++ map <F8> :call Rungdb()<CR> func!Rungdb() exec "w" exec "!g + + % -g -o %<" exec "!gdb ./%<" endfunc """""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""" "" ""Practical settings """""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""" " "Set up to automatically load files when they are modified set autoread "quickfix mode autocmd FileType c,cpp map <buffer> <leader><space> :w<cr>:make<cr> "Code completion set completeopt=preview,menu "Allow plugin filetype plugin on "Share clipboard set clipboard + =unnamed "Never back up set nobackup "make run :set makeprg=g + + \ -Wall\ \ % "Auto save set autowrite set ruler "Open the status bar ruler set cursorline " Highlight the current line set magic " set magic set guioptions-=T "Hide toolbar set guioptions-=m "Hide menu bar "set statusline=\ %<%F[%1*%M%*%n%R%H]%=\ %y\ %0(%{<!-- --> & amp;fileformat}\ %{ <!-- --> & amp;encoding}\ %c:%l/%L%)\ " Set the information displayed in the status line set foldcolumn=0 set foldmethod=indent set foldlevel=3 set foldenable " Start folding "Don't use vi's keyboard mode, but vim's own set nocompatible " syntax highlighting set syntax=on " Remove the prompt sound for input errors set noeb " When processing unsaved or read-only files, pop up a confirmation set confirm "Auto-indent set autoindent set cindent " Tab key width set tabstop=4 "Uniform indentation is 4 set softtabstop=4 set shiftwidth=4 " Do not use spaces instead of tabs set noexpandtab " Use tabs at the beginning of lines and paragraphs set smarttab "Display line number set number "Number of historical records set history=1000 "Prohibit the generation of temporary files set nobackup set noswapfile "Search ignores case set ignorecase "Search character by character highlighting sethlsearch set incsearch "Inline replacement set gdefault "Encoding settings set enc=utf-8 set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936 "language settings set langmenu=zh_CN.UTF-8 set helplang=cn " What my status line shows (including file type and decoding) "set statusline=%F%m%r%h%w\ [FORMAT=%{ & amp;ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime("%d/%m/%y\ -\ %H:%M")} "set statusline=[%F]%y%r%m%*%=[Line:%l/%L,Column:%c][%p%%] "Always show status line set laststatus=2 "The height of the command line (under the status line), the default is 1, here it is 2 set cmdheight=2 "Detect file type filetype on "Load file type plug-in filetype plugin on "Load the relevant indent file for a specific file type filetype indent on "Save global variables set viminfo + =! " Words with the following symbols should not be separated by newlines set iskeyword + =_,$,@,%,#,- "The number of pixel lines inserted between characters set linespace=0 " Command line autocomplete in enhanced mode set wildmenu " Make the backspace key handle indent, eol, start, etc. normally set backspace=2 "Allow backspace and cursor keys to cross line boundaries set whichwrap + =<,>,h,l " You can use the mouse anywhere in the buffer (similar to double-clicking the mouse in the workspace in office) set mouse=a set selection=exclusive set selectmode=mouse,key " Tell us which line of the file has been changed by using: commands command set report=0 " Display white space between divided windows for easier reading set fillchars=vert:\ ,stl:\ ,stlnc:\ " Highlight matching brackets set showmatch " Matching bracket highlighting time (unit is tenth of a second) set matchtime=1 " Keep the cursor 3 lines apart when moving to the top and bottom of the buffer set scrolloff=3 " Provide automatic indentation for C programs set smartindent " Highlight ordinary txt files (requires txt.vim script) au BufRead,BufNewFile * setfiletype txt "Autocomplete :inoremap ( ()<ESC>i :inoremap ) <c-r>=ClosePair(')')<CR> :inoremap {<!-- --> {<!-- --><CR>}<ESC>O :inoremap } <c-r>=ClosePair('}')<CR> :inoremap [ []<ESC>i :inoremap ] <c-r>=ClosePair(']')<CR> :inoremap " ""<ESC>i :inoremap ' ''<ESC>i function! ClosePair(char) if getline('.')[col('.') - 1] == a:char return "\<Right>" else return a:char endif endfunction filetype plugin indent on "Turn on file type detection. Only after adding this sentence can you use smart completion. set completeopt=longest,menu """""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""" "CTags settings """""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""" let Tlist_Sort_Type = "name" " Sort by name let Tlist_Use_Right_Window = 1 " Show the window on the right let Tlist_Compart_Format = 1 "Compression method let Tlist_Exist_OnlyWindow = 1 "If there is only one buffer, the kill window will also kill the buffer. let Tlist_File_Fold_Auto_Close = 0 "Do not close tags of other files let Tlist_Enable_Fold_Column = 0 "Do not display the folded tree autocmd FileType java set tags + =D:\tools\java\tags "autocmd FileType h,cpp,cc,c set tags + =D:\tools\cpp\tags "let Tlist_Show_One_File=1 "Do not display the tags of multiple files at the same time, only display the tags of the current file "Set tags set tags=tags "set autochdir """""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""" """"""""""""" " """""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""" """""""""""" "Open Taglist by default let Tlist_Auto_Open=1 """"""""""""""""""""""""""""" " Tag list (ctags) """"""""""""""""""""""""""""""" let Tlist_Ctags_Cmd = '/usr/bin/ctags' let Tlist_Show_One_File = 1 "Do not display the tags of multiple files at the same time, only display the tags of the current file let Tlist_Exit_OnlyWindow = 1 "If the taglist window is the last window, exit vim let Tlist_Use_Right_Window = 1 "Display the taglist window in the right window "General settings of the minibufexpl plug-in let g:miniBufExplMapWindowNavVim = 1 let g:miniBufExplMapWindowNavArrows = 1 let g:miniBufExplMapCTabSwitchBufs = 1 let g:miniBufExplModSelTarget = 1
Possible problems
1. In the Windows operation interface, file creation failed, prompting that there is no permission.
Reason: The current default user of Linux is not the root user.
Solution:
The administrator starts the command line and enters
C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps\ubuntu2204.exe config --default-user root
[Replace Administrator with the file name displayed on your computer. AppData is a hidden folder. You need to open: Show-Hidden Items]
2. WSL/Ubuntu installation anaconda3
1. Installation
Download version Linux-x86.sh file
2. Install anaconda
Move the file to the appropriate directory and execute it from the WSL command line
bash Anaconda3-2022.10-Linux-x86_64.sh
There is no need to change the configuration during the installation process and just press Enter. If necessary, just enter yes.
3. Configure the environment
echo 'export PATH="~/anaconda3/bin:$PATH"' >> ~/.bashrc
4. Resource
source ~/.bashrc
5. Verification
conda
Conda information appears!