Search code examples
pythonlinuxlets-encryptamazon-linux

letsencrypt failed with ImportError: No module named interface


I'm using Amazon linux, and I followed some steps for using letsencrypt that easily found in google search, but all it fails with:

Error: couldn't get currently installed version for /root/.local/share/letsencrypt/bin/letsencrypt: 
Traceback (most recent call last):
  File "/root/.local/share/letsencrypt/bin/letsencrypt", line 7, in <module>
    from certbot.main import main
  File "/root/.local/share/letsencrypt/local/lib/python2.7/dist-packages/certbot/main.py", line 11, in <module>
    import zope.component
  File "/root/.local/share/letsencrypt/local/lib/python2.7/dist-packages/zope/component/__init__.py", line 16, in <module>
    from zope.interface import Interface
ImportError: No module named interface

What I do is:

# git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt
# /opt/letsencrypt/letsencrypt-auto --debug

That's it. So I tried to fix this, but dozens of solution that I found all won't worked to me.

Most of them said try this:

unset PYTHON_INSTALL_LAYOUT

But still got same error, nothing changes. And someone said that type this:

pip install --upgrade pip

But after typed that, I can't use pip anymore, it failed with some kind of command not found error, so I had recreated my server again.

I also tried to use CertBot, but it gives me exactly same error!

I'm using Linux 4.4.51-40.58.amzn1.x86_64 x86_64, need a help. I spent almost a day, but nothing progressed.

Every solution that I was found were not worked to me. Any advice will very appreciate it.


Solution

  • I had same issue and after a long run, a very simple thing solved this issue on my AWS instance:

    1. Move the letsencrypt cache files to another folder (considering you run it as root/sudo):

      sudo mv /root/.local/share/letsencrypt /root/.local/share/letsencrypt-old

    2. Downloaded a brand new version of letsencrypt

      git clone https://github.com/letsencrypt/letsencrypt

    3. Run the letsencrypt command to test if its working again:

      sudo ./letsencrypt-auto --debug

    During my search for a solution I also updated pip which might have helped. Although my attempts after pip update did not solved my issue in the same way as cleaning up the letsencnrypt cache folder.

    I hope this helps. If not, some links I can share about same issue: