# Occasional virtualenv: command not found

**URL:** <https://community.letsencrypt.org/t/occasional-virtualenv-command-not-found/84010>\
**Category:** Help\
**Created:** [January 25, 2019, 3:19pm UTC](https://community.letsencrypt.org/t/occasional-virtualenv-command-not-found/84010 "2019-01-25T15:19:59Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jcormier](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@jcormier](https://community.letsencrypt.org/u/jcormier)\
**Post date:** [January 25, 2019, 3:19pm UTC](https://community.letsencrypt.org/t/occasional-virtualenv-command-not-found/84010/1 "2019-01-25T15:19:59Z")

</div>

certbot-auto is setup to run every 12 hours via cron and usually runs without issue. But twice in the last two months, certbot-auto will exit with the below virtualenv error, and cron sends me a failure email. I'd like to see if there is a reason for these failures or if we should just ignore them.

First failure happened on Jan 3rd, and second on Jan 25th.

My domain is: [syr.criticallink.com](http://syr.criticallink.com)

I ran this command: sudo /etc/letsencrypt/certbot-auto renew -q

It produced this output:

> /etc/letsencrypt/certbot-auto: line 1004: virtualenv: command not found

My web server is (include version):  
apache

The operating system my web server runs on is (include version):  
$ lsb\_release -d  
Description: Ubuntu 16.04.5 LTS

I can login to a root shell on my machine (yes or no, or I don't know): yes

The version of my client is (e.g. output of `certbot --version` or `certbot-auto --version` if you're using Certbot):  
$ sudo /etc/letsencrypt/certbot-auto --version  
certbot 0.30.1

---

<div class="post-metadata">

**Author:** ![stevenzhu](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/stevenzhu/32/18864_2.png) [@stevenzhu](https://community.letsencrypt.org/u/stevenzhu)\
**Post date:** [January 25, 2019, 3:32pm UTC](https://community.letsencrypt.org/t/occasional-virtualenv-command-not-found/84010/2 "2019-01-25T15:32:14Z")

</div>

Hi,

Can you please check if virtualenv is installed?  
Also, what version of python are you using?

Thank you

---

<div class="post-metadata">

**Author:** ![jcormier](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@jcormier](https://community.letsencrypt.org/u/jcormier)\
**Post date:** [January 25, 2019, 3:51pm UTC](https://community.letsencrypt.org/t/occasional-virtualenv-command-not-found/84010/3 "2019-01-25T15:51:45Z")

</div>

It would have to be installed for the tool to work most of the time.

```
 $ which virtualenv
/usr/local/bin/virtualenv
 $ virtualenv --version
16.0.0
 $ python --version
Python 2.7.12
```

---

<div class="post-metadata">

**Author:** ![rg305](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/rg305/32/91314_2.png) [@rg305](https://community.letsencrypt.org/u/rg305)\
**Post date:** [January 26, 2019, 12:16am UTC](https://community.letsencrypt.org/t/occasional-virtualenv-command-not-found/84010/4 "2019-01-26T00:16:07Z")

</div>

> [@jcormier](#):
>
> I ran this command: **sudo /etc/letsencrypt/certbot-auto renew -q**

Just to be sure, is that exactly how it is shown with:  
`crontab -l`

---

<div class="post-metadata">

**Author:** ![jcormier](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@jcormier](https://community.letsencrypt.org/u/jcormier)\
**Post date:** [January 28, 2019, 3:47pm UTC](https://community.letsencrypt.org/t/occasional-virtualenv-command-not-found/84010/5 "2019-01-28T15:47:16Z")

</div>

> [@rg305](#):
>
> > [@jcormier](#):
> >
> > I ran this command: **sudo /etc/letsencrypt/certbot-auto renew -q**
> 
> Just to be sure, is that exactly how it is shown with:  
> `crontab -l`

```nohighlight
 $ sudo crontab -l
...
# Every 12 hours check for letsencrypt renew
0 */12 * * * /etc/letsencrypt/certbot-auto renew -q

```

---

<div class="post-metadata">

**Author:** ![jcormier](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@jcormier](https://community.letsencrypt.org/u/jcormier)\
**Post date:** [January 28, 2019, 3:52pm UTC](https://community.letsencrypt.org/t/occasional-virtualenv-command-not-found/84010/6 "2019-01-28T15:52:06Z")

</div>

A coworker pointed out that virtualenv is installed in several ways.

```auto
which virtualenv --> /usr/local/bin/virtualenv
dpkg --listfiles virtualenv --> /usr/bin/virtualenv [which does not exist]

 $ pip list | grep virt
virtualenv 16.0.0               
virtualenv-clone 0.3.0                

[/usr/local/bin/virtualenv is installed via pip]

dpkg --get-selections|grep virtualenv

python-virtualenv install
python3-virtualenv install
virtualenv install

```

Which I think is throwing off the script. I think it sees that virtualenv package is installed and expects virtualenv to be in the path, but it is in /usr/local/bin instead and it cannot find it. I don’t think /usr/local/bin is in the PATH for root crontab.

Strangely this seems to work most of the time

---

<div class="post-metadata">

**Author:** ![jcormier](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@jcormier](https://community.letsencrypt.org/u/jcormier)\
**Post date:** [January 28, 2019, 4:12pm UTC](https://community.letsencrypt.org/t/occasional-virtualenv-command-not-found/84010/7 "2019-01-28T16:12:29Z")

</div>

Updated cron entry to specify the /usr/local/bin. Quick tests look promising.

```auto
# Every 12 hours check for letsencrypt renew
0 */12 * * * PATH=$PATH:/usr/local/bin /etc/letsencrypt/certbot-auto renew -q

```

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/letsencrypt/original/3X/c/a/ca6c06ea1ea201324bba7048c6841ce60236468d.png) [@system](https://community.letsencrypt.org/u/system)\
**Post date:** [February 27, 2019, 4:13pm UTC](https://community.letsencrypt.org/t/occasional-virtualenv-command-not-found/84010/8 "2019-02-27T16:13:30Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
