This article walks you through the steps of a beginner developing a coupon distribution service for the iPhone with a RESTful API and swift. It is a very detour implementation because it was implemented while examining the technical elements one by one.
Nowadays, development using framework is commonplace. In the case of Python, a framework called "Django" is often used. The framework makes programming easier, as you can use Django to implement what would normally be done in a complex line program in one line.
There are many ways to install Django, but this time I'll summarize how to use a tool called pipenv. pipenv is a tool to create and manage a virtual environment (called a project) in which python runs. By creating a virtual environment instead of building an environment directly on a computer, one computer can use multiple environments properly.
https://qiita.com/anvinon/items/5d9c128ef8b65b866dfe https://qiita.com/nochifuchi/items/4fe0164f0d8949cf11b7
MacOS 10.15 Homebrew 2.1.15 Fixed internet connection
Just in case, check if pipenv is already installed by running the command to display the version of pipenv.
$ pipenv --version
If you see the message "-bash: pipenv: command not found", pipenv is not installed.
From here, use Homebrew to install pipenv. If you have not installed Homebrew, please install it first.
$ brew install pipenv
Installation is complete when a display like this appears. The installation was completed in a minute or two in my environment.
Execute the version check command earlier to check the version of pipenv installed. I have installed version 2018.11.26 in my environment.
First, create a directory to create a virtual environment. You will create and execute programs under that directory. If you want to use various types of environments, you can do it by using different directories.
To create a directory, use the following command. You can create it in Finder.
$ mkdir [Directory path]
Move to the directory created in the terminal and build the pipenv virtual environment (project) with the following command. I built the environment in a directory called "amiApp".
$ pipenv install
Let's check the contents of the directory here. Here is the command to display the files and directories in the directory.
$ ls
Then, the files "Pipfile" and "Pipfile.lock" are created. Pipfile is
Pipenv A dedicated file used by the virtual environment to manage project dependencies
... apparently ... Looking at the contents of the Pipfile, it looks like this. It seems to be a file that manages the configuration of packages and the like. And in the place of [requires], there is a notation of python_version = "3.7". It seems that python will be installed at the same time when the virtual environment of pipenv is created.
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
[packages]
[requires]
python_version = "3.7"
By the way, to create a virtual environment with the specified python version, execute the command as follows.
$ pipenv --python [Version number]
Now that you have a virtual environment to run python and Django, install Django. Django is a package, so installing it should add Django to the [packages] section of your Pipfile.
You can install django with the following command.
$ pipenv install django
If you check the contents of the Pipfile again, you will find Django in [packages].
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
[packages]
django = "*"
[requires]
python_version = "3.7"
This completes the installation of Django in the pipenv virtual environment.
Next time, I'll run the Django code in the environment I created this time
Recommended Posts