When building the Python environment, I went through various articles because "authentication proxy settings, coexistence environment, and execution confirmation are required", so I think it would be good to put them together.
The contents introduced in this article are as follows. Please skip the authentication proxy and coexistence environment construction if necessary.
For Python beginners who have any of the following:
The environment whose operation has been confirmed is as follows.
Download the installer for the target OS from the Download Site. (*) Even if you are a Python2 system main user, you can use the 3 system installer.
Kick the installed exe to proceed with the installation. __ Check "Add to environment variable PATH" Except for __, the default settings are OK.
C:\Users\User name>conda info -e
# conda environments:
#
root * C:\Users\User name\Anaconda3
python
to see the version of Python in your current environment.
From the following, you can confirm that it is Python 3.6.1.C:\Users\User name>python
Python 3.6.1 |Anaconda 4.4.0 (64-bit)| (default, May 11 2017, 13:25:24) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>>exit()
(*) If you are in an authentication proxy environment, you cannot execute "Building a coexistence environment" unless you pass the authentication first.
`.condarc``` directly under the Anaconda3 HOME directory (usually`
C: \ Users \ username \ Anaconda3```)..Describe the "user name", "password", "IP address", and "port number" used for proxy authentication in condarc as follows.[^1]
```yaml
proxy_servers:
http: http://User name:password@IP address:port number
https: https://User name:password@IP address:port number
(*) If you cannot create it directly, create an appropriate text file and execute the following.
#Go to the Anaconda3 HOME directory and then run
C:\Users\User name\Anaconda3 >ren <Text file name> .condarc
C:\Users\User name>conda config --show
add_anaconda_token: True
...
proxy_servers:
http: http://User name:password@IP address:port number
https: https://User name:password@IP address:port number
...
verbosity: 0
anaconda
to the end, the library automatically included when Anaconda is installed will be inherited. [^ 2]# 2.Create a 7-series Python execution environment with the name "py27"
C:\Users\User name>conda create -n py27 python=2.7 anaconda
C:\Users\User name>conda info -e
# conda environments:
#
py27 C:\Users\User name\Anaconda3\envs\py27
root * C:\Users\User name\Anaconda3
activate
command. [^ 3]C:\Users\User name>activate py27
(py27) C:\Users\User name>
python
to see the Python version and make sure the environment is switched.(py27) C:\Users\User name>python
Python 2.7.13 |Continuum Analytics, Inc.| (default, May 11 2017, 13:17:26) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>>
print('hello, world!')
Please enter.>>> print('Hello, world!')
Hello, world!
>>>
I was able to confirm that "Hello, world!" Is displayed.
>>>exit()
helloWorld.py
print('Hello, world!')
<Script storage location>
Enter the path of the script you created earlier.(py27) C:\Users\User name>python <Script storage location>\helloWorld.py
Hello, world!
(py27) C:\Users\User name>
deactivate
command to exit the 2 system environment.(py27) C:\Users\User name>deactivate py27
C:\Users\User name>
python
to make sure the environment is switched.C:\Users\User name>python
Python 3.6.1 |Anaconda 4.4.0 (64-bit)| (default, May 11 2017, 13:25:24) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
This completes the operation check of Python2 series. Following the above, you can check the operation by "Run the program in interactive mode" and "Run the Python script" in the 3rd system as well. [^ 4]
In this article, we have introduced the following contents.
I think it was very easy from installation to execution confirmation.
For me, who mainly used Java, I was surprised that it was too easy to build a coexistence environment for different versions.
Here are some supplements related to the following commands when building a coexistence environment for different versions.
C:\Users\User name>conda create -n py27 python=2.7 anaconda
C:\Users\User name>conda create -n py21 python=2.1
Fetching package metadata ...........
PackageNotFoundError: Package missing in current win-64 channels:
- python 2.1*
system | Specifiable version |
---|---|
2.5 or earlier | None |
2.6 | 2.6.8、2.6.9 |
2.7 | 2.7.3 ~ 2.7.13 |
3.1 | None |
3.2 | None |
3.3 or later | Basically everything is OK |
C:\Users\User name>conda remove -n <Environment name> --all
[^ 1]: If user / password authentication is not required, delete @ and before.
[^ 2]: If you do not add anaconda
to the end, install it later by yourself with `conda install``` etc. You can check what is already installed with
conda list
``.
[^ 3]: `source activate``` on Mac and Linux [^ 4]:
`print``` behaves differently between the 2nd and 3rd series, but this article introduces how to write it in both environments.
Recommended Posts