I don't think it will hurt to do Python. Since it is a scripting language, it is ** easy to learn ** and ** easy to code **. Interpreter language, ** easy to execute . It is one of the most popular languages and the community is active. What's more, there are many things you can do ** from web application development to deep learning. I will say it again. ** Python Let's do it. ** **
** Let's use the virtual environment **. Python uses a lot of libraries, so it's easier to manage if you do it in a virtual environment. here,
I would like to introduce two of them. The target OS is Windows 10.
This is the place to make a web application.
First, install Python.
A interpreter
that translates code into machine language.
The PythonJapan site is convenient, so let's use it.
Visit this site (https://pythonlinks.python.jp/ja/index.html) and download the latest stable installer.
As of January 2021, it's the 3.9.1 installer, that is, python-3.9.1-amd64.exe
.
After the download is complete, let's install it.
Run the installer.
You will enter various initial settings screens, but I think that most of the items are okay without touching them.
However, if the checkbox for the item Add Python 3.x to PATH
appears, check it.
This is so that you can operate Python from PowerShell or a command prompt.
When the installation is complete, close it with Close
.
Make sure you have installed it successfully.
Start PowerShell and
python -V
Execute the command.
If the version is displayed, such as 3.9.1
, it is OK.
There are times when you want to change the Python version depending on the project (although I don't have one yet). At such times, you can use pyenv to use multiple versions of Python on the same PC. In short, it's a Python version control tool.
pyenv is a UNIX-like service, so use the Windows version of pyenv-win
instead.
Run the following command in PowerShell.
pip install pyenv-win --target $HOME\.pyenv
Then run the following command to add the PYENV environment variable.
[System.Environment]::SetEnvironmentVariable('PYENV',$env:USERPROFILE + "\.pyenv\pyenv-win\","User")
Run the following command in PowerShell with administrator privileges.
[System.Environment]::SetEnvironmentVariable('PATH', $HOME + "\.pyenv\pyenv-win\bin;" + $HOME + "\.pyenv\pyenv-win\shims;" + $env:Path,"Machine")
Close PowerShell once and start it again for the settings to take effect.
Now that the installation and initial setup of pyenv is complete, check if it is reflected normally.
In PowerShell, run the following command.
pyenv --version
If the version is output, it's OK.
Manage your current Python with pyenv.
pyenv rehash
--Update of pyenv
pip install --upgrade pyenv-win
--List of supported versions of pyenv
pyenv install -l
--Install any version
pyenv install 3.9.0
--Globalization of any version (to a common version of PC)
pyenv global 3.9.0
--Localization of any version (version within the project)
pyenv local 3.9.0
--Any version of uninstall
pyenv uninstall 3.9.0
One of the features of Python is that external libraries are important
.
An external library is simply an extension.
It is common to install and use an external library with pip or the like.
However, if you install too many libraries, it will be difficult to manage.
Therefore, Poetry is a tool that manages libraries for each project.
In PowerShell, run the following command.
(Invoke-WebRequest -Uri https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py -UseBasicParsing).Content | python
Close PowerShell once to reflect the settings. Start again,
poetry --version
Execute the command.
When the version is displayed, it's OK.
As a default setting, execute the following command.
poetry config virtualenvs.in-project true
A virtual environment for virtualenv is now created in your project.
--Poetry update
poetry self update
--Project template generation
poetry new MyProject01
MyProject01
├── pyproject.toml
├── README.rst
├── myproject01
│ └── __init__.py
└── tests
├── __init__.py
└── test_project01.py
--Add library to project (numpy here)
poetry add numpy
--Program execution
Create main.py
in the myproject01 directory.
main.py
import numpy as np
x = np.array([1, 2, 3])
print(x.size)
In the myproject01 directory, run the following command.
poetry run python main.py
Anaconda
This is the place to do statistical analysis and machine learning.
Anaconda is a distribution that includes a Pyhon interpreter, an external library often used for scientific calculations, and an IDE that is convenient for development. If you install only Anaconda, the development environment will be ready immediately.
First, go to This Site.
When you scroll, you will see a screen like this.
Click 64-Bit Graphical Installer
to download the installer.
Launch the installer.
You will be taken to various initial settings screens, but I think it's okay not to touch most of the items here either.
However, if the check box for the item Add Anaconda 3 to the system PATH environment variable
appears, check it.
This is so that you can operate Python from PowerShell or a command prompt.
After the installation is complete, start Anaconda Powershell Prompt (Anaconda3)
from Anaconda3 (64-bit)
on the start screen.
Then execute the following command.
ipython
IPython is the python shell that comes with Anaconda. You can type in the code and execute it. For the time being,
exit()
Let's get out of the shell with.
To do programming, you need something called a "text editor" or "integrated development environment" in addition to the one you just installed. These are software for "writing code". The text editor is the minimum function, and the integrated development environment, commonly known as IDE, is multi-functional. There is also a standard Windows version called Notepad, but it is difficult to use, so install it separately.
We recommend PyCharm
.
It's a Python-only IDE, and it's very good software.
There are a paid version and a free version, but basically the free version will suffice. When it comes to framework development, I think the paid version is good.
PyCharm is developed by a Czech company called JetBrains
.
JetBrains also develops other useful IDEs such as Intellij IDEA
and RubyMine
.
The software to manage them is JetBrains Toolbox
.
It is more convenient to use Toolbox than to install it from the official website, so let's use it.
Download the installer from this site (https://www.jetbrains.com/ja-jp/toolbox-app/).
You can easily install it by running the installer.
Launch Toolbox and install`` PyCharm Community
.
It's easy to get a little confused when starting up for the first time, so I will explain it.
After starting, click the + mark.
Location
is the location where you want to save your project. Unless you have a specific reason, create a directory such as Python
in the document on drive C or drive D, and create a project in it.
Change the Virtualenv
below it to raw Python + pyenv + Poetry
, or to conda
for Anaconda
.
After that, create a project with CREATE
.
Also, if you are using Anaconda, IDEs such as JupyterLab
and Spyder
are included, so you can use that as well.
Also, if you are a pervert, please use Vim. Vim best Vim best Vim best Vim best
Building an environment is the most frustrating part of programming. So failure is a matter of course. If that doesn't work, try the other method or the method introduced on another site.
Using Poetry and pyenv from Python installation on Windows 10 (https://qiita.com/kerobot/items/3f4064d5174676080585)