When I loaded the Poetry environment into VS Code, I got an import error. After that, the error was resolved safely, but I'm addicted to it, so I'll leave a note.
Mac mojave
The default behavior of Poetry is to create a virtual environment according to the settings. I don't know that in VSCode, so even if I ignore poetry and try to read it, the library cannot be found at all and an error occurs because it cannot be solved.
It is necessary to change the settings and recreate the poetry environment. Poetry seems to be a specification that prioritizes reading the environment once it is created, so it will not be as I thought I would not recreate it by taking steps.
First, check the poetry settings.
The important thing here is virtualenvs.in-project
.
If you get an error, I think this is false
.
This setting is where to place the poetry installation, and if it is false
, it will be stored in the folder set in virtualenvs.path
. "
$ poetry config --list
cache-dir = "/Users/tasogarei/Library/Caches/pypoetry"
virtualenvs.create = true
virtualenvs.in-project = false
virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/tasogarei/Library/Caches/pypoetry/virtualenvs
Change virtualenvs.in-project
to true
.
This setting is to place the part to be installed by poetry in the root folder of the project, and by setting it to true
, it will be placed in the root folder.
$ poetry config virtualenvs.in-project true
Once created with the poetry specifications, even if the settings are changed, the file before the change will be viewed.
Therefore, there is no point in changing it unless you delete the folder in virtualenvs.path
.
So, please delete the entire folder of the project you want to read in the corresponding folder.
Now that you are ready, install the package again.
I started over from ʻinit just in case, but I don't need ʻinit
.
$ poetry install
When ʻinstall is complete, a
.venv` folder will be created at the root.
From now on, the package will be in here, and VS Code will read this folder nicely (no additional settings required), so I think the error disappears when you start it.
This completes the work.