Using Virtualenv with Python 3

Hello,

I just installed openSUSE 12.3 and was trying to setup a Python development environment, so I installed the following packages:

python3, python3-devel, python3-pip

.

Then I used pip to install virtualenv:

sudo pip-3.3 install virtualenv

When I now try to create a virtualenv via

virtualenv-3.3 ~/virtualenvs/venv01

I get the following error message:


Installing distribute.........................................................................................................................................................................................................................................................................................................................................................................................................done.
Installing pip....
  Complete output from command /home/name/virtualenvs/venv01/bin/python3 -x /home/name/virtua...v01/bin/easy_install /usr/local/lib/pytho...ort/pip-1.3.1.tar.gz:
  /home/name/virtualenvs/venv01/bin/python3: can't open file '/home/name/virtualenvs/venv01/bin/easy_install': [Errno 2] No such file or directory
----------------------------------------
...Installing pip...done.
Traceback (most recent call last):
  File "/usr/local/bin/virtualenv", line 9, in <module>
    load_entry_point('virtualenv==1.9.1', 'console_scripts', 'virtualenv')()
  File "/usr/local/lib/python3.3/site-packages/virtualenv.py", line 979, in main
    no_pip=options.no_pip)
  File "/usr/local/lib/python3.3/site-packages/virtualenv.py", line 1094, in create_environment
    install_pip(py_executable, search_dirs=search_dirs, never_download=never_download)
  File "/usr/local/lib/python3.3/site-packages/virtualenv.py", line 667, in install_pip
    filter_stdout=_filter_setup)
  File "/usr/local/lib/python3.3/site-packages/virtualenv.py", line 1057, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command /home/name/virtualenvs/venv01/bin/python3 -x /home/name/virtua...v01/bin/easy_install /usr/local/lib/pytho...ort/pip-1.3.1.tar.gz failed with error code 2

This seem to a problem due to the fact that openSUSE sets a default distutils prefix (https://en.opensuse.org/openSUSE:Packaging_Python#File_locations).

Due to this prefix distribute is not installed into the directories venv01/lib/python3.3/site-packages and venv01/bin but instead into the directories venv01/local/lib/python3.3/site-packages and venv01/local/bin.

Is there an easy way to fix this and make virtualenv work in openSUSE?

This is a really essential tool for my Python development and I would sorely miss it :(.

Thanks in advance for any help.

i have the same problem. don’t have a solution yet, but thanks for posting - good to know i am not alone!

https://bugzilla.novell.com/show_bug.cgi?id=809831

kind-of obvious, but you can work-around this by installing everything yourself (starting with Python 3.3).

instructions at Andrew Cooke: C[omp]ute

Thanks Andrew, that’s probably the easiest solution.

I attempted messing with local pydistutils.cfg files, but could not really get it working.

So will simply reinstall my own python according to your instructions.

hello folks, thanks for discovering the problem.

i pushed a fixed package into devel:languages:python:Factory OBS repository, so as soon as the rebuild finishes you can install python3 from there. (that might be a good idea anyway, if you don’t want to wait for official updates)

alternately, for a workaround on existing installations that doesn’t involve rebuilding the whole of python, download this:
http://users.suse.cz/~jmatejek/fix-virtualenv.patch
and use it, as root, like this - assuming you are on a 64bit system and that you downloaded the file to your home directory:

# cd /usr/lib64/python
# patch -p1 < ~/fix-virtualenv.patch

Hi matejcik,

Awesome that you actually could fix this bug!

However it seems that the website you hosted the patch on is down.
Would you care to upload it again? I would really like to take a look where the problem actually came from.

Thanks again for your awesome work :).

Cheers,

Gjallar

ah, sorry about that. apparently that URL is internal only.
this one should work right: http://paste.opensuse.org/view/download/bf0feecd
(except it apparently doesn’t give you the right filename, as it’s from a pastebin: http://paste.opensuse.org/bf0feecd
oh well, i’m sure you can work with that too ;e) )