Install Anaconda and configure the Anaconda environment. In Windows, Anaconda activates the environment using conda Activate. HTTP 000 CONNECTION FAILED for URL: HTTP 000 CONNECTION FAILED for URL error, conda command, Anaconda command

Computer configuration: Windows10, 64-bit operating system

I. Introduction to Anaconda

Anaconda refers to an open source distribution of Python that contains more than 180 science packages and their dependencies, including Conda, Python, and others. Because of the large number of science packages included, Anaconda’s download files are relatively large.

Conda is an open source package and environment manager that can be used to install different versions of software packages and their dependencies on the same machine and switch between different environments.

Anaconda includes Conda, Python, anda number of installed toolkits such as Numpy and pandas.

Anaconda is extremely user-friendly for python beginners. Choosing Anaconda can save you a lot of trouble compared to installing python’s main program separately. Anaconda adds a number of commonly used feature packages that you would need to install yourself if you installed Python separately. Anaconda doesn’t have to worry about that, and it comes bundled with two very useful interactive code editors (Spyder, Jupyter Notebook).

Anacond download

1. The Anaconda’s official website

Anaconda is cross-platform, available for Windows, macOS, and Linux. Depending on your PC’s configuration, choose the 64-bit version of python3.8 for Windows.

Finally download anaconda3-2020.07-windows-x86_64.exe.

2. Official website: Anaconda Installer Archive

3. Open Source Software Mirror station of Tsinghua University

Anaconda installation

1. Double-click the downloaded anaconda3-2020.07-Windows-x86_64. exe file.

2. Click ON I Agree.

3. Select All User and click Next.

4. Select the folder you want to install. I installed it in E:\Anaconda3 and click Next.

5. Advanced Installation Options. Two default is good, the first is to add environment variables, ** must not check the first option in this step to configure the environment, the subsequent configuration of their own environment, otherwise prone to error, and error uninstall very troublesome; ** The second is to use Python 3.8 by default. Click Install to finally start the installation.

6. Wait for the installation. Install anaconda3-2020.07-windows-x86_64. exe DLL and py files into the installation target folder. Once the installation is complete, click Next.

7. Continue clicking Next.

8. Click Finish to cancel the two √’s.

4. Configure Anaconda environment variables

1. The configuration

I am running Windows10 and need to configure environment variables. Right-click advanced system Settings environment variables user variables path and add the Scripts folder of Anaconda’s installation directory, that is, E: Anaconda3 Scripts (depending on your installation path).

2. Verify

To verify at the command prompt, open the command prompt window with Windows+R or Windows system \ run \ CMD.

Python * * * * 1)

If you type Python, the output is 3.8.× (if python is not installed on your computer), indicating that the environment variable has been set successfully.

2) conda

Enter conda –version and the output conda 4.×× indicates that the environment variable is set successfully.

3) Update the upgrade tool package

To avoid possible errors, type Conda upgrade –all to upgrade all toolkits first.

Manage the virtual environment

Torch 0.4.0-cp36-cp36m-win_amd64. WHL, Torch 1.0.0-cp36-cp36m-win_amd64. WHL, torch 1.0.0-cp36-cp36m-win_amd64.

1. Create a virtual environment chPY36

Virtual environment name =chPY36,

Conda create -n chPY36 python=3.6

Create a virtual environment named chPY36 and set the Python version to 3.6 (conda will automatically download the latest version of 3.6).

** Problem: ** Conda cannot create virtual environments and cannot install other third-party packages

** The access speed of the default image source is too slow, which will cause a timeout, resulting in update and download failure

** Solution: ** Change the image source to Tsinghua image source and delete the default image source

** Solution: 1) Enter the following code at the command prompt **

conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64
conda config --set show_channel_urls yes
Copy the code

** 2) Find the. Condarc file in the user root directory (C:\Users\ username), open and edit it, and delete the default configuration line in it. 支那

To:

Conda create -n chPY36 python=3.6 conda create -n chPY36 python=3.6 支那

2. Proceed 

Prompt you whether to Proceed, type Y

3. Access the virtual environment

Enter conda activate chPY36 at the command prompt

An error occurred.

Solution: 1) Enter the command prompt: activate (switch to the base environment)

Conda activate chPY36 activate chPY36

4. Install dependencies

** * Place requirements. TXT, torch 0.4.0-cp36-cp36m-win_amd64. WHL, torch 1.0.0-cp36-cp36m-win_amd64. WHL in C:\Users\ user name.

The code for requirements.txt is as follows:

