[PYTHON] What to do if you can't create a virtual environment using venv even though you're following the Django official website

OS used

Windows10

Overview

I built a virtual environment with reference to django's official website, but it didn't work, and I managed to deal with it, so I will write how to do it.

Django Official HP

Clogged place

After creating a new directory djangogirls in your home directory as shown on the official website, enter the following command using the command prompt. However, the virtual environment env is not created.

C:\Users\Name\djangogirls> python -m venv env
C:\Users\Name\djangogirls>

Trial and error begins ...

After python3.7, when I installed python, venv was also installed automatically, but I could not do it even though it was mentioned in some article, so check the version I installed just in case. Type the following command

C:\Users\Name\djangogirls>python3 -V
C:\Users\Name\djangogirls>

that? No reaction. Check again and type the following command

C:\Users\amanonda\djangogirls>python3 --version
C:\Users\amanonda\djangogirls>

Version information does not come out ...

Isn't the environment setting wrong in the first place? I decided to set the environment again. I referred to the following site for how to change the environment settings.

Let's programming

Click _ "Control Panel" from the displayed pages on this page. I'm starting from the place called "_".

As I proceeded with the environment settings, I was wondering which directory had Python installed in the first place, so I used the where command to find the installed directory.

C:\Users\Name\djangogirls>where python
C:\Users\Name\AppData\Local\Microsoft\WindowsApps\python.exe
C:\Users\Name\AppData\Local\Programs\Python\Python37\python.exe
C:\Users\Name\djangogirls>

There are two things here, Microsoft and others. Please select ** not Microsoft ** and set the path.

After completing the settings, use the cd command to move to the installed directory. It came out when I checked the version after moving.

C:\Users\Name\djangogirls>cd C:\Users\amanonda\AppData\Local\Programs\Python\Python37
C:\Users\Name\AppData\Local\Programs\Python\Python37>python -V
Python 3.7.9

It's 3.7 or later! But I wonder if this happened because the environment settings weren't working. So go back to the first directory and use venv again!

C:\Users\Name\djangogirls>python -m venv env
C:\Users\Name\djangogirls>

... I couldn't create the env directory.

Try using venv by moving to the directory where the path is set.

C:\Users\Name\djangogirls>cd C:\Users\amanonda\AppData\Local\Programs\Python\Python37
C:\Users\Name\AppData\Local\Programs\Python\Python37>python -m venv env
C:\Users\Name\AppData\Local\Programs\Python\Python37>

qiita.png

It's done ... I can't follow the official website, but I decided that the purpose was achieved because the virtual environment was created.

Summary

When creating a virtual environment using venv, move to the installed directory and type the command to create the virtual environment. Just in case, set the path.

It ended halfway, but I'm not in trouble now, so I'm happy with it!

bonus

I really wanted to create env under djangogirls, so I created a djangogirls directory with mkdir under the directory where python was installed. I typed the command again.

C:\Users\Name\AppData\Local\Programs\Python\Python37>cd djangogirls
C:\Users\Name\AppData\Local\Programs\Python\Python37\djangogirls>python -m venv env
C:\Users\Name\AppData\Local\Programs\Python\Python37\djangogirls>

... I couldn't create the env directory. ~ Complete ~

Recommended Posts

What to do if you can't create a virtual environment using venv even though you're following the Django official website
[Django] What to do if the model you want to create has a large number of fields
What to do if you are told "Import Error: cannot import name'HTTPSHandler'" when building a virtual environment using virtualenv
What to do if you can't use the trash in Lubuntu 18.04.
What to do if you can't install with pip in babun environment
What to do if you get a "Wrong Python Platform" warning when using Python with the NetBeans IDE
How to create a Python virtual environment (venv)
What to do if you can't pipenv shell
What to do if Django can't load an image from a static folder
What to do if you can't pip install mysqlclient
Build a Python virtual environment using venv (Django + MySQL ①)
What to do if the Microsoft Store opens even if you run python on Windows
What to do if you get the error ʻERR_FEATURE_UNAVAILABLE_ON_PLATFORM` when using ts-node-dev on Linux
What to do if you can't hit the arrow keys in the Python interactive console
What to do if the library doesn't load when you run it in PyCharm, even though it works fine on terminal
What to do if you can't sort files with subscripts
What to do if you can't log in as root
What to do if you can't use WiFi on Linux
What to do if you cat or tail a binary file and the terminal is garbled
When you want to use multiple versions of the same Python library (virtual environment using venv)
What to do if pip --user returns an error in a virtual environment created with pyenv
What to do if you can't install pyaudio with pip #Python
What to do if you get a minus zero in Python
What to do if you get a UnicodeDecodeError with pip install
What to do if you can't build your project with Maven
What to do when you get "I can't see the site !!!!"
[Python] What to do if you get a ModuleNotFoundError when importing pandas using Jupyter Notebook in Anaconda
What to do if you can't find PDO in Laravel or CakePHP
What to do if the Pipenv environment is corrupted by updating Homebrew
What to do if you can't use scikit grid search in Python
What to do if you get a TypeError with numpy min, max
If you were to create a TODO application (distributed) using only Python-extension 1
What to do if you installed pyenv on Mac OS using Homebrew but the python version doesn't switch
If you want to display values using choices in a template in a Django model
Create a Django project and application in a Python virtual environment and start the server
What to do if you get "Python not configured." Using PyDev in Eclipse
If you want to enter the virtual environment with jupyter, nb_conda_kernels is recommended
What to do if a version error occurs in the selenium Chrome driver
If you want to create a Word Cloud.
[Venv] Create a python virtual environment on Ubuntu
What to do if you get a memory error when converting from PySparkDataFrame to PandasDataFrame
How to install and use pyenv, what to do if you can't switch python versions
What to do if you don't want to use Japanese column names when using ortoolpy.logistics_network
No module named What to do if you get'libs.resources'
ModuleNotFoundError: No module What to do if you get'tensorflow.contrib'
[CRUD] [Django] Create a CRUD site using the Python framework Django ~ 1 ~
What to do if a UnicodeDecodeError occurs in pip
[CRUD] [Django] Create a CRUD site using the Python framework Django ~ 2 ~
[CRUD] [Django] Create a CRUD site using the Python framework Django ~ 3 ~
[CRUD] [Django] Create a CRUD site using the Python framework Django ~ 4 ~
[CRUD] [Django] Create a CRUD site using the Python framework Django ~ 5 ~
What to do when you can't bind CaboCha to Python
[* CentOS 6.10] What to do if you cannot add the IUS Community Project repository on CentOS 6.5 (VirtualBox)
Make a note of what you want to do in the future with Raspberry Pi
(Note) I'll do a Django tutorial. Even if I follow the site, it doesn't work.
What to do if the image is not displayed using matplotlib etc. in the Docker container
What to do if you get a Cannot retrieve metalink for repository error in yum
What to do if you get an error when running "certbot renew" in CakePHP environment
What to do if you get angry with "Gtk * backend requires pygtke to be installed" even though pygtk is included in matplotlib
What to do if you get `locale.Error: unsupported locale setting` when getting the day of the week from a date in Python