How to Fix ImportError: No module named virtualenv in CentOS?

Updated on September 2, 2017

I was trying to compile Letsencrypt package on my CentOS machine and landed up on this error message – ImportError: No module named virtualenv.

./letsencrypt-auto 
::::::::::::::::::::::::::::
Traceback (most recent call last):
 File "/usr/bin/virtualenv", line 2, in <module>
 import virtualenv
ImportError: No module named virtualenv

By default virtualenv was installed under ‘/usr/local/bin‘, but executing the program throws the same error:

$/usr/bin/virtualenv
Traceback (most recent call last):
 File "/usr/bin/virtualenv", line 2, in <module>
 import virtualenv
ImportError: No module named virtualenv

How to fix this error?

import error linux

Answer:

Since the default ‘virtualenv‘ throws the same error (may be it was not installed properly or corrupted), you may try installing the package again using Python-pip (this tutorial will help you to install pip)

$pip install virtualenv
::::
Installing collected packages: virtualenv
Successfully installed virtualenv-13.1.2

Once done, check if ‘/usr/bin/virtualenv‘ is working properly. The command ‘/usr/bin/virtualenv’ without any options should print the command help.

That’s it. Hope it works for you.

Was this article helpful?

Related Articles

Leave a Comment