[DOCKER] [Windows 10] [Development environment construction] How to resolve when unresolved import'django.xxx' python (unresolved-import) occurs in VS Code

Occurrence event

Unresolved import related to django occurred in vscode. For example, unresolved import'django.urls' python (unresolved-import).

I felt uncomfortable, so how to deal with it.

Development environment

--Build a development environment with docker for Windows. The Python virtual environment uses pipenv.

item version
OS Window10 2004
Python 3.8.2
docker 2.3.0.5
Editor VSCode:1.49.2

--Various software versions of the virtual environment are as follows.

item version
OS ubunts:20.04
python 3.8.2
Django 3.0.6
gunicorn 20.0.4
psycopg2 2.8.5
PostgeSQL 2.3
nginx 1.17.10

Building a virtual environment

Correspondence

1. Create an .env file directly under the workspace

2. Describe the following in the .env file

python:.\.env


PYTHONPATH = app\.venv\Lib\site-packages

3. Check the VS Code envFile settings.

3-1. Open the settings with File-> Preferences-> Settings from the VS Code menu.

Settings.png

3-3. Enter "python.envFile" in the search window.
3-4. If the value of python.envFile is "$ {workspaceFolder} /.env", there is no problem as it is. Probably the path is directly under the workspace by default.

envfile.png

3-5. Restart VS Code.

** Probably the unresolved import related to django has been resolved **

Afterword

It's natural because it's not visible from VS Code, but ...

The site that I used as a reference

https://blog.mrym.tv/2019/08/vscode-python-unresolved-import/

Recommended Posts

[Windows 10] [Development environment construction] How to resolve when unresolved import'django.xxx' python (unresolved-import) occurs in VS Code
How to use VS Code in venv environment on windows
UpNext2 Development Record # 1 Build Python CI environment in VS Code
[Python3] Development environment construction << Windows edition >>
Create a Python environment for professionals in VS Code on Windows
How to build Python and Jupyter execution environment with VS Code
How to access environment variables in Python
How to prepare Python development environment [Mac]
Windows + gVim + Poetry python development environment construction
Steps to create a Python virtual environment with VS Code on Windows
How to debug a Python program by remotely connecting to a Docker container in WSL2 environment with VS Code
VS Code + Azure Functions + Python environment construction procedure
Python (Windows 10) Virtual Environment / Package with VS Code
Use Python in Anaconda environment with VS Code
What to do when SSL error occurs in pip in Windows10, miniconda, VScode environment
Python local development environment construction template [Flask / Django / Jupyter with Docker + VS Code]
Easy Python data analysis environment construction with Windows10 Pro x VS Code x Docker
I tried to build an environment with WSL + Ubuntu + VS Code in a Windows environment
python windows environment construction
Allow real-time code checking in Python development with VS Code
Python development environment construction
How to make a Python package using VS Code
What to do if Python IntelliSense is not displayed in VS Code on Windows
Python development environment with Windows + Anaconda3 + Visual Studio Code
Python development environment construction 2020 [From Python installation to poetry introduction]
How to resolve SSL module errors in Anaconda environment
python2.7 development environment construction
How to exit when using Python in Terminal (Mac)
How to use jupyter lab in Windows 10 local environment
Python development environment with Windows + Python + PipEnv + Visual Studio Code
Environment construction for those who want to study python easily with VS Code (for Mac)
Development environment in Python
Prepare Python development environment with Mac + Windows + VisualStudio Code (Windows version)
How to develop in a virtual environment of Python [Memo]
Prepare Python development environment with Mac + Windows + VisualStudio Code (Mac version)
How to implement Python EXE for Windows in Docker container
How to build a python2.7 series development environment with Vagrant
How to get into the python development environment with Vagrant
I want to be able to run Python in VS Code
Python with VS Code (Windows 10)
How to install Python [Windows]
Python environment construction (Windows10 + Emacs)
Python environment construction under Windows7 environment
[MEMO] [Development environment construction] Python
How to develop in Python
[Subprocess] When you want to execute another Python program in Python code
How to not escape Japanese when dealing with json in python
Introducing vebootstrap to handle virtualenv more easily in Python development environment
Debug settings in virtual environment when using Pipenv with VS Code
Articles to read when Blender Python script code doesn't work in 2.80
Create a simple Python development environment with VS Code and Docker
What to do when ModuleNotFoundError: No module named'XXX' occurs in Python
How to set up the development environment of ev3dev [Windows version]
Python environment construction memo on Windows 10
[Python] How to do PCA in Python
Anaconda python environment construction on Windows 10
How to collect images in Python
How to use SQLite in Python
Build a development environment using Jupyter and Flask with Python in Docker (supports both VS Code / code-server)
Resolve VS Code unresolved import error
Python development environment construction on macOS