Python Forum
virtual environment is not activating in centOS
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
virtual environment is not activating in centOS
#1
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)?
Reply
#2
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.
Reply
#3
I am using bash.

Output:
[email protected] ~$ echo $SHELL My current shell - /bin/bash
Reply
#4
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)
Reply
#5
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 Sad . Is it correct to choose the directory /home/LPython/
Reply
#6
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 Dance
Thank you for all the support.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python to interact with the Linux Command Line - Centos/RHEL redhat_boy 2 2,157 May-10-2020, 08:33 AM
Last Post: redhat_boy
  can't use pip on CentOS 7 Sakurami 1 2,672 Apr-15-2020, 02:59 AM
Last Post: Larz60+
  Setting up virtual environment tjnichols 6 3,605 Sep-18-2018, 05:18 PM
Last Post: tjnichols

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020