Cannot find HashLib module after server upgrade

I am running Python scripts on our Dreamhost server. Our Python scripts use Python 2.7 - we created a custom installation because Dreamhost uses Python 2.6. Everything worked fine for 1 year.

Dreamhost made a yesturday server update, and now our scripts cannot find a specific module - MD5. The scripts output the error below when we go to import hashlib.

What do I need to do to fix this?

  • Should I reinstall Python 2.7?
  • Should I reinstall Pip and Easy_Install?
  • Should I reinstall VirtualEnv?
  • Is there anything else you recommend to me?

The error of all Python scripts:

/home/user/script.py in () 
  import hashlib  
  hashlib undefined    

/home/user/python/lib/python2.7/hashlib.py in ()  
    # version not supporting that algorithm.  
    try:  
        globals()[__func_name] = __get_hash(__func_name)  
    except ValueError:  
        import logging builtin globals = <built-in function globals, __func_name = 'md5', __get_hash = <function __get_builtin_constructor  /home/user/python/lib/python2.7/hashlib.py in __get_builtin_constructor(name='md5')  
        return _sha.new  
    elif name in ('MD5', 'md5'):  
        import _md5  
         return _md5.new  
     elif name in ('SHA256', 'sha256', 'SHA224', 'sha224'):  
 _md5 undefined  

<type 'exceptions.ImportError': No module named _md5  
   args = ('No module named _md5',)  
   message = 'No module named _md5' 
+4
1

. Python 2.7 virtualenv. python Django 1.7.

.

1. ( )

pythonbrew, : http://wiki.dreamhost.com/Python pythonbrew . , pyenv - , virtualenv .. pythonbrew .

$ rm -Rf ~/.pythonbrew

.bashrc pythonbrew

2.

virtualenv. env

$~/env> virtualenv myNewEnvironment
$~/env/myNewEnvironment/bin> source activate
$ pip freeze

, . , "import hashlib". python, Ubuntu.

(myNewEnvironment):~> which python
~/env/myNewEnvironment/bin/python
(myNewEnvironment):~> python
Python 2.7.3 (default, Feb 27 2014, 19:58:35)  
[GCC 4.6.3] on linux2
installed on Ubuntu 12.04 (which is the new OS)

, :   import hashlib

3.

pip install Django
pip install MySQL-python

, , / , http://wiki.dreamhost.com/Django ( wiki )

() , : ; , . 'python manage.py migrate', .

!

+5

All Articles