I figured it out!
I again thought about the “Permission denied” error.
It did try to install it in the correct directory! So it must have picked up the venv.
(habapp) openhabian@openhab:/opt/habapp $ pip install requests
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting requests
Using cached https://www.piwheels.org/simple/requests/requests-2.25.1-py2.py3-none-any.whl (61 kB)
Requirement already satisfied: chardet<5,>=3.0.2 in ./lib/python3.7/site-packages (from requests) (3.0.4)
Collecting idna<3,>=2.5
Using cached https://www.piwheels.org/simple/idna/idna-2.10-py2.py3-none-any.whl (58 kB)
Collecting urllib3<1.27,>=1.21.1
Using cached https://www.piwheels.org/simple/urllib3/urllib3-1.26.3-py2.py3-none-any.whl (137 kB)
Collecting certifi>=2017.4.17
Using cached https://www.piwheels.org/simple/certifi/certifi-2020.12.5-py2.py3-none-any.whl (147 kB)
Installing collected packages: urllib3, idna, certifi, requests
ERROR: Could not install packages due to an OSError: [Errno 13] Permission denied: '/opt/habapp/lib/python3.7/site-packages/urllib3'
Consider using the `--user` option or check the permissions.
It also didn’t work with the --user
(habapp) openhabian@openhab:/opt/habapp $ pip install --user requests
ERROR: Can not perform a '--user' install. User site-packages are not visible in this virtualenv.
So I checked the folder permissions.
It was missing the “w” write permission for group and others:
(habapp) openhabian@openhab:/opt/habapp $ deactivate
openhabian@openhab:/opt/habapp $ ls -l
total 20
drwxr-xr-x 2 root root 4096 Feb 1 16:23 bin
drwxr-xr-x 2 root root 4096 Feb 1 16:22 include
drwxr-xr-x 3 root root 4096 Feb 1 16:22 lib
-rw-r--r-- 1 root root 69 Mar 9 13:54 pyvenv.cfg
drwxr-xr-x 3 root root 4096 Feb 1 16:22 share
So I changed that (using chmod -R recursive mode)
openhabian@openhab:/opt/habapp $ sudo chmod -R u=rwx,g=rwx,o=rwx /opt/habapp/
openhabian@openhab:/opt/habapp $ sudo ls -l
total 20
drwxrwxrwx 2 root root 4096 Feb 1 16:23 bin
drwxrwxrwx 2 root root 4096 Feb 1 16:22 include
drwxrwxrwx 3 root root 4096 Feb 1 16:22 lib
-rwxrwxrwx 1 root root 69 Mar 9 13:54 pyvenv.cfg
drwxrwxrwx 3 root root 4096 Feb 1 16:22 share
Try install again - IT WORKS!
openhabian@openhab:/opt/habapp $ source bin/activate
(habapp) openhabian@openhab:/opt/habapp $ pip install requests
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting requests
Using cached https://www.piwheels.org/simple/requests/requests-2.25.1-py2.py3-none-any.whl (61 kB)
Collecting idna<3,>=2.5
Using cached https://www.piwheels.org/simple/idna/idna-2.10-py2.py3-none-any.whl (58 kB)
Collecting urllib3<1.27,>=1.21.1
Using cached https://www.piwheels.org/simple/urllib3/urllib3-1.26.3-py2.py3-none-any.whl (137 kB)
Collecting certifi>=2017.4.17
Using cached https://www.piwheels.org/simple/certifi/certifi-2020.12.5-py2.py3-none-any.whl (147 kB)
Requirement already satisfied: chardet<5,>=3.0.2 in ./lib/python3.7/site-packages (from requests) (3.0.4)
Installing collected packages: urllib3, idna, certifi, requests
Attempting uninstall: idna
Found existing installation: idna 3.1
Uninstalling idna-3.1:
Successfully uninstalled idna-3.1
Successfully installed certifi-2020.12.5 idna-2.10 requests-2.25.1 urllib3-1.26.3
Also shows up in the pip list now:
(habapp) openhabian@openhab:/opt/habapp $ pip list
Package Version
------------------ ---------
aiohttp 3.7.3
aiohttp-sse-client 0.2.0
astral 2.2
async-timeout 3.0.1
attrs 20.3.0
bidict 0.21.2
certifi 2020.12.5
chardet 3.0.4
EasyCo 0.2.3
HABApp 0.20.0
idna 2.10
multidict 5.1.0
paho-mqtt 1.5.1
pip 21.0.1
pkg-resources 0.0.0
pydantic 1.7.3
pytz 2020.5
requests 2.25.1
ruamel.yaml 0.16.12
ruamel.yaml.clib 0.2.2
setuptools 40.8.0
stackprinter 0.2.5
typing-extensions 3.7.4.3
tzlocal 2.1
ujson 4.0.1
urllib3 1.26.3
voluptuous 0.12.1
watchdog 1.0.2
yarl 1.6.3
Thanks again for the efforts!