{"id":71846,"date":"2020-09-30T21:45:39","date_gmt":"2020-09-30T18:45:39","guid":{"rendered":"https:\/\/computingforgeeks.com\/?p=71846"},"modified":"2026-03-21T19:03:42","modified_gmt":"2026-03-21T16:03:42","slug":"fix-mkvirtualenv-command-not-found-ubuntu","status":"publish","type":"post","link":"https:\/\/computingforgeeks.com\/fix-mkvirtualenv-command-not-found-ubuntu\/","title":{"rendered":"Fix mkvirtualenv command not found on Ubuntu"},"content":{"rendered":"\n<p>In this short tutorial we&#8217;ll show you how to install <em>mkvirtualenv<\/em> (virtualenvwrapper &amp; virtualenv) on Ubuntu Linux machine. <em>virtualenvwrapper<\/em> is a set of shell&nbsp;<em>functions<\/em>&nbsp;defined in Bourne shell compatible syntax. virtualenv is what enables you to create many different Python environments in your Linux \/ macOS system. With virtualenvwrapper you can automate tests run under the following shells on a Linux or OS X machine.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>bash<\/code><\/li>\n\n\n\n<li><code>ksh<\/code><\/li>\n\n\n\n<li><code>zsh<\/code><\/li>\n<\/ul>\n\n\n\n<p>This is the error I&#8217;m getting if I try type <em>mkvirtualenv<\/em> in the terminal.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <span class=\"has-inline-color has-pale-pink-color\">mkvirtualenv<\/span>\nmkvirtualenv: command not found<\/code><\/pre>\n\n\n\n<p>You&#8217;ll need to install virtualenvwrapper package into the same global site-packages area where virtualenv is installed. Administrative privileges are required for this installation. Ensure you&#8217;re logged in as root user or standard user with sudo privileges.<\/p>\n\n\n\n<p>Update the System package list.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update<\/code><\/pre>\n\n\n\n<p>Then install Python build tools.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\"># Python 3\n<\/mark><\/em>sudo apt install python3-pip python3-dev build-essential\n\n<em><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\"># Python 2<\/mark><\/em><strong><em>\n<\/em><\/strong>sudo apt install python-pip python-dev build-essential<\/code><\/pre>\n\n\n\n<p>Then install <em>virtualenv<\/em> and <em>virtualenvwrapper<\/em> packages.<\/p>\n\n\n\n<p><strong>With APT package manager:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install virtualenv virtualenvwrapper<\/code><\/pre>\n\n\n\n<p><strong>With Pip:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\"># Python 3\n<\/mark><\/em>sudo pip3 install virtualenv virtualenvwrapper\n\n<em><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\"># Python 2<\/mark><\/em>\nsudo pip install virtualenv virtualenvwrapper<\/code><\/pre>\n\n\n\n<p>An alternative to installing it into the global site-packages is to add it to&nbsp;<a href=\"https:\/\/docs.python.org\/install\/index.html#alternate-installation-the-user-scheme\" target=\"_blank\" rel=\"noreferrer noopener\">your user local directory<\/a>&nbsp;(usually&nbsp;~\/.local). See below example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install --user virtualenv virtualenvwrapper<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Configure your Shell<\/h2>\n\n\n\n<p>Depending on your installation method you may need to add <em>virtualenvwrapper<\/em> script path to your startup file (<em>.bashrc<\/em>, <em>.profile<\/em>, etc.).<\/p>\n\n\n\n<p>But first confirm the location of virtualenvwrapper script.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <span style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">sudo find \/ -name virtualenvwrapper.sh<\/span>\n\/usr\/local\/bin\/virtualenvwrapper.sh<\/code><\/pre>\n\n\n\n<p>Then edit<strong> ~\/.bashrc<\/strong> and add a line to source<em> \/usr\/share\/virtualenvwrapper\/virtualenvwrapper.sh<\/em><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <span style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-amber-color\">vim ~\/.bashrc<\/span>\n# Add to end\nVIRTUALENVWRAPPER_PYTHON=$(which python3) #or python2\nsource $(sudo find \/ -name virtualenvwrapper.sh)<\/code><\/pre>\n\n\n\n<p>Now source your <em>bashrc<\/em> file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <span class=\"has-inline-color has-pale-pink-color\">source ~\/.bashrc<\/span>\nvirtualenvwrapper.user_scripts creating \/home\/computingforgeeks\/.virtualenvs\/premkproject\nvirtualenvwrapper.user_scripts creating \/home\/computingforgeeks\/.virtualenvs\/postmkproject\nvirtualenvwrapper.user_scripts creating \/home\/computingforgeeks\/.virtualenvs\/initialize\nvirtualenvwrapper.user_scripts creating \/home\/computingforgeeks\/.virtualenvs\/premkvirtualenv\nvirtualenvwrapper.user_scripts creating \/home\/computingforgeeks\/.virtualenvs\/postmkvirtualenv\nvirtualenvwrapper.user_scripts creating \/home\/computingforgeeks\/.virtualenvs\/prermvirtualenv\nvirtualenvwrapper.user_scripts creating \/home\/computingforgeeks\/.virtualenvs\/postrmvirtualenv\nvirtualenvwrapper.user_scripts creating \/home\/computingforgeeks\/.virtualenvs\/predeactivate\nvirtualenvwrapper.user_scripts creating \/home\/computingforgeeks\/.virtualenvs\/postdeactivate\nvirtualenvwrapper.user_scripts creating \/home\/computingforgeeks\/.virtualenvs\/preactivate\nvirtualenvwrapper.user_scripts creating \/home\/computingforgeeks\/.virtualenvs\/postactivate\nvirtualenvwrapper.user_scripts creating \/home\/computingforgeeks\/.virtualenvs\/get_env_details<\/code><\/pre>\n\n\n\n<p>You can as well set <strong>WORKON_HOME<\/strong> variable to custom path which by default is&nbsp;<code>$HOME\/.virtualenvs<\/code>.&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>export WORKON_HOME=\/my\/other\/path<\/code><\/pre>\n\n\n\n<p>If the directory does not exist when virtualenvwrapper is loaded, it will be created automatically.<\/p>\n\n\n\n<p>Try run <em>mkvirtualenv<\/em> command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <span style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">mkvirtualenv -p \/usr\/bin\/python3 test_venv<\/span>\ncreated virtual environment CPython3.10.12.final.0-64 in 266ms\n  creator CPython3Posix(dest=\/root\/.virtualenvs\/test_venv, clear=False, no_vcs_ignore=False, global=False)\n  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=\/root\/.local\/share\/virtualenv)\n    added seed packages: pip==23.3.1, setuptools==68.2.2, wheel==0.41.2\n  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator\nvirtualenvwrapper.user_scripts creating \/root\/.virtualenvs\/test_venv\/bin\/predeactivate\nvirtualenvwrapper.user_scripts creating \/root\/.virtualenvs\/test_venv\/bin\/postdeactivate\nvirtualenvwrapper.user_scripts creating \/root\/.virtualenvs\/test_venv\/bin\/preactivate\nvirtualenvwrapper.user_scripts creating \/root\/.virtualenvs\/test_venv\/bin\/postactivate\nvirtualenvwrapper.user_scripts creating \/root\/.virtualenvs\/test_venv\/bin\/get_env_details<\/code><\/pre>\n\n\n\n<p>To enable your project virtual environment any time run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-amber-color\"> workon test_venv<\/mark>\n(test_venv) jmutai@jammy:~$<\/code><\/pre>\n\n\n\n<p>To exit run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>deactivate<\/code><\/pre>\n\n\n\n<p>You should now be able to work on your Python Project with <em>virtualenv<\/em> and <em>virtualenvwrapper<\/em> script.<\/p>\n\n\n\n<p>Other Python related articles:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/computingforgeeks.com\/how-to-install-python2-with-virtualenv-on-ubuntu\/\" target=\"_blank\" rel=\"noreferrer noopener\">How To Install Python 2 with Virtualenv&nbsp; on Ubuntu<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/computingforgeeks.com\/deploy-django-rocky-almalinux\/\" target=\"_blank\" rel=\"noreferrer noopener\">Deploy Python 3 Django Application on CentOS 7 with Apache and mod_wsgi<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/computingforgeeks.com\/5-best-computer-programming-books-for-beginners\/\" target=\"_blank\" rel=\"noreferrer noopener\">Best Books for Learning Python Programming<\/a><\/li>\n<\/ul>\n\n","protected":false},"excerpt":{"rendered":"<p>In this short tutorial we&#8217;ll show you how to install mkvirtualenv (virtualenvwrapper &amp; virtualenv) on Ubuntu Linux machine. virtualenvwrapper is a set of shell&nbsp;functions&nbsp;defined in Bourne shell compatible syntax. virtualenv is what enables you to create many different Python environments in your Linux \/ macOS system. With virtualenvwrapper you can automate tests run under the &#8230; <a title=\"Fix mkvirtualenv command not found on Ubuntu\" class=\"read-more\" href=\"https:\/\/computingforgeeks.com\/fix-mkvirtualenv-command-not-found-ubuntu\/\" aria-label=\"Read more about Fix mkvirtualenv command not found on Ubuntu\">Read more<\/a><\/p>\n","protected":false},"author":3,"featured_media":71902,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[299,690,50,81],"tags":[29658,29659],"class_list":["post-71846","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-how-to","category-dev","category-linux-tutorials","category-ubuntu","tag-mkvirtualenv","tag-virtualenv"],"_links":{"self":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/71846","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/comments?post=71846"}],"version-history":[{"count":1,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/71846\/revisions"}],"predecessor-version":[{"id":163145,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/71846\/revisions\/163145"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media\/71902"}],"wp:attachment":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media?parent=71846"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/categories?post=71846"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/tags?post=71846"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}