# Certbot failing due to Python Module [SOLVED]

## CM73

I had certbot running without issue for about a year now, but I seemed to have screwed something up:

```
$certbot renew

Traceback (most recent call last):

  File "/usr/lib/python-exec/python3.4/certbot", line 11, in <module>

    load_entry_point('certbot==0.21.0.dev0', 'console_scripts', 'certbot')()

  File "/usr/lib/python3.4/site-packages/pkg_resources/__init__.py", line 560, in load_entry_point

    return get_distribution(dist).load_entry_point(group, name)

  File "/usr/lib/python3.4/site-packages/pkg_resources/__init__.py", line 2642, in load_entry_point

    return ep.load()

  File "/usr/lib/python3.4/site-packages/pkg_resources/__init__.py", line 2296, in load

    return self.resolve()

  File "/usr/lib/python3.4/site-packages/pkg_resources/__init__.py", line 2302, in resolve

    module = __import__(self.module_name, fromlist=['__name__'], level=0)

  File "/usr/lib/python3.4/site-packages/certbot/main.py", line 9, in <module>

    import josepy as jose

ImportError: No module named 'josepy'
```

certbot throws the same error regardless of the argument - so the 'renew' isn't the issue. 

I'm not entirely sure what I did to break it. I recently uninstalled the np-hardass-overlay as well as tiny-acme, and I *think* the "josephy" module was related to that. I've also tried re-emerging certbot and certbot-apache - and it emerges without error, but still throws the same ImportError when I try to run it. I don't have issues with portage (emerge works fine and I can update the system), so I don't think it's python related. 

Any ideas would be appreciated.

[UPDATE]

So I completely uninstalled both app-crypt/acme and app-crypt/certbot and re-emerged them. Now I'm getting a similar but slightly different error:

```
Traceback (most recent call last):

  File "/usr/lib/python-exec/python3.4/certbot", line 6, in <module>

    from pkg_resources import load_entry_point

  File "/usr/lib/python3.4/site-packages/pkg_resources/__init__.py", line 3030, in <module>

    @_call_aside

  File "/usr/lib/python3.4/site-packages/pkg_resources/__init__.py", line 3014, in _call_aside

    f(*args, **kwargs)

  File "/usr/lib/python3.4/site-packages/pkg_resources/__init__.py", line 3043, in _initialize_master_working_set

    working_set = WorkingSet._build_master()

  File "/usr/lib/python3.4/site-packages/pkg_resources/__init__.py", line 654, in _build_master

    ws.require(__requires__)

  File "/usr/lib/python3.4/site-packages/pkg_resources/__init__.py", line 968, in require

    needed = self.resolve(parse_requirements(requirements))

  File "/usr/lib/python3.4/site-packages/pkg_resources/__init__.py", line 854, in resolve

    raise DistributionNotFound(req, requirers)

pkg_resources.DistributionNotFound: The 'josepy>=1.0.0' distribution was not found and is required by acme
```

Perhaps there is something up with the certbot package itself?  Unless I'm wrong, I think it should be pulling in this dependency.Last edited by CM73 on Thu Dec 21, 2017 2:28 pm; edited 1 time in total

----------

## Fooligan

I had the same problem but now seem to have solved it.

Which version of certbot and certbot-apache are you running?

When I installed it I used the howto found here https://wiki.gentoo.org/wiki/Let%27s_Encrypt . This installed the 9999 version for both packages for me.

I removed the 9999 permissions from /etc/portage/package.accept_keywords and reinstalled (downgraded) both packages. This also pulled in a downgrade for acme.

After this all seems to work as it should be.

----------

## CM73

So I went back and looked and I set this up back in Nov 2016. I also followed the guide, and I remember running into a couple of issues, but I honestly don't remember all of the details. 

Right now, I'm also pulling from certbot-9999 and acme-9999. So maybe it is an issue with the latest package after all. 

Thanks for the help (both here and in the Let's Encrypt forums)!

----------

## Fooligan

Hi CM73,

Please go to /etc/portage/package.accept_keywords and remove the lines mentioning certbot, certbot-apache and acme. If you then re-install the packages they should downgrade to the "stable" versions. After this everything works as before. (9999 versions are test versions)

----------

## CM73

That did it. The cert renewed without an issue. 

Thank you, THANK YOU! I really appreciate it.

----------

## Fooligan

My pleasure!

----------

## duus

I got it to upgrade cleanly by patching the ebuild of josepy

```

diff --git a/usr/portage/dev-python/josepy/josepy-1.0.1.ebuild b/dev-python/josepy/josepy-1.0.1.ebuild

index 115d502..6250583 100644

--- a/usr/portage/dev-python/josepy/josepy-1.0.1.ebuild

+++ b/dev-python/josepy/josepy-1.0.1.ebuild

@@ -16,6 +16,7 @@ KEYWORDS="~amd64 ~arm ~ppc64 ~x86"

 IUSE=""

 DEPEND="

+       !<=app-crypt/acme-0.20.0[${PYTHON_USEDEP}]

        >=dev-python/setuptools-1.0[${PYTHON_USEDEP}]

        >=dev-python/cryptography-0.8[${PYTHON_USEDEP}]

        >=dev-python/pyopenssl-0.13[${PYTHON_USEDEP}]

```

----------

