Reinstall software
- 1. Software list (brief version)
- 2. LetsVPN configuration
- 3. VScode and Anaconda download process
-
- 3.1 Download version
- 3.2 Anaconda
-
- Update software
-
- Update python error report
-
- Method 1, delete the library (invalid
- Method 2, update pip (invalid
- Method 3, reinstall
- Update anaconda error
-
- Method 1, update the basic environment (invalid
- Method 2, create a new environment
- Download python library
-
- tensorflow
- Change source
- Distinguish between pytorch and torch
- pytorch
- 3.3 VScode
-
- Configure python environment
-
- Download plugin
-
- python
- Pylance
- indent-rainbow
- Rainbow Brackets 2
- Remote-SSH
- refer to
1. Software list (brief version)
- netdisc
- Alibaba Cloud Disk (storage files and installation programs)
- Baidu Skydisk
- network
- Letsvpn (easy to download software only if you have internet connection)
- Browser
- Edge (brought in)
- Chrome
- Decompression software
- WinRar (unzip the installation package)
- download tool
- FDM (otherwise it will take too long to download the installation package)
- Programming software
- VScode (high difficulty and tight demand)
- Anaconda
- Github Desktop
- drive
- Master Lu
- video player
- Potplayer
- File readers and editors
- Foxit Reader
- Three-piece office set (bring your own)
- visio
- mathtype
- CAJViewer
- Literature reading
- Zotero
- Zhiyun Translation
- Youdao Dictionary
- Screen capture and screen recording
- Snipaste
- oCam
- social application
- WeChat (convenient for transferring files, you can use the web version first)
- Tencent Conference
- entertainment
- bilibili
- NetEase Cloud Music
- Drawing
- Edraw icon (purchase)
2. LetsVPN configuration
You need to follow the help center to turn off the ipv6 protocol, not only Letsvpn’s network, but also its own network.
3. VScode and Anaconda download process
3.1 download version
Go to the official website to download. Although the Sys version is recommended on the Internet as better than the User version, since the direct download is a 32-bit version, after installation, the app prompts that the version is too old and needs to be uninstalled to install a new version. In the end, I chose the latest User version of the Installer.
Consider mainly using the python programming language. Download Anaconda and link it directly with VScode. After running it, check the lower right corner of VScode and you will see that the basic environment base after Anaconda installation is used.
Anaconda powershell prompt is more powerful than Anaconda prompt and is compatible with more Linux commands. There is essentially no difference. Subsequent commands are performed in Anaconda Prompt.
You can only use pip in python, but in the python environment in anaconda, both can be used, and anaconda also has C, R and other languages, so conda has more functions, but if you only look at python, pip is better. Supports all python packages in pypi, and conda is only a small part.
3.2 Anaconda
Update software
Since you want to use the new version of python3.8 to update Anaconda, use Anaconda Prompt to enter the following command. Note that since you need to update the package, try to surf the Internet scientifically.
conda --version python --version conda update conda conda update anaconda conda update python
The system operation results are as follows
Instruction 1
(D:\Programs\Anaconda3) C:\Users\wyh>conda --version conda 4.3.8
Instruction 2
(D:\Programs\Anaconda3) C:\Users\wyh>python --version Python 3.6.0 :: Anaconda 4.3.0 (64-bit)
Command 3
(D:\Programs\Anaconda3) C:\Users\wyh>conda update conda Fetching package metadata ........ Solving package specifications: . Package plan for installation in environment D:\Programs\Anaconda3: The following NEW packages will be INSTALLED: vc: 14-0 The following packages will be UPDATED: conda: 4.3.8-py36_0 --> 4.3.30-py36h7e176b0_0 Proceed ([y]/n)? vc-14-0.tar.bz 100% |##############################| Time: 0:00: 00 208.78 kB/s conda-4.3.30-p 100% |##############################| Time: 0:00:00 582.62 kB/s
Directive 4
(D:\Programs\Anaconda3) C:\Users\wyh>conda update anaconda Fetching package metadata ............. InvalidSpecError: Invalid spec: =2.7
Directive 5
(D:\Programs\Anaconda3) C:\Users\wyh>conda update python Fetching package metadata ............. Solving package specifications: . Package plan for installation in environment D:\Programs\Anaconda3: The following NEW packages will be INSTALLED: brotlipy: 0.7.0-py36h2bbff1b_1003 ,,, The following packages will be UPDATED: bzip2: 1.0.6-vc14_3 --> 1.0.8-he774522_0 ,,, Proceed ([y]/n)? menuinst-1.4.1 100% |##############################| Time: 0:00:00 105.31 kB/ s ,,, ERROR conda.core.link:_execute_actions(337): An error occurred while installing package 'defaults::charset-normalizer-2.0.4-pyhd3eb1b0_0'. CondaError: Cannot link a source that does not exist. D:\Programs\Anaconda3\Scripts\conda.exe Running `conda clean --packages` may resolve your problem. Attempting to roll back. CondaError: Cannot link a source that does not exist. D:\Programs\Anaconda3\Scripts\conda.exe Running `conda clean --packages` may resolve your problem.
Error reporting when updating python
Method 1, delete the library (invalid
Use the recommended command conda clean --packages
to solve the error problem of command 5, delete many packages, and rerun command 5. The results are as follows
Proceed ([y]/n)? ERROR conda.core.link:_execute_actions(337): An error occurred while installing package 'defaults::charset-normalizer-2.0.4-pyhd3eb1b0_0'. CondaError: Cannot link a source that does not exist. D:\Programs\Anaconda3\Scripts\conda.exe Running `conda clean --packages` may resolve your problem. Attempting to roll back. CondaError: Cannot link a source that does not exist. D:\Programs\Anaconda3\Scripts\conda.exe Running `conda clean --packages` may resolve your problem.
Still reporting an error
Method 2, update pip (invalid
Consider updating the pip tool and enter the command conda install pip
. Similar problems occur after running it.
ERROR conda.core.link:_execute_actions(337): An error occurred while installing package 'defaults::charset-normalizer-2.0.4-pyhd3eb1b0_0'. CondaError: Cannot link a source that does not exist. D:\Programs\Anaconda3\Scripts\conda.exe Running `conda clean --packages` may resolve your problem. Attempting to roll back. CondaError: Cannot link a source that does not exist. D:\Programs\Anaconda3\Scripts\conda.exe Running `conda clean --packages` may resolve your problem.
Method 3, reinstall
Considering that the installation package was retained from before, I chose to go to the official website to reinstall Anaconda.
Check and update after reinstallation
Instruction 1
(base) PS C:\Users\wyh> conda --version conda 23.7.4
Instruction 2
(base) PS C:\Users\wyh> python --version Python 3.11.5
Command 3
(base) PS C:\Users\wyh> conda update conda ,,, done
Directive 4
(base) PS C:\Users\wyh> conda update anaconda PackageNotInstalledError: Package is not installed in prefix. prefix: D:\Programs\anaconda3 package name: anaconda
Error reporting when updating anaconda
Method 1, update the basic environment (invalid
Usually this error “PackageNotInstalledError: Package is not installed in prefix.” is because the custom environment does not have conda infrastructure. Instead, it’s only in your base environment, which you want to update.
Use conda update --all
to update and it will run without any problem.
Re-run command 4 and still get the error.
Method 2, create a new environment
Since the packages in the base can be used by other environments, we are planning to establish a new environment. However, because too many virtual environments can easily cause various problems, we are currently only establishing a new environment.
Use conda env list
to view all environment lists,
# conda environments: # base * D:\Programs\anaconda3
To create a new environment, use the command conda create -n torch python=3.11
, and some packages will be automatically installed based on the base.
Check again using conda env list
# conda environments: # base * D:\Programs\anaconda3 torch D:\Programs\anaconda3\envs\torch
The environment has been established. Use conda activate torch
to change the environment. Repeat the command for the new environment. Command 3 will report an error.
(torch) PS C:\Users\wyh> conda update conda PackageNotInstalledError: Package is not installed in prefix. prefix: D:\Programs\anaconda3\envs\torch package name:conda
Use command
(torch) PS C:\Users\wyh> conda update --name base conda Collecting package metadata (current_repodata.json): done Solving environment: done # All requested packages already installed.
View installed version
(torch) PS C:\Users\wyh> conda list --name base conda # packages in environment at D:\Programs\anaconda3: # # Name Version Build Channel _anaconda_depends 2023.09 py311_mkl_1 anaconda-anon-usage 0.4.3 py311hfc23b7f_100 anaconda-catalogs 0.2.0 py311haa95532_0 anaconda-client 1.12.1 py311haa95532_0 anaconda-cloud-auth 0.1.4 py311haa95532_0 anaconda-navigator 2.5.0 py311haa95532_0 anaconda-project 0.11.1 py311haa95532_0 conda 23.9.0 py311haa95532_0 conda-build 3.27.0 py311haa95532_0 conda-content-trust 0.2.0 py311haa95532_0 conda-index 0.3.0 py311haa95532_0 conda-libmamba-solver 23.9.2 py311haa95532_0 conda-pack 0.6.0 pyhd3eb1b0_0 conda-package-handling 2.2.0 py311haa95532_0 conda-package-streaming 0.9.0 py311haa95532_0 conda-repo-cli 1.0.75 py311haa95532_0 conda-token 0.4.0 pyhd3eb1b0_0 conda-verify 3.4.2 py_1 msys2-conda-epoch 20160418 1
Repeating command 3 still failed, and found that updating the conda tool can only be done in the base environment.
Try command 4 to update anaconda, still in the base environment and the new environment, both show that it is not in the prefix, fail, and give up.
Try instruction 5, update the python library, try it in the new environment, and complete it successfully.
Use conda deactivate
to shut down the environment.
Download python library
tensorflow
Using conda install tensorflow
to download tensorflow failed
(torch) C:\Users\wyh>conda install tensorflow Collecting package metadata (current_repodata.json): done Solving environment: unsuccessful initial attempt using frozen solve. Retrying with flexible solve. Solving environment: unsuccessful attempt using repodata from current_repodata.json, retrying with next repodata source.Collecting package metadata (repodata.json): done Solving environment: unsuccessful initial attempt using frozen solve. Retrying with flexible solve. Solving environment: / Found conflicts! Looking for incompatible packages. This can take several minutes. Press CTRL-C to abort. failed UnsatisfiableError: The following specifications were found to be incompatible with the existing python installation in your environment: Specifications: - tensorflow -> python[version='3.10.*|3.9.*|3.8.*|3.7.*|3.6.*|3.5.*'] Your python: python=3.12 If python is on the left-most side of the chain, that's the version you've asked for. When python appears to the right, that indicates that the thing on the left is somehow not available for the python version you are constrained to. Note that conda will not change your python version to a different minor version unless you explicitly specify that.
Meaning, unsatisfiable error: The following specifications were found to be incompatible with existing python installations in the environment:
Specification:
-h5py==2.7.0->python[version=>=2.7,<2.8.0a0 |>=3.5,.6.0a0 |>=3.6,.7.0a0’]
your python:python=3.8
If python is at the far left of the chain, then that’s the version you’re asking for. When python appears on the right, it’s an indication that what’s on the left is somehow inappropriate for the version of python you’re constraining. Note that conda will not change the python version to a different minor version unless you specify it explicitly.
Solution
The version of the currently installed package is inappropriate or incompatible with the current Python version. Therefore, you need to install the corresponding package according to the Python language version!
For example, for python3.7 or above, the installed h5py version cannot be lower than version 3.6!
Maybe because I installed version 3.11 and updated python at the same time, it is currently version 3.12. So uninstall and delete the environment, and reinstall the 3.10 version of the torch environment. Exit the environment first and use it in the base environment
conda remove -n torch --all conda create -n torch python=3.10 (base) C:\Users\wyh>conda activate torch (torch) C:\Users\wyh>conda install tensorflow (torch) C:\Users\wyh>conda install matplotlib
Select and change python directly in VScode
Change source
Use conda list
to view all packages, use conda install name
to download, and there will be an error.
PackagesNotFoundError: The following packages are not available from current channels: -torch Current channels: - https://repo.anaconda.com/pkgs/main/win-64 - https://repo.anaconda.com/pkgs/main/noarch - https://repo.anaconda.com/pkgs/r/win-64 - https://repo.anaconda.com/pkgs/r/noarch - https://repo.anaconda.com/pkgs/msys2/win-64 - https://repo.anaconda.com/pkgs/msys2/noarch
No matter whether you are scientifically connected or not, you cannot download it. Prepare to switch to domestic mirror sources.
Use conda config --show
to view the image source. There are several lines in it.
,,, channel_alias: https://conda.anaconda.org channel_priority: flexible channel_settings: [] channels: -defaults ,,, custom_channels: pkgs/main: https://repo.anaconda.com pkgs/r: https://repo.anaconda.com pkgs/msys2: https://repo.anaconda.com pkgs/pro: https://repo.anaconda.com custom_multichannels: defaults: - https://repo.anaconda.com/pkgs/main - https://repo.anaconda.com/pkgs/r - https://repo.anaconda.com/pkgs/msys2 local: debug: False default_channels: - https://repo.anaconda.com/pkgs/main - https://repo.anaconda.com/pkgs/r - https://repo.anaconda.com/pkgs/msys2
You can use conda config --remove channels url address
to delete the source, and use conda config --remove-key channels
to change back to the default source. Since the Tsinghua source has stopped serving, choose University of Science and Technology of China Mirror Source
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/ conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/ conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/ conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/ conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/ conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/ conda config --set show_channel_urls yes
Check again there are
channel_alias: https://conda.anaconda.org channel_priority: flexible channel_settings: [] channels: - https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/ - https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/ - https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/ - https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/ - https://mirrors.ustc.edu.cn/anaconda/pkgs/free/ - https://mirrors.ustc.edu.cn/anaconda/pkgs/main/ -defaults
Source change successful! Download the time, pytorch package again
Distinguish between pytorch and torch
Pytorch can be said to be the python version of torch, and adds many new features. Officials believe that the biggest difference between the two is that Pytorch redesigns the relationship between the model model and intermediate variables. In Pytorch, all calculated intermediate variables exist in the calculation graph, and all models can share intermediate variables. The intermediate variables in torch are in each module. If you want to call the parameters of other modules, you must first copy this module and then call it.
- The biggest feature of pytorch when writing models is to use autograd technology to realize automatic derivation, which means that we do not need to bother writing some reverse calculation functions. This aspect is inherited from torch.
- Pytorch relies on Python’s powerful third-party libraries. Existing libraries can be used directly. We can use our image reading to directly use Python’s own PIL image library or python-opencv. All other functions you want to implement can be used. Implemented using python’s powerful third-party libraries; torch can easily expand cuda and c code to implement richer custom layers and algorithm operations
pytorch
Report an error
CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://mirrors.ustc.edu.cn/anaconda/pkgs/main/win-64/pytorch-2.0.1-cpu_py310hb0bdfb8_0.conda> Elapsed: - An HTTP error occurred when trying to retrieve this URL. HTTP errors are often intermittent, and a simple retry will get you on your way.
Confirm network connection and try again.
3.3 VScode
Configure python environment
Download plug-in
python
The full name of the Python plug-in is Python extension for Visual Studio Code. It is a Visual Studio Code extension with rich support for the Python language (for all supported versions of the language: >= 3.6), including functions such as IntelliSense, linting, debugging, Code navigation, code formatting, Jupyter Notebook support, refactoring, features like variables explorer, test explorer, snippets and more!
Pylance
Pylance mainly has the following features:
Docstrings
Parameter prompt
Automatic import
code completion
code diagnostics
Quotes and jumps
code outline
type checking
Support multiple workspaces
Signature help with type information
Compatible with IntelliCode and Jupyter notebooks
When you need to run a Python program
- You can right-click the program file (py file) and select Run Python File in Terminal to run the program
- Click the green triangle in the upper right corner to run the program
indent-rainbow
When there are many levels of code indentation, in order to make it easier to visually identify, it is generally hoped that multiple indents can be highlighted in different colors. The indent-rainbow plug-in in VS Code can achieve this function.
Rainbow Brackets 2
When there are many levels of code, in addition to the indentation effect, there is another situation that is often encountered, which is various brackets, including (), [], {}; Rainbow Brackets 2 in VS Code
The plug-in can list the effects of bracket highlighting, especially for multiple sets of nested brackets.
Remote-SSH
Because you use SSH to connect to the remote server, Windows needs to support SSH.
You can get SSH functionality by installing Git
Verification: Use Win + R, enter cmd to open the control window, enter ssh directly, and usage is displayed, which means SSH has been installed successfully.
Reference
The difference between pytorch and torch