asdf-community / asdf-python

Python plugin for the asdf version manager
https://github.com/asdf-vm/asdf
MIT License
656 stars 56 forks source link

How to use pyenv virtualenv? #64

Closed viniciusban closed 4 years ago

viniciusban commented 4 years ago

Is there a way to use pyenv virtualenv with asdf-python?

I don't pollute the global Python environment with my packages. So, I create a virtualenv using pyenv virtualenv:

$ pyenv virtualenv 3.7.6 jupyter
$ pyenv activate jupyter
(jupyter) $ pip install jupyter matplotlib pandas scipy
(jupyter) $ pyenv deactivate
$ pyenv global 3.7.6 jupyter

Is there a way to achieve that with asdf-python?

Thanks in advance.

alesso-x commented 4 years ago

You can use the builtin venv command to create virutalenvs python -m venv jupyter. It will use the existing python in your path, make sure to change python version asdf shell python 3.7.6.

danhper commented 4 years ago

I am not familiar with pyenv virtualenv but the builtin venv module should indeed work without any issue. Please comment if you think this should be reopened.

viniciusban commented 4 years ago

Unfortunately, this suggestion does not work.

The caveat is having more than one python "version" active at the same time.

With the pyenv-virtualenv plugin, pyenv recognizes a virtualenv as if it was a python version, allowing me to do this:

$ pyenv global 3.7.6 jupyter_venv

Notice I am setting 3.7.6 and jupyter_venv at the same time as global python versions.

The command above sets the path in a way that if I issue the command $ jupyter, it will search it in the vanilla python 3.7.6 and, if not found, search for it inside the jupyter_venv.

I could not achieve it with asdf.

gabrielmancini commented 4 years ago

i think is a little trick to use env @danhper @alessod

i have a different experience but i think is related, so let me put here my bootstrap

asdf plugin-add python
asdf install python 3.8.2
asdf global python 3.8.2
asdf plugin-add pip
asdf install pip
asdf reshim python
pip install --upgrade pip
pip install virtualenv
asdf reshim python

before u will sufering sudo apt-get install (find de erros depends of de os)

cd mystuff
virtualenv venv -p python3
source venv/bin/activate
pip install -f requirements.txt
scrapy crawl myspyder

requirements.txt

appdirs==1.4.3
attrs==19.3.0
Automat==20.2.0
cffi==1.14.0
constantly==15.1.0
cryptography==2.9.2
cssselect==1.1.0
distlib==0.3.0
filelock==3.0.12
hyperlink==19.0.0
idna==2.9
appdirs==1.4.3
attrs==19.3.0
Automat==20.2.0
cffi==1.14.0
constantly==15.1.0
cryptography==2.9.2
cssselect==1.1.0
distlib==0.3.0
filelock==3.0.12
hyperlink==19.0.0
idna==2.9
incremental==17.5.0
lxml==4.5.0
numpy==1.18.4
pandas==1.0.3
parsel==1.5.2
Protego==0.1.16
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycparser==2.20
PyDispatcher==2.0.5
PyHamcrest==2.0.2
pyOpenSSL==19.1.0
python-dateutil==2.8.1
pytz==2020.1
queuelib==1.5.0
Scrapy==2.1.0
service-identity==18.1.0
six==1.14.0
Twisted @ git+git://github.com/twisted/twisted.git@6d5ea4d4cc980ecf90cc05643fd9ff14e8b4d05d
virtualenv==20.0.20
w3lib==1.21.0
zope.interface==5.1.0

i had a this error

File "/home/xxx/.asdf/installs/python/3.8.2/lib/python3.8/bz2.py", line 19, in <module>
    from _bz2 import BZ2Compressor, BZ2Decompressor
ModuleNotFoundError: No module named '_bz2'
darkn3rd commented 7 months ago

Is .python-version supported with support for virtualenv?