yboetz / pyznap

ZFS snapshot tool written in python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pyznap setup failure

jedi-nz opened this issue · comments

Hi, I was wondering if someone could help me with this...

root@Ubuntu19:/home/mike# pyznap setup -p /etc/pyznap/
Traceback (most recent call last): File "/usr/local/bin/pyznap", line 6, in <module> from pyznap.main import main File "/usr/local/lib/python2.7/dist-packages/pyznap/main.py", line 18, in <module> from .utils import read_config, create_config File "/usr/local/lib/python2.7/dist-packages/pyznap/utils.py", line 14, in <module> from subprocess import Popen, PIPE, TimeoutExpired, CalledProcessError ImportError: cannot import name TimeoutExpired

pyznap needs python 3.5+, you installed it for python 2.7. Install it again using pip3 install --user pyznap (as your root user), then it should work without problem.

Ok got it sorted.

mike@Ubuntu19:~$ sudo pip3 install --user pyznap
[sudo] password for mike:
Collecting pyznap Downloading https://files.pythonhosted.org/packages/11/60/cb90deef643313ace14cf78efbb0c9b5517664c3a3f7be36230ab1751020/pyznap-1.5.0-py3-none-any.whl
Installing collected packages: pyznap
The script pyznap is installed in '/root/.local/bin' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pyznap-1.5.0
mike@Ubuntu19:~$ sudo setup -p /etc/pyznap
sudo: setup: command not found
mike@Ubuntu19:~$ sudo /root/.local/bin/pyznap setup -p /etc/pyznap
May 05 19:32:47 INFO: Starting pyznap...
May 05 19:32:47 INFO: Initial setup...
May 05 19:32:47 INFO: Creating directory /etc/pyznap...
May 05 19:32:47 INFO: Creating sample config /etc/pyznap/pyznap.conf...
May 05 19:32:47 INFO: Finished successfully...

Hopefully the fact that the script pyznap is not installed on PATH will not cause me any issues.

Thank you for your help.

If you run pyznap with cronjob, you can define the PATH in the cron file. Or simply always call pyznap with the full path /root/.local/bin/pyznap, then you wont have any problem.

Hi Yannick can you help with this? I am running Ubuntu 22.04

root@mail:~# which pyznap
/usr/local/bin/pyznap
root@mail:~# /usr/local/bin/pyznap setup -p /etc/pyznap
Traceback (most recent call last):
  File "/usr/local/bin/pyznap", line 5, in <module>
    from pyznap.main import main
  File "/usr/local/lib/python2.7/dist-packages/pyznap/main.py", line 18, in <module>
    from .utils import read_config, create_config
  File "/usr/local/lib/python2.7/dist-packages/pyznap/utils.py", line 14, in <module>
    from subprocess import Popen, PIPE, TimeoutExpired, CalledProcessError
ImportError: cannot import name TimeoutExpired
root@mail:~# pip3 install --user pyznap
Command 'pip3' not found, but can be installed with:
apt install python3-pip
root@mail:~# apt install python3-pip
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
python3-pip is already the newest version (22.0.2+dfsg-1ubuntu0.4).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Someone said I have to exit the root shell to use the --user option but that didn't work either:

mike@mail:~$ sudo pip3 install --user pyznap
[sudo] password for mike: 
sudo: pip3: command not found

The first error is because you installed pyznap for python 2.7, but it needs python 3. As your root user do pip3 install --user pyznap to install pyznap properly for python 3. You need to use root since pyznap needs root to run zfs commands.

I solved it with

root@mail:/home/mike# /usr/bin/pip3.10 install --user pyznap
Collecting pyznap
  Downloading pyznap-1.6.0-py3-none-any.whl (39 kB)
Installing collected packages: pyznap
  WARNING: The script pyznap is installed in '/root/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pyznap-1.6.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

It seems python3-pip may not have been installed correctly on my system.