Absl-py ==0.9.0 ASTor ==0.8.1 astunparse==1.6.3 backcall==0.1.0 backports. Weakref ==1.0 rC1 bleach==1.5.0 Certifi ==2019.11.28 chardet==3.0.4 click==7.1.2 colorama==0.4.3 comtypes==1.1.7 cycler==0.10.0 dataclasses==0.7 Decorator ==4.4.2 filelock== 3.0.12gast ==0.3.3 Google -pasta== 0.2.0grpcio == 1.27.2H5PY ==2.10.0 html5lib==0.9999999 Idna ==2.9 imageio==2.8.0 imageio-FFmPEG ==0.4.1 Intel-OpenMP ==2019.0 ipython==7.13.0 ipython-genutils==0.2.0 Jedi ==0.16.0 Joblib ==0.17.0 Keras==2.0.0 keras-applications ==1.0.8 keras-preprocessing ==1.1.2 kiwisolver==1.2.0 Markdown==3.2.1 Matplotlib ==3.2.1 mock==4.0.2 moviepy==1.0.2 numpy==1.19.4 Opencv-python ==3.4.3.18 opt-einsum==3.3.0 packaging==20.4 Pandas ==1.0.1 parso==0.6.2 Pickleshare ==0.7.5 Pillow==7.1.1 proglog==0.1.9 prompt- Toolkit ==3.0.5 protobuf==3.11.3 Pyexplanations ==2.6.1 pyparsing==2.4.7 PyQt5==5.14.2 PyQt5-SIP ==12.7.2 Python-dateutil ==2.8.1 PyTTsx3 ==2.87 Pytz ==2019.3 PyYAML==5.3.1 regex==2020.10.28 requests==2.23.0 SACRemoses ==0.0.43 scikit-learn==0.23.2 sciPY ==1.5.4 Sentencepiece ==0.1.91 six==1.15.0 sklearn==0.0 style==1.1.0 tensorboard==1.13.1 tensorflow==1.13.1 Tensorflow-estimator ==1.13.0 Tensorflow-tensorboard ==0.1.8 TERmcolor ==1.1.0 ThreadPoolCTL ==2.1.0 tokenizers==0.9.3 Torch == 1.00tqDM == 1.004 traitlets== 1.004 transformers== 1.004 update== 1.001urllib3 == 1.002wcWidth == 1.003 Werkzeug = = 1.0.0 wincertstore wrapt = = = = 0.2 1.12.0Copy the code

Comment out the torch package in requirements.txt, or it will not be found during installation.

PIP install torch-1.0.0-cp36-cp36m-win_amd64.whl

PIP install -r requirements. TXT -i pypi.douban.com/simple/

5. Test

1) Trial run test procedure,

The code for shizipeixun.py is as follows:

Versions of the main libraries required for the course: Tensorflow ==1.13.1 Torch ==1.0.0 transformers==3.5.0 "import numpy as NP import tensorflow as TF import transformers import torch print(__doc__)Copy the code

Run shizipeixun.py in the chPY36 environment, place it in C:\Users\a, and type

C:\Users\a>activate
(base) C:\Users\a>conda activate chPY36
(chPY36) C:\Users\a>python shizipeixun.py
Copy the code

Error as follows:

2) Modify the generation_utils.py source code in the Transformers folder as prompted (line 173)

Location: E:\Anaconda3\envs\chPY36\Lib\site-packages\transformers

Comment out line 173,

And change Torch.BoolTensor to Torch.IntTensor or Torch.ByteTensor on line 173

3) Re-run the test program and see the output of the following pictures, indicating that the environment configuration is complete.

6. Initial experience of Anaconda

1. Anaconda Prompt

Path: Windows start menu /Anaconda/Anaconda Prompt, open Anaconda Prompt. This window is the same as the doc window, and you can control and configure Python by typing commands. The most commonly used command is conda. This software is integrated, you can directly use, click on the picture below.

Some conda commands, more visible conda simple commands:

Conda List: Lists all installed packages

Conda install name: where name is the name of the packages that need to be installed. For example, if I install numpy, enter the command “conda install numpy”. Leave a space between the words, press Enter, and type y.

2. Anaconda Navigtor

Graphical user interface for managing toolkits and environments, and many of the admin commands that follow can also be implemented manually in Navigator.

3. Jupyter notebook

A web-based interactive computing environment that can edit human-readable documents to show the process of data analysis.

For example, open the jpynb file in C:\Users\a\Day02 and execute it in the virtual environment chPY36, as shown in the following figure:

appear