#2 No module named DenyHosts.python_version

open
nobody
5
2014-08-22
2006-10-02
Mike Robinson
No

I followed all of the steps for installation from this
site (except the `update-rc.d denyhosts defaults`
command since I'm using CentOS):
http://www.howtoforge.com/preventing_ssh_dictionary_attacks_with_denyhosts

I get an error when I try to run DenyHosts:

root@duck [/usr/local/bin]# /etc/init.d/denyhosts start
starting DenyHosts: /usr/bin/env python
/usr/local/bin/denyhosts.py --daemon
--config=/usr/share/denyhosts/denyhosts.cfg
Traceback (most recent call last):
File "/usr/local/bin/denyhosts.py", line 5, in ?
import DenyHosts.python_version
ImportError: No module named DenyHosts.python_version

in my /usr/local/bin/denyhosts.py the first line is:
#!/usr/local/bin/python

I tried changing this (even to incorrect paths) and I
still get the same error. I know this is the correct path:

root@duck [/usr/local/bin]# ls -la
total 16188
drwxr-xr-x 2 root root 4096 Oct 2 11:13 ./
drwxr-xr-x 21 root root 4096 Sep 29 12:38 ../
-rwxr-xr-x 1 root root 6587 Oct 2 12:17
denyhosts.py*
lrwxrwxrwx 1 root root 19 Jun 18 2005
freshclam -> ../../bin/freshclam*
-rwxr-xr-x 1 root root 96 Sep 5 21:46
idle*
-rwxr-xr-x 1 root root 1198 Sep 29 14:05
pcre-config*
-rwxr-xr-x 1 root root 28064 Sep 29 14:05
pcregrep*
-rwxr-xr-x 1 root root 40349 Sep 29 14:05
pcretest*
-rwxr-xr-x 1 root root 666 Jun 16 2005
pear*
lrwxrwxrwx 1 root root 13 Jun 16 2005
perl -> /usr/bin/perl*
-rwxr-xr-x 1 root root 9895926 Jun 17 2005
php*
-rwxr-xr-x 1 root root 1148 Jun 17 2005
php-config*
-rwxr-xr-x 1 root root 593 Jun 17 2005
phpextdist*
-rwxr-xr-x 1 root root 3060 Jun 17 2005
phpize*
-rwxr-xr-x 1 root root 81 Sep 5 21:46
pydoc*
-rwxr-xr-x 2 root root 2416740 Sep 5 21:46
python*
-rwxr-xr-x 2 root root 2416740 Sep 5 21:46
python2.4*
-rwxr-xr-x 1 root root 18017 Sep 5 21:46
smtpd.py*
-rwxr-xr-x 1 root root 1673506 Sep 29 14:06
snort*

I also tried with /usr/local/bin/python2.4 and get the
same error.

I'm stuck with this error. Any advice would be great.

Discussion

  • Logged In: NO

    I have the same error. Using Centos with Cpanel.

     
  • Logged In: NO

    Well, I fixed the problem. Apparently, I had to do this:

    In the daemon-control file, I edited it with this line

    PYTHON_BIN = "/usr/bin/env python"

    changed to

    PYTHON_BIN = "/usr/bin/env python2.4"

    That's all I had to do. No other editing.

    Oh, and a nonrelated issue is in denyhosts.cfg where in stock
    configuration the SECURE_LOG declaration for the Macintosh wasn't
    uncommented. Just added a # to comment out. if you don't,
    you'll get an error that isn't of the focus of this discussion.

     
  • Apollo
    Apollo
    2006-11-25

    Logged In: YES
    user_id=1653669
    Originator: NO

    I had the same problem, I solved it by executing denyhosts.py explicity "/usr/local/bin/python2.3 /usr/local/bin/denyhosts.py" and that worked then.

     
  • Mike Robinson
    Mike Robinson
    2006-11-25

    Logged In: YES
    user_id=1611574
    Originator: YES

    Using the suggestion made on 2006-11-08, I got this to work. Thanks for all your comments.

     
  • Ecki77
    Ecki77
    2007-05-17

    Logged In: YES
    user_id=1795302
    Originator: NO

    I have the same Problem!
    Installed Python 2.5 and denyhosts 2.6.
    When ich will get started, i became this error:

    starting DenyHosts: /usr/local/bin/python /usr/bin/denyhosts.py --daemon --config=/usr/share/denyhosts/denyhosts.cfg
    Traceback (most recent call last):
    File "/usr/bin/denyhosts.py", line 6, in <module>
    import DenyHosts.python_version
    ImportError: No module named DenyHosts.python_version

    I have changed Line 1&18 to the correkt Files:
    /usr/local/bin/python2.5

    It will not correctly works:(
    The suggestion made on 2006-11-08 will not help me.

    Excuse me for my english;)

     
  • Paul Franz
    Paul Franz
    2009-03-04

    The error is caused from not having the denyhosts files in the correct directory
    ./site-packages/DenyHosts/

    Using the install script provided when you have multiple python installations won't work. For example it did this:

    /usr/lib/python2.5/site-packages/DenyHosts/denyfileutil.py

    When it should have done this:

    /usr/local/lib/python2.5/site-packages/DenyHosts/denyfileutil.py

    I have modified the README.txt file to reflect what worked for me.
    <http://eucleides.com/~paul/DenyHosts/README.txt>
    and modified the answer to FAQ question 1.9:
    <http://eucleides.com/~paul/DenyHosts/faq.html#1_9>

    I also wrote the author but have not received a response.