Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I thought this would be simple, but I think I'm missing something easy.

I have python 2.7 installed in Ubuntu 12.04 via apt. I grabbed the source for python 2.6 and compiled it. I now have the following structure.

ll /usr/bin/python*
lrwxrwxrwx 1 root root       9 Apr 17  2012 /usr/bin/python -> python2.7*
lrwxrwxrwx 1 root root       9 Apr 17  2012 /usr/bin/python2 -> python2.7*
-rwxr-xr-x 1 root root 2799288 Aug  1 00:46 /usr/bin/python2.7*
-rwxr-xr-x 1 root root    1652 Aug  1 00:45 /usr/bin/python2.7-config*



/usr/local/bin$ ll
total 9120
drwxr-xr-x  2 root root    4096 Dec 17 20:35 ./
drwxr-xr-x 10 root root    4096 Oct  7  2010 ../
-rwxrwxr-x  1 root root     111 Dec 17 15:39 2to3*
-rwxr--r--  1 root root     246 Jan 19  2012 fixvpnroute*
-rwxrwxr-x  1 root root      99 Dec 17 15:39 idle*
-rwxrwxr-x  1 root root      84 Dec 17 15:39 pydoc*
-rwxr-xr-x  2 root root 4637487 Dec 17 20:35 python*
-rwxr-xr-x  2 root root 4637487 Dec 17 20:35 python2.6*
-rwxr-xr-x  1 root root    1424 Dec 17 20:35 python2.6-config*
lrwxrwxrwx  1 root root      16 Dec 17 20:35 python-config -> python2.6-config*
-rwxrwxr-x  1 root root   18233 Dec 17 15:39 smtpd.py*
-rwxr-xr-x  1 root root     316 Dec 17 15:54 virtualenv*
-rwxr-xr-x  1 root root     324 Dec 17 15:54 virtualenv

I installed virtualenv using pip before installing python 2.6. Now, when I try to use virtualenv, I get an error.

sudo virtualenv -p /usr/local/bin/python2.6 testproject
Running virtualenv with interpreter /usr/local/bin/python2.6
New python executable in testproject/bin/python2.6
Not overwriting existing python script testproject/bin/python (you must use testproject/bin/python2.6)
Installing setuptools.............
  Complete output from command /home/greg/Projects/...roject/bin/python2.6 -c "#!python
\"\"\"Bootstra...sys.argv[1:])






" --always-copy -U setuptools:
  -c:67: DeprecationWarning: the md5 module is deprecated; use hashlib instead
Traceback (most recent call last):
  File "<string>", line 67, in <module>
  File "/usr/local/lib/python2.6/md5.py", line 10, in <module>
    from hashlib import md5
  File "/usr/local/lib/python2.6/hashlib.py", line 138, in <module>
    sha224 = __get_builtin_constructor('sha224')
  File "/usr/local/lib/python2.6/hashlib.py", line 66, in __get_builtin_constructor
    import _sha256
ImportError: No module named _sha256
----------------------------------------
...Installing setuptools...done.
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 2560, in <module>
    main()
  File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 964, in main
    never_download=options.never_download)
  File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 1074, in create_environment
    search_dirs=search_dirs, never_download=never_download)
  File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 611, in install_setuptools
    search_dirs=search_dirs, never_download=never_download)
  File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 583, in _install_req
    cwd=cwd)
  File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 1042, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command /home/greg/Projects/...roject/bin/python2.6 -c "#!python
\"\"\"Bootstra...sys.argv[1:])






" --always-copy -U setuptools failed with error code 1

So then I tried to install setuptools with pip, but...

sudo pip install setuptools
Requirement already satisfied (use --upgrade to upgrade): distribute in /usr/lib/python2.7/dist-packages
Cleaning up.

So, I think my issue has to do with running pip in the context of python 2.6, but I'm not sure how to do that. Am I on track? ..

Edit

Recompiling Python 2.6 with the sha modules uncommented was the solution.

In the source directory, I edited Modules/Setup, and uncommented these lines.

# The _sha module implements the SHA checksum algorithms.
# (NIST's Secure Hash Algorithms.)
_sha shamodule.c
_sha256 sha256module.c
_sha512 sha512module.c

Then reran configure and make install.

share|improve this question

migrated from stackoverflow.com Dec 18 '12 at 7:17

This question came from our site for professional and enthusiast programmers.

You must log in to answer this question.

Browse other questions tagged .