Closed haoyun closed 2 years ago
pdm venv create -v -w conda 3.9
To see what command is being run.
pdm venv create -v -w conda 3.9
I am sorry that I might made some mistakes. But there are still some "strange" behaviors (see examples below)
What I would like to do is to specify a different python version from that I am using, e.g, I have /usr/bin/python
of version 3.9
. Now I would like to create a conda venv of version 3.8
.
$ which python
/usr/bin/python
$ python --version
Python 3.9.7
$ pdm venv create -v -w conda 3.8
[VirtualenvCreateError]: Can't find python interpreter 3.8 <-------------------- Problem A
$ pdm venv create -v -w conda 3.9
Run command: ['conda', 'create', '--yes', '--prefix', '/$HOME/.local/share/pdm/venvs/project-quiNeM0n-3.9', 'pip', 'python=3.9']
<------------------- OK
$ pdm venv remove 3.9
$ conda create -y -n test python=3.8
$ conda activate test
$ which python
~/.conda/envs/test/bin/python
$ python --version
Python 3.8.12
$ pdm venv create -v -w conda 3.10
[VirtualenvCreateError]: Can't find python interpreter 3.10 <-------------------- Problem B
$ pdm venv create -v -w conda
Run command: ['conda', 'create', '--yes', '--prefix', '$HOME/.local/share/pdm/venvs/project-quiNeM0n-3.8', 'pip', 'python']
...
The following NEW packages will be INSTALLED:
...
python pkgs/main/linux-64::python-3.10.0-h151d27f_3 <-------------------- Problem C.1
...
$ pdm venv list
Virtualenvs created with this project:
- 3.8: $HOME/.local/share/pdm/venvs/project-quiNeM0n-3.8 <-------------------- Problem C.2
...
$ pdm venv create -v -w conda 3.8
[VirtualenvCreateError]: The location $HOME/.local/share/pdm/venvs/project-quiNeM0n-3.8 is not empty
<-------------------- Problem C.3
$ pdm venv remove 3.8
$ pdm venv create -v -w conda 3.8
Run command: ['conda', 'create', '--yes', '--prefix', '$HOME/.local/share/pdm/venvs/project-quiNeM0n-3.8', 'pip', 'python=3.8']
<------------------- OK
$ pdm venv create -v -w conda 3.9
Run command: ['conda', 'create', '--yes', '--prefix', '$HOME/.local/share/pdm/venvs/project-quiNeM0n-3.9', 'pip', 'python=3.9']
<------------------- OK
$ pdm venv create -vw conda 3.9 python=3.10
Run command: ['conda', 'create', '--yes', '--prefix', '$HOME/.local/share/pdm/venvs/project-quiNeM0n-3.9', 'pip', 'python=3.10', 'python=3.9']
[VirtualenvCreateError]: Command '['conda', 'create', '--yes', '--prefix', '$HOME/.local/share/pdm/venvs/project-quiNeM0n-3.9', 'pip', 'python=3.10', 'python=3.9']' returned non-zero exit status 1.
<-------------------- Problem D
$ pdm venv remove 3.8
$ pdm venv remove 3.9
$ pdm install
use_venv is on, creating a virtualenv for this project... <---------- Problem E
You might have a look at the above.
If I only have python 3.9
, then I am not able to create a 3.8
venv with conda (Problem A). However conda
is able to do this with conda create python=3.8
. Then I create one and activate it.
Now I have python 3.8
. Of course, I can not create a 3.10
venv with conda using pdm-venv
(Problem B). This is the same as Problem A
But if I execute pdm venv create -w conda
, a venv with python 3.10
is created (Problem C.1). Meanwhile, pdm
thought I am create a venv with python 3.8
, as the name suggests (Problem C.2). Now I cannot even create a 3.8
venv using the expected command pdm venv create -w conda 3.8
, as the path is nonempty now, with 3.10
installed (Problem C.3). I have to remove the incorrect one.
What I am expecting is:
pdm venv create -w conda 3.x
could create a 3.x
venv using conda create python=3.x
, no matter which interpreter I am currently using.
Or better, pdm
could detect that I am currently using a conda venv, so instead of creating a new one (Problem E), just use the existing one.
Can you help test on the main branch? Thanks in advance
When create a venv with
conda
, why do we still need to specify the python interpreter? Shouldn'tconda
take care of it? Currently, on my machine, with/usr/bin/python
(3.9):conda
will installpython 3.10
, it makes no sense to specify 3.9 here.Only with
can I install
python 3.8.12
. Again,3.9
here in the command line makes no sense.