As @KarlKnechtel pointed out, sudo
should not be used with pip
, so I tried to do it that way - first, restore previous state (from the changes done in OP):
# answer Y to all questions at next command
sudo -H pip3 uninstall virtualenv pip-tools pipdeptree
rm -rf venv_mpl
Now, since this is currently Python 3.8.10, I can use the venv
module, which is standard since 3.3 - however, I first need to do this (error message recommended python3.8-venv
, but python3-venv
is probably better):
sudo apt install python3-venv
... and then, I can create virtualenv:
python3 -m venv venv_mpl
Now, let's proceed in the venv, and run commands as normal user:
$ source venv_mpl/bin/activate
(venv_mpl) $ pip3 install --upgrade pip
...
Successfully installed pip-21.3.1
(venv_mpl) $ pip3 install pip-tools pipdeptree
Collecting pip-tools
...
Successfully installed click-8.0.3 pep517-0.12.0 pip-tools-6.4.0 pipdeptree-2.2.0 tomli-2.0.0 wheel-0.37.0
(venv_mpl) $ cat > venv_mpl/requirements.in <<'EOF'
plotly
seaborn
scikit-learn
EOF
(venv_mpl) $ pip-compile venv_mpl/requirements.in
...
(venv_mpl) $ pip-sync venv_mpl/requirements.txt
Found existing installation: pipdeptree 2.2.0
Uninstalling pipdeptree-2.2.0:
Successfully uninstalled pipdeptree-2.2.0
Collecting cycler==0.11.0
Using cached cycler-0.11.0-py3-none-any.whl (6.4 kB)
Collecting fonttools==4.28.3
Using cached fonttools-4.28.3-py3-none-any.whl (884 kB)
Collecting joblib==1.1.0
Using cached joblib-1.1.0-py2.py3-none-any.whl (306 kB)
Collecting kiwisolver==1.3.2
Using cached kiwisolver-1.3.2-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl (1.2 MB)
Collecting matplotlib==3.5.1
Using cached matplotlib-3.5.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl (11.3 MB)
Collecting numpy==1.21.4
Using cached numpy-1.21.4-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (15.7 MB)
Collecting packaging==21.3
Using cached packaging-21.3-py3-none-any.whl (40 kB)
Collecting pandas==1.3.5
Using cached pandas-1.3.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.5 MB)
Collecting pillow==8.4.0
Using cached Pillow-8.4.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB)
Collecting plotly==5.4.0
Using cached plotly-5.4.0-py2.py3-none-any.whl (25.3 MB)
Collecting pyparsing==3.0.6
Using cached pyparsing-3.0.6-py3-none-any.whl (97 kB)
Collecting python-dateutil==2.8.2
Using cached python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
Collecting pytz==2021.3
Using cached pytz-2021.3-py2.py3-none-any.whl (503 kB)
Collecting scikit-learn==1.0.1
Using cached scikit_learn-1.0.1-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (25.9 MB)
Collecting scipy==1.7.3
Using cached scipy-1.7.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (39.3 MB)
Collecting seaborn==0.11.2
Using cached seaborn-0.11.2-py3-none-any.whl (292 kB)
Collecting six==1.16.0
Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting tenacity==8.0.1
Using cached tenacity-8.0.1-py3-none-any.whl (24 kB)
Collecting threadpoolctl==3.0.0
Using cached threadpoolctl-3.0.0-py3-none-any.whl (14 kB)
Installing collected packages: six, pyparsing, pytz, python-dateutil, pillow, packaging, numpy, kiwisolver, fonttools, cycler, threadpoolctl, tenacity, scipy, pandas, matplotlib, joblib, seaborn, scikit-learn, plotly
Successfully installed cycler-0.11.0 fonttools-4.28.3 joblib-1.1.0 kiwisolver-1.3.2 matplotlib-3.5.1 numpy-1.21.4 packaging-21.3 pandas-1.3.5 pillow-8.4.0 plotly-5.4.0 pyparsing-3.0.6 python-dateutil-2.8.2 pytz-2021.3 scikit-learn-1.0.1 scipy-1.7.3 seaborn-0.11.2 six-1.16.0 tenacity-8.0.1 threadpoolctl-3.0.0
Well, it did succeed here, without bumping into the apturl issue - great!
I find it a bit weird, though, that pipdeptree
had to be removed for this to succeed (EDIT: it turns out, pipdeptree
also has to be added to requirements.in
, then it gets installed as all others there - strange that pip-tools
does not need this, then again, pip-tools
is the one doing the parsing of the requirements file; possibly related: note that sometimes "The following packages are considered to be unsafe in a requirements file:" gets printed, there is some discussion on that here Reasoning behind unsafe packages · Issue #522 · jazzband/pip-tools · GitHub), but hey - at least the procedure passed, and the right packages got installed, so ... great!
EDIT2: if when trying to run a matplotlib script from this virtual environment, Python responds with "UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.", one needs to install the system sudo apt install python3-tk
(see "UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure." when plotting figure with pyplot on Pycharm)