1

Recently, my certbot installation through pip/virtualenv has stopped working. It claims to not be able to find a specific module, even though pip can see the module in question. Is there a way that I can force the package to "see" the module in a directory it doesn't necessarily expect?

I'm in a unique situation with a shared hosting environment, so I don't really have the ability to edit system files, or install new system packages. This means I cannot use the recommended methods to install certbot, due to lack of permissions. For years, in this same environment, I have successfully used the pip-installed certbot to generate certificates for my services. Recently, for some unknown reason, it stopped working.

Here is the error message, run in the virtualenv that certbot was installed to:

$ source ~/virtualenv3/bin/activate

(virtualenv3) $ certbot
Traceback (most recent call last):
  File "/home/USERNAME/virtualenv3/bin/certbot", line 5, in <module>
    from certbot.main import main
  File "/home/USERNAME/virtualenv3/lib/python3.7/site-packages/certbot/main.py", line 2, in <module>
    from certbot._internal import main as internal_main
  File "/home/USERNAME/virtualenv3/lib/python3.7/site-packages/certbot/_internal/main.py", line 11, in <module>
    import zope.component
  File "/home/USERNAME/virtualenv3/lib/python3.7/site-packages/zope/component/__init__.py", line 25, in <module>
    from zope.interface import Interface
ModuleNotFoundError: No module named 'zope.interface'

But, the thing is, the module in question already exists. It's just in a system directory.

(virtualenv3) $ pip install zope.interface
Requirement already satisfied: zope.interface in /usr/lib/python3.7/site-packages (5.1.0)
Requirement already satisfied: setuptools in ./virtualenv3/lib/python3.7/site-packages (from zope.interface) (49.1.0)

(virtualenv3)  $ pip list zope.interface
zope.interface      5.1.0

(virtualenv3) $ pip show zope.interface
Name: zope.interface
Version: 5.1.0
Summary: Interfaces for Python
Home-page: https://github.com/zopefoundation/zope.interface
Author: Zope Foundation and Contributors
Author-email: zope-dev@zope.org
License: ZPL 2.1
Location: /usr/lib/python3.7/site-packages
Requires: setuptools
Required-by: zope.proxy, zope.component, certbot

There is what seems to be a similar problem reported officially for certbot, but it's not exactly the same issue, and since the package is actually on the server, I felt like this was probably a personal problem rather than the same. I tried some of the recommended fixes:

pip install pip -U
pip install virtualenv -U
pip install zope.interface -U
pip install certbot -U

Didn't help. So, I can't install the package in pip, because it says it's already satisfied. But the certbot package itself can't see it. How do I tell the package where the zope.interface module is actually located?

  • 3
    It seems to me that you are not using the virtualenv's pip when installing the dependency. Try with `/home/USERNAME/virtualenv3/bin/pip` – Uku Loskit Jul 15 '20 at 21:50
  • @UkuLoskit - The commands above are being run after I have activated virtualenv with source. I will add this to the notes. As far as I know, see [here](https://stackoverflow.com/questions/21240653/how-to-install-a-package-inside-virtualenv) and [here](https://stackoverflow.com/questions/33945808/how-to-use-pip-in-virtualenv), you only need to run commands like pip as normal when virtualenv is activated. Do you have more information on your alternative? – Philippe Fenderson Jul 15 '20 at 22:10
  • the problem is that if pip is not installed within the virtualenv then the system pip will be used (as it is one the PATH). my approach makes sure that the correct pip is being used. – Uku Loskit Jul 15 '20 at 22:14
  • @UkuLoskit That has the same effect as listed above. ``` (virtualenv3) $ ~/virtualenv3/bin/pip install zope.interface Requirement already satisfied: zope.interface in /usr/lib/python3.7/site-packages (5.1.0) Requirement already satisfied: setuptools in ./virtualenv3/lib/python3.7/site-packages (from zope.interface) (49.1.0) ``` – Philippe Fenderson Jul 16 '20 at 18:46

0 Answers0