Explains how to build a development environment for Python and Django on Windows.
First install Python. Please open the following URL in your browser.
Download the latest version for Windows https://www.python.org/downloads/
Download 3.8.1. (Choose the latest version of Python 3 at that time)
Double-click the downloaded python-3.8.1.exe.
virtualenv is a tool for creating a virtual environment for Python. For each project
Build a fixed virtual environment.
Open a command prompt and enter the command as shown below. (User is hoge)
C:¥Users¥hoge> pip install virtualenv
Create a virtual environment named env1 under My Documents.
C:¥Users¥hoge>cd Documents
C:¥Users¥hoge¥Documents> virtualenv env1
Let's go inside the virtual environment env1.
C:¥Users¥hoge¥Documents> cd env1
C:¥Users¥hoge¥Documents¥env1> Scripts¥activate
(env1) C:¥Users¥hoge¥Documents¥env1>
If (env1) is displayed like this, it is successful.
Use the Scripts \ deactivate
command to exit the virtual environment, but keep this in mind as it will continue.
Django is also one of the Python modules. Install in the virtual environment env1.
This time, I'll install the Django version specified for this course.
(env1) C:¥Users¥hoge¥Documents¥env1> pip install django==3.0.2
You can view the list of Python packages installed locally in your virtual environment with the following command:
(env1) C:¥Users¥hoge¥Documents¥env1> pip freeze -l
asgiref==3.2.3
Django==3.0.2
pytz==2019.3
sqlparse==0.3.0
You can use any text editor to write your Django code, but we recommend that you install PyCharm Professional (https://www.jetbrains.com/pycharm/) as your IDE.
Recently, there is an option to use Visual Studio Code as a Python IDE. I won't explain it here, but if you like the Japanese one for free, you can choose it. · Python code completion -If you can specify where the Python interpreter of the Python virtual environment is, debug execution Etc. can be done in the same way as PyCharm.
Up to this point, in my case it has started. Since I installed the Community version once, is the setting left?
I think you've asked me what the theme should be, but the IDE theme: Darcula has a black background / white letters, and I feel like I'm writing code.
Once you've come this far, let's move on.
Continue to Introduction to Python Django (3)
Recommended Posts