Source venv/bin/activate isn’t returning anything on CentOS

centosflaskpython

I'm trying to deploy a Python Flask app (for API endpoint) on CentOS for work, but every online guide I've followed isn't working for me!

python3 -m venv APIenv

The env was created successfully, but then trying to activate it:

source APIenv/bin/activate

Returns nothing, neither an error not is it activating it!

from what I understood, activating it should make the CLI look like this:

(venv) $ _

I'm also having another problem:

pip3 install firebase_admin

this worked and it was installed, but then running my app:

python3 app.py

Traceback (most recent call last):
File "app.py", line 4, in
import firebase_admin
ModuleNotFoundError: No module named 'firebase_admin'

Every online guide I've followed is getting me stuck here, I really need to get this to work, what am I doing wrong?

Best Answer

Probably you have pip3 linked to another version of python(3.6,3.8, etc) than python3 which you are using

Make sure you are using the same versions and it is in venv actually check python3

# python3 -V
Python 3.8.6
# which python3
/tmp/APIenv/bin/python3
# ls -laht /tmp/APIenv/bin/python3
lrwxrwxrwx 1 root root 8 Sep 30 13:59 /tmp/APIenv/bin/python3 -> python38

Check pip3

# pip3 -V
pip 19.3.1 from /tmp/APIenv/lib64/python3.8/site-packages/pip (python 3.8)
# which pip3
/tmp/APIenv/bin/pip3
# ls -laht /tmp/APIenv/bin/pip3
-rwxr-xr-x 1 root root 225 Sep 30 13:59 /tmp/APIenv/bin/pip3

sometimes it can be looking so even under VENV:

#  which python38
/tmp/APIenv/bin/python38
# ls -laht /tmp/APIenv/bin/python38
lrwxrwxrwx 1 root root 17 Sep 30 13:59 /tmp/APIenv/bin/python38 -> /usr/bin/python38

Check paths of your pip and python interpreter then, to be sure you can use it by absolute path of your venv

Updated:

Issue related to python3.6 version.

firebase_admin cannot be installed with python3.6 version

Required at least python3.8 (3.7 not tested)

Python38 installation for Centos 8 and related question modules:

dnf install python38 python38-pip
pip38 install firebase_admin flask venv