I am trying to install django in CentOS 7 cloud server. For that I have installed Virtual environment by using python -m venv env
. And environment installed successfully, but it is not activating when I used the shell command source env/bin/activate
. The name of the current virtual environment is NOT appear on the left of the prompt. So I understand virtual environment is not active. I am still unsuccessful. In CentOS do I need to use specific Shell(eg:$BASH)
?
Which shell are you using? csh?
I am no sure how it is in CentOS but in my Ubuntu I have under env/bin:
Output:
-rw-rw-r-- 1 user group 2096 feb 10 2018 activate
-rw-rw-r-- 1 user group 1038 feb 10 2018 activate.csh
-rw-rw-r-- 1 user group 2236 feb 10 2018 activate.fish
-rw-rw-r-- 1 user group 1137 feb 10 2018 activate_this.py
If you are using csh you should use activate.csh.
I am using bash.
Output:
[email protected] ~$ echo $SHELL
My current shell - /bin/bash
If you do this what happens,and give it a more unique name eg
my_env
.
# Python need to be a newer version for "venv" to work
tom@tom-VirtualBox:~$ python -V
Python 3.7.3
# I have use pyenv here to install Python
tom@tom-VirtualBox:~$ which python
/home/tom/.pyenv/shims/python
# Make
tom@tom-VirtualBox:~$ python -m venv my_env
# cd in
tom@tom-VirtualBox:~$ cd my_env
# Activate
tom@tom-VirtualBox:~/my_env$ source bin/activate
# Now active see (my_env)
# Python executable point now to "my_env" folder
(my_env) tom@tom-VirtualBox:~/my_env$ which python
/home/tom/my_env/bin/python
# Test pip
(my_env) tom@tom-VirtualBox:~/my_env$ pip -V
pip 19.0.3 from /home/tom/my_env/lib/python3.7/site-packages/pip (python 3.7)
I removed my
env
folder then I created
my_env
as you have said.
MY console is given below
Output:
[email protected] /$ python3.8 -V
Python 3.8.0
[email protected] /$ which python3.8
/usr/local/bin/python3.8
#I created my_env in /home/LPython/
[email protected] /$ python3.8 -m venv /home/LPython/my_env
[email protected] /$ cd /home/LPython/my_env
[email protected] /home/LPython/my_env$ source bin/activate
[email protected] /home/LPython/my_env$
But still my virtual environment is
not active. Left of the prompt is still same

. Is it correct to choose the directory
/home/LPython/
This problem is solved. Actually I was not using
BASH shell, even if the
echo $SHELL outputs
bin/bash. Because of this output, I thought i was using using
BASH shell. Then I login through
SSH. If you are using Windows must login through
PUTTY. Then I could activate my
virtual environment through
source my_env/bin/activate
Thank you for all the support.