WebFaction
Community site: login faq

asked 13 Jul '14, 09:26

ryans ♦♦
5.0k93460
accept rate: 43%

edited 06 Sep '14, 08:38


Virtual environments are now integrated into python 3.4. Previously, there was a bug that caused them to work in an unexpected way, but that's been fixed, and now I've been successfully using pyvenv-3.4 instead of virtualenv for python 3.4 virtual environments.

They work exactly as you'd expect:

pyvenv-3.4 myenv
cd myenv
source bin/activate
pip install django

The virtualenv package is deprecated, but it works too:

easy_install-3.4 virtualenv
virtualenv myenv
cd myenv
source bin/activate
pip install django

Here are the terminal captures for a full example:

#--- pyvenv ---

[user@server ~]$ pyvenv-3.4 myenv
[user@server ~]$ cd myenv
[user@server myenv]$ source bin/activate
(myenv) [user@server myenv]$ pip install django
Downloading/unpacking django
  Downloading Django-1.7-py2.py3-none-any.whl (7.4MB): 7.4MB downloaded
Installing collected packages: django
Successfully installed django
Cleaning up...
(myenv) [user@server myenv]$ python
Python 3.4.0 (default, Apr 22 2014, 12:11:21) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>>


#--- virtualenv ---

[user@server ~]$ easy_install-3.4 virtualenv
Searching for virtualenv
Reading https://pypi.python.org/simple/virtualenv/
Best match: virtualenv 1.11.6
Downloading https://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.11.6.tar.gz#md5=f61cdd983d2c4e6aeabb70b1060d6f49
Processing virtualenv-1.11.6.tar.gz
Writing /tmp/easy_install-9s7f3mes/virtualenv-1.11.6/setup.cfg
Running virtualenv-1.11.6/setup.py -q bdist_egg --dist-dir /tmp/easy_install-9s7f3mes/virtualenv-1.11.6/egg-dist-tmp-6nt2rkjv
warning: no previously-included files matching '*' found under directory 'docs/_templates'
warning: no previously-included files matching '*' found under directory 'docs/_build'
Adding virtualenv 1.11.6 to easy-install.pth file
Installing virtualenv-3.4 script to /home/user/bin
Installing virtualenv script to /home/user/bin
Installed /home/user/lib/python3.4/virtualenv-1.11.6-py3.4.egg
Processing dependencies for virtualenv
Finished processing dependencies for virtualenv
[user@server ~]$ virtualenv myenv
Using base prefix '/usr/local'
New python executable in myenv/bin/python3.4
Also creating executable in myenv/bin/python
Installing setuptools, pip...done.
[user@server ~]$ cd myenv/
[user@server myenv]$ source bin/activate
(myenv)[user@server myenv]$ pip install django
Downloading/unpacking django
  Downloading Django-1.7-py2.py3-none-any.whl (7.4MB): 7.4MB downloaded
Installing collected packages: django
Successfully installed django
Cleaning up...
(myenv)[user@server myenv]$ python
Python 3.4.0 (default, Apr 22 2014, 12:11:21) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>>
permanent link
This answer is marked "community wiki".

answered 13 Jul '14, 09:36

ryans ♦♦
5.0k93460
accept rate: 43%

edited 17 Sep '14, 02:26

Hm, actually this could be a bug:

[testuser@web430 bin]$ head -n1 ~/bin/pip
#!/home/testuser/myenv/bin/python3.4

For now, I'd use virtualenv and hold off on using pyvenv. Most packages don't have wheel support yet, and I'm not convinced that the new ~/bin/pip implementation works as intended (as shown above). I'm sure it'll be fixed eventually one way or another.

As far as I've been able to tell, virtualenv seems to work as expected with python 3.4 despite its deprecated status, and that's what I'd stick with until pyvenv is ready.

(13 Jul '14, 10:13) ryans ♦♦

It was a bug, and the Python community has fixed it.

Now, pyvenv-3.4 works exactly as you'd expect. I have updated the original post to convey the new (and correct) behavior.

(06 Sep '14, 08:27) ryans ♦♦

Awesome post mate!

I have been scratching my head over pythonbrew, pyenv, pyvenv and virtualenv!

Thank to the python community that things are getting easier for the novice. Just wanted to commend the post was well thought out.

Many thanks.

permanent link

answered 01 Oct '14, 18:11

Sean Knowles
11
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×55
×54
×6
×1

question asked: 13 Jul '14, 09:26

question was seen: 13,314 times

last updated: 01 Oct '14, 18:11

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2020 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM