You are on page 1of 6

HOW TO INSTALL NANOVNA-SAVER INTO A PYTHON VIRTUAL ENVIRONMENT ON

LINUX MINT 19.3 NB: 64-BIT ONLY1 - UPDATED 02.12.20

INTRODUCTION

A number of group members have recently (January 2020) reported


problems installing Rune Broberg’s excellent nanovna-saver
application on Debian based distributions of linux2.

PROBLEM

The build instruction...

$ python3.7 -m pip install .

...typically fails with these error messages (YMMV) ...

$ sudo python3.7 -m pip install .


[sudo] password for mm:
The directory '/home/mm/.cache/pip/http' or its parent directory
is not owned by the current user and the cache has been disabled.
Please check the permissions and owner of that directory. If
executing pip with sudo, you may want sudo's -H flag.
The directory '/home/mm/.cache/pip' or its parent directory is not
owned by the current user and caching wheels has been disabled.
check the permissions and owner of that directory. If executing
pip with sudo, you may want sudo's -H flag.
Processing /home/mm/nanovna-saver
Collecting PyQt5 (from NanoVNASaver==0.2.2)
Downloading
https://files.pythonhosted.org/packages/3a/fb/eb51731f2dc7c22d8e1a
63ba88fb702727b324c6352183a32f27f73b8116/PyQt5-5.14.1.tar.gz
(3.2MB)
100% |████████████████████████████████| 3.2MB 232kB/s
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3.7/tokenize.py", line 447, in open
buffer = _builtin_open(filename, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-
build-a8hpixj_/PyQt5/setup.py'

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in
/tmp/pip-build-a8hpixj_/PyQt5/
mm@bob-OMEN-by-HP-Laptop:~/nanovna-saver$ python3.7 -m pip install
.
Processing /home/mm/nanovna-saver
Collecting PyQt5 (from NanoVNASaver==0.2.2)
1 https://www.riverbankcomputing.com/static/Docs/PyQt5/installation.html
2 https://github.com/mihtjel/nanovna-saver

/home/nick/projects/nanovna/python/nvna-s-pve-rev-d.odt Page 1 of 6
Using cached
https://files.pythonhosted.org/packages/3a/fb/eb51731f2dc7c22d8e1a
63ba88fb702727b324c6352183a32f27f73b8116/PyQt5-5.14.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3.7/tokenize.py", line 447, in open
buffer = _builtin_open(filename, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-
build-7clot2r6/PyQt5/setup.py'

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in
/tmp/pip-build-7clot2r6/PyQt5/
------------------------------------------------------------------

The pip install command tries to install the latest versions of


the application dependencies i.e. scipy, pyqt5, pyserial, numpy.

ANALYSIS

Check your pip version. This is from a LM-19.3 64-bit machine –


YMMV.

$ pip3 -V
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)

After some tests it seems that;

- the latest version of PyQt5 that pip 9.0.1 will install cleanly
is PyQt 5.13.2 (dated 03.11.19).

- pip 19.3.1 or later is required to install PyQt5-5.14.1 (dated


06.01.20) cleanly.

Whatever the somewhat misleading pip error messages might say, the
underlying problem is that the version of pip installed by...

$ sudo apt install python3-pip

...is now too old to install the latest version of PyQt5.

WORKAROUNDS

There are several workarounds for this problem suggested in group


messages;

- run "python3.7 -m pip install ." as root


- install the dependencies from your distro's repositories
- edit ~/nanovna-saver/requirements.txt

/home/nick/projects/nanovna/python/nvna-s-pve-rev-d.odt Page 2 of 6
All these workarounds represent a compromise, to some extent.

A FIX

A no compromise solution is to install nanovna-saver and its


dependencies into a Python Virtual Environment (PVE)3.

A PVE is a private environment in which a python application can


be run with its own set of dependencies without disturbing the
system python installation and configuration. The only external
dependency is the system version of python that you are using, in
this case python3.7.

The following steps may look daunting, but having done it once you
will be hooked on PVEs!

STEPS

1. Install python3.7

$ sudo apt install python3.7

2. Install python3.7-venv

$ sudo apt install python3.7-venv

(Do not bother to install python3-pip – it’s too old anyway.)

3. Install git

$ sudo apt install git

4. Make a directory for your python virtual environments (PVE)

$ mkdir ~/.venv

5. Create a new PVE for nanovna-saver

$ cd ~/.venv
$ python3.7 -m venv nvna-s --without-pip

6. Activate the PVE

$ source ~/.venv/nvna-s/bin/activate

3 https://docs.python.org/3.7/tutorial/venv.html

/home/nick/projects/nanovna/python/nvna-s-pve-rev-d.odt Page 3 of 6
Notice how the command prompt is now prefixed with the name of the
PVE e.g.

(nvna-s) nick@LM19-3:~/.venv$

7. Install the latest versions of pip, setuptools and wheel

$ cd ~/.venv/nvna-s

$ curl https://bootstrap.pypa.io/get-pip.py | python

% Total % Received % Xferd Average Speed Time Time


Time Current
Dload Upload Total Spent
Left Speed
100 1842k 100 1842k 0 0 1133k 0 0:00:01 0:00:01
--:--:-- 1132k
Collecting pip
Downloading pip-20.3-py2.py3-none-any.whl (1.5 MB)
|████████████████████████████████| 1.5 MB 1.8 MB/s
Collecting setuptools
Downloading setuptools-50.3.2-py3-none-any.whl (785 kB)
|████████████████████████████████| 785 kB 1.7 MB/s
Collecting wheel
Downloading wheel-0.36.0-py2.py3-none-any.whl (34 kB)
Installing collected packages: pip, setuptools, wheel
Successfully installed pip-20.3 setuptools-50.3.2 wheel-0.36.0
Note that pip-20.3 is now installed into the PVE.

8. Clone nanovna-saver

$ git clone https://github.com/NanoVNA-Saver/nanovna-saver.git


Cloning into 'nanovna-saver'...
remote: Enumerating objects: 40, done.
remote: Counting objects: 100% (40/40), done.
remote: Compressing objects: 100% (34/34), done.
remote: Total 5427 (delta 19), reused 13 (delta 6), pack-reused
5387
Receiving objects: 100% (5427/5427), 2.70 MiB | 1.14 MiB/s, done.
Resolving deltas: 100% (3820/3820), done.

/home/nick/projects/nanovna/python/nvna-s-pve-rev-d.odt Page 4 of 6
9. Install dependencies and build

$ cd ~/.venv/nvna-s/nanovna-saver

$ python3.7 -m pip install .


Processing /home/nick/.venv/nvna-s/nanovna-saver
Collecting cython
Downloading Cython-0.29.21-cp37-cp37m-manylinux1_x86_64.whl (2.0
MB)
|████████████████████████████████| 2.0 MB 1.6 MB/s
Collecting numpy
Downloading numpy-1.19.4-cp37-cp37m-manylinux2010_x86_64.whl
(14.5 MB)
|████████████████████████████████| 14.5 MB 2.0 MB/s
Collecting PyQt5
Downloading PyQt5-5.15.2-5.15.2-cp35.cp36.cp37.cp38.cp39-abi3-
manylinux2014_x86_64.whl (68.3 MB)
|████████████████████████████████| 68.3 MB 79 kB/s
Collecting PyQt5-sip<13,>=12.8
Downloading PyQt5_sip-12.8.1-cp37-cp37m-manylinux1_x86_64.whl
(283 kB)
|████████████████████████████████| 283 kB 1.4 MB/s
Collecting pyserial
Downloading pyserial-3.5-py2.py3-none-any.whl (90 kB)
|████████████████████████████████| 90 kB 1.0 MB/s
Collecting scipy
Downloading scipy-1.5.4-cp37-cp37m-manylinux1_x86_64.whl (25.9
MB)
|████████████████████████████████| 25.9 MB 1.8 kB/s
Building wheels for collected packages: NanoVNASaver
Building wheel for NanoVNASaver (setup.py) ... done
Created wheel for NanoVNASaver: filename=NanoVNASaver-0.3.8-py3-
none-any.whl size=173903
sha256=134074d4d5b628fa0c2dc69c4ba3eb6e71230cfa73aa2f8352d34bd41a3
7cf65
Stored in directory:
/home/nick/.cache/pip/wheels/b0/71/5f/5abb53cbb3005997bcd3e3d2be22
de847b00da45f919046fc4
Successfully built NanoVNASaver
Installing collected packages: PyQt5-sip, numpy, scipy, pyserial,
PyQt5, cython, NanoVNASaver
Successfully installed NanoVNASaver-0.3.8 PyQt5-5.15.2 PyQt5-sip-
12.8.1 cython-0.29.21 numpy-1.19.4 pyserial-3.5 scipy-1.5.4

10. Run nanovna-saver and test

$ python3.7 ./nanovna-saver.py
NanoVNASaver 0.3.8

Copyright (C) 2019, 2020 Rune B. Broberg


Copyright (C) 2020 NanoVNA-Saver Authors

/home/nick/projects/nanovna/python/nvna-s-pve-rev-d.odt Page 5 of 6
This program comes with ABSOLUTELY NO WARRANTY
This program is licensed under the GNU General Public License
version 3

See https://github.com/NanoVNA-Saver/nanovna-saver for further


details.

Settings: /home/nick/.config/NanoVNASaver/NanoVNASaver.ini

nanovna-saver should run correctly.

11. Deactivate the PVE

When you are done testing...

$ deactivate
$ cd

You should not get any error messages during the creation of the
PVE, installation of nanovna-saver or at run time.

12. Startup script

For convenience you can start nanovna-saver from a simple bash


script e.g.

#!/bin/bash
# start-nvna-s.sh
cd
source ~/.venv/nvna-s/bin/activate
python3.7 ./.venv/nvna-s/nanovna-saver/nanovna-saver.py
deactivate

Don’t forget to give yourself execute permission...

$ chmod +x ./start-nvna-s.sh

To run nanovna-saver...

$ ~/start-nvna-s.sh

You can also create a desktop launcher for the script.

Hope this helps. Comments welcome.

73
Nick
G3VNC

/home/nick/projects/nanovna/python/nvna-s-pve-rev-d.odt Page 6 of 6

You might also like