Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

poetry install doesnt create .env folder inside project folder with Anaconda python 3.9 env

I have anaconda 3.8 on windows 10. I created python3.9 virtual environment and set poetry config virtualenvs.in-project true. But when I do poetry install it doesnt create the .envn folder inside the project. Below is the poetry env info results:

(python39) C:\Users\username\Developer\Packages\test5>poetry env info

Virtualenv

Python:         3.9.6

Implementation: CPython

Path:           C:\Users\username\Anaconda3\envs\python39

Valid:          True


System

Platform: win32

OS:       nt

Python:   C:\Users\username\Anaconda3\envs\python39***

However, when deactivate the python39 environment and run poetry install it creates the .envn folder inside project. and the poetry env info results the following:

Virtualenv

Python: 3.9.6

Implementation: CPython

Path: C:\Users\username\Developer\Packages\test2\.venv

Valid: True


System

Platform: win32

OS: nt

Python: C:\Users\username\Anaconda3\envs\python39

how can I make it work in python39 environment?

like image 373
pw_machine_vision Avatar asked Jul 26 '26 05:07

pw_machine_vision


1 Answers

This is an expected behavior. Whenever poetry detect it's running within a virtual environment it will not create a new one ( Exception: condas "base" environment is not detected as a virtual environment).

To create an in-project venv for python3.9 using conda you can do this:

  • set the config to virtualenvs.in-project true
  • without being in a venv run poetry env use /path/to/python3.9 once
  • run poetry install

Also have a look into the docs about poetry env use.

(Question and are answer are cross-posted in poetry's issue tracker)

like image 113
finswimmer Avatar answered Jul 30 '26 00:07

finswimmer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!