Skip to content

Instantly share code, notes, and snippets.

@x-yuri
Last active October 7, 2019 13:02
Show Gist options
  • Select an option

  • Save x-yuri/9899344a28ed5357b5c755a4323b8af1 to your computer and use it in GitHub Desktop.

Select an option

Save x-yuri/9899344a28ed5357b5c755a4323b8af1 to your computer and use it in GitHub Desktop.
/opt/eff.org/certbot/venv/bin/python: No module named pip.__main__; 'pip' is a package and cannot be directly executed

Debian Wheezy

/opt/eff.org/certbot/venv/bin/python: No module named pip.__main__; 'pip' is a package and cannot be directly executed
Traceback (most recent call last):
  File "/tmp/tmp.Xxcju1yqBr/pipstrap.py", line 177, in <module>
    sys.exit(main())
  File "/tmp/tmp.Xxcju1yqBr/pipstrap.py", line 149, in main
    pip_version = StrictVersion(check_output([python, '-m', 'pip', '--version'])
  File "/usr/lib/python2.7/subprocess.py", line 544, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['/opt/eff.org/certbot/venv/bin/python', '-m', 'pip', '--version']' returned non-zero exit status 1

Possible solutions:

  1. Change certbot-auto:
--- certbot-auto	2019-10-04 17:08:55.310470864 +0300
+++ certbot-auto-new	2019-10-07 14:39:59.407460138 +0300
@@ -1502,7 +1502,7 @@
 
 def main():
     python = sys.executable or 'python'
-    pip_version = StrictVersion(check_output([python, '-m', 'pip', '--version'])
+    pip_version = StrictVersion(check_output(['pip', '--version'])
                                 .decode('utf-8').split()[1])
     has_pip_cache = pip_version >= StrictVersion('6.0')
     index_base = get_index_base()
@@ -1513,7 +1513,7 @@
                                      digest)
                      for path, digest in PACKAGES]
         # Calling pip as a module is the preferred way to avoid problems about pip self-upgrade.
-        command = [python, '-m', 'pip', 'install', '--no-index', '--no-deps', '-U']
+        command = ['pip', 'install', '--no-index', '--no-deps', '-U']
         # Disable cache since it is not used and it otherwise sometimes throws permission warnings:
         command.extend(['--no-cache-dir'] if has_pip_cache else [])
         command.extend(downloads)

To make it not self-upgrade add NO_SELF_UPGRADE=1 to /etc/environment or some such.

https://community.letsencrypt.org/t/pip-error-with-certbot-auto/88200/6?u=ericb2038 certbot/certbot#6824 (comment)

  1. Downgrade to 0.31 and --no-self-upgrade (or NO_SELF_UPGRADE=1):

https://community.letsencrypt.org/t/certbot-auto-started-failing-with-no-module-named-pip-main/89097/3 certbot/certbot#6824 (comment)

  1. Make use of pyenv:

https://community.letsencrypt.org/t/pip-error-with-certbot-auto/88200/18 https://community.letsencrypt.org/t/pip-error-with-certbot-auto/88200/20 https://community.letsencrypt.org/t/installing-certbot-on-systems-running-outdated-versions-of-python/92041

  1. Upgrade pip:

https://community.letsencrypt.org/t/pip-error-with-certbot-auto/88200/15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment