Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Python-3-only virtualenvwrapper

136 views
Skip to first unread message

Lumír Balhar

unread,
Mar 19, 2018, 9:26:00 AM3/19/18
to virtualenvwrapper
Hello.

I recently met a bug when trying to use virtualenvwrapper in Python-3-only environment. From `virtualenvwrapper.sh` it's obvious that it depends on Python 2 and you have to define `VIRTUALENVWRAPPER_PYTHON` environment variable to use other Python but even then it won't work because there is also a dependency on `virtualenv` command which is provided by Python 2 virtualenv package.

I am using Fedora and of course, we can do some hacks to support Python 3 only environments based on Fedora, but I would prefer to adress this need in upstream. As published last week, Python 2 EOL will be 1/1/2020 and I'd like my favorite tool to be ready for Python 3.

I can imagine two new scripts `virtualenvwrapper-2.sh` and  `virtualenvwrapper-3.sh` which would both source `virtualenvwrapper.sh` but with some variables setting in advance which will make wrapper to point to right binaries.

 What do you think about it? I can try to implement my idea and prepare pull request.

Have a nice day.
Lumír

Jason Myers

unread,
Mar 19, 2018, 10:15:42 AM3/19/18
to virtuale...@googlegroups.com
Virtualenv is a python package that you have to install and it does support Python 3. I'm using both it and virtualenvwrapper on python3 every day on Pop_Os and Mac OS X. Can you share the exact error you are running into and let's see if we can help resolve your issue?

Cheers,
Jason


--
You received this message because you are subscribed to the Google Groups "virtualenvwrapper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to virtualenvwrapper+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted
Message has been deleted
Message has been deleted

Gary Oberbrunner

unread,
Jan 24, 2019, 9:57:38 PM1/24/19
to virtualenvwrapper
I suspect part of Lumir's problem is that python3.7 no longer provides the `virtualenv` command; users are supposed to use python3 -mvenv instead. (Similarly to how "pip" is being phased out in favor of "python -mpip".) See issue #320.
To unsubscribe from this group and stop receiving emails from it, send an email to virtualenvwrap...@googlegroups.com.

Lumír Balhar

unread,
Jan 29, 2019, 5:45:23 AM1/29/19
to virtualenvwrapper
I did a test again on Fedora rawhide which comes with only Python 3.

$ pip3 --version
pip
18.0 from /usr/lib/python3.7/site-packages/pip (python 3.7)

$ pip3 install
--user virtualenvwrapper

$
export WORKON_HOME=$HOME/.virtualenvs
$
export PROJECT_HOME=$HOME/Devel

$ source
.local/bin/virtualenvwrapper.sh
which
: no python in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin)
bash
: : command not found
virtualenvwrapper
.sh: There was a problem running the initialization hooks.

If Python could not import the module virtualenvwrapper.hook_loader,
check that virtualenvwrapper has been installed
for
VIRTUALENVWRAPPER_PYTHON
= and that PATH is
set properly

As you can see in PEP 394 (https://www.python.org/dev/peps/pep-0394), /usr/bin/python still has to be a symlink pointing to python2 so when a distro comes without python2 by default, there is no /usr/bin/python.

This patch changes the default binary in virtualenvwrapper RPM package in Fedora to work properly in python3-only environment.

IMHO virtualenvwrapper should check whether python3 is available or not and if so, use them. Otherwise, use a fallback to python2.

Doug Hellmann

unread,
Feb 2, 2019, 11:19:16 AM2/2/19
to virtuale...@googlegroups.com
I think we would be happy to review patches to add that feature. Let us know if you’re interested in working on it and need help getting started.

Doug

Lumír Balhar

unread,
Feb 19, 2019, 8:48:24 AM2/19/19
to virtualenvwrapper
I've prepared a pull request: https://bitbucket.org/virtualenvwrapper/virtualenvwrapper/pull-requests/73/find-the-highest-python-version-with/diff

Dne sobota 2. února 2019 17:19:16 UTC+1 Doug Hellmann napsal(a):
Reply all
Reply to author
Forward
0 new messages