Introduction
This is an article where the main focus is just to solve an error message. Actually, the command which is triggering an error message is an attempt to activate a python virtual environment. There are several steps which is basically modifying the command for activating the python virtual environment. This is an attempt for activating python virtual environment in a server or a machine running using a Linux operating system.It is a python virtual environment exist where the process for creating the python virtual environment exist as follows :
[django@localhost sites]$ virtualenv env created virtual environment CPython3.6.8.final.0-64 in 580ms creator CPython3Posix(dest=/home/django/sites/env, clear=False, no_vcs_ignore=False, global=False) seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/django/.local/share/virtualenv) added seed packages: pip==21.3.1, setuptools==58.3.0, wheel==0.37.0 activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator [django@localhost sites]$
[django@localhost sites]$ cd env/bin/ [django@localhost bin]$ ls activate activate.fish activate.ps1 deactivate.nu pip3 pip3.6 python3 wheel wheel-3.6 activate.csh activate.nu activate_this.py pip pip-3.6 python python3.6 wheel3 wheel3.6 [django@localhost bin]$
Attempt to activate Python Virtual Environment
So, the following are the steps or the attempt where it is trying to activate a python virtual environment.
-
Modifying the activate script by adding executable permission as follows :
[django@localhost bin]$ chmod +x activate
-
Finally, another attempt is just by executing it user the ‘sh’ command as follows :
[django@localhost bin]$ cd .. [django@localhost env]$ cd .. [django@localhost sites]$ cd .. [django@localhost ~]$ sh sites/env/bin/activate You must source this script: $ source sites/env/bin/activate [django@localhost ~]$
Unfortunately, it ends in a failure.
-
It is actually another variety command using ‘./’ but along with several path to the python virtual environment activation file as follows :
[django@localhost ~]$ ./sites/env/bin/activate You must source this script: $ source ./sites/env/bin/activate [django@localhost ~]$ cd sites/env/bin/
The above command also ends in a failure.
-
Using the ./ with the python virtual environment activation file directly as follows :
[django@localhost ~]$ cd sites/env/bin/ [django@localhost bin]$ ./activate You must source this script: $ source ./activate [django@localhost bin]$
Once more, it is not working at all. Try to use another alternative command below.
-
Using the sh command with the python virtual environment activation file as follows :
[django@localhost bin]$ sh activate You must source this script: $ source activate [django@localhost bin]$ cd .. [django@localhost env]$ cd .. [django@localhost .sites]$ cd .. [django@localhost ~]$
Again, it is wrong and it is not working at all.
-
Last but not least, the one which is working exist as follows :
[django@localhost ~]$ . sites/env/bin/activate (env) [django@localhost ~]$
So, the working command is just by using the command as follows :
. + path_from_the_current_working_directory_to_the_activate_file/ + activate
As an example in the above command exist as follows :
. sites/env/bin/activate
Nice, good