Cherrytree: Executable '7za' Not Found on Windows 7 64 and 32 bit

Created on 10 Feb 2019  路  9Comments  路  Source: giuspen/cherrytree

Hi,

Been using CherryTree 0.38.7 on Windows 10 for a couple weeks and it works like a charm. However, when I tried using it my older Windows 7 computers (one is a 32 bits and the other a 64 bits system) I systematically got the ""Binary Executable '7za' Not Found, Check The Package 'p7zip-full' to be Installed
Properly" error message.

I tried to reinstall 7z, I also tried to copy 7za.exe in other places but couldn't get this to work.

After checking the code, I see it all boils down to the variable "subprocess.call" being called with SZA_PATH (with quote characters) and shell=True. Apparently, somethings causes this call(s) to fail on a Windows 7.

One possibility is that "shell=True" is not the right way to call 7za.exe using "subprocess.call":

The only time you need to specify shell=True on Windows is when the command you wish to execute is built into the shell (e.g. dir or copy). You do not need shell=True to run a batch file or console-based executable.
-- REF: https://stackoverflow.com/questions/3022013/windows-cant-find-the-file-on-subprocess-call

If that is the case, I'm afraid there is no workaround for this (eg. by copying 7za.exe to a specific location) unless it is fixed directly in the code.

bug win install\running\future

All 9 comments

I'm surprised because the path to 7za.exe is bond to the path to cherrytree.exe and the two are installed together. Could it be your antivirus made something nasty? Can you try to run the portable version and report what happens?

Hi I did the test and it doesn't change anything.

I have downloaded the latest Python2 version, and I've put together a demo script. And it appears that setting shell=True is causing the error.

On Windows 10, whether we use shell=True or shell=False, we get Subprocess call to '7za' returned a nul error code: TEST PASSED.

On Windows 7 however, when we use shell=False, we also get TEST PASSED., but when we use shell=True, we get Subprocess call to '7za' returned non-nul error code: TEST FAILED. (We can see that the first line of the output states The system cannot find the path specified. even though 7zip is actually called fine. I know, it's weird, but that's how it is ;-P).

Please find below the file header and comments:

"""
TESTID: TEST_CherryTree_with_7Zip_on_Win7_PUBLISHED_190216

DESCRIPTION:

Testing on Windows 7, where we get an error message when opening encrypted archive:
"Binary Executable '7za' Not Found, Check The Package 'p7zip-full' to be Installed Properly"

SAMPLE OUTPUT ON WINDOWS 7 (32 BITS):

T:\>TEST_CherryTree_with_7Zip_on_Win7_PUBLISHED_190216.py
---------------------------------------------------------
Below, test with shell=True
---------------------------------------------------------
The system cannot find the path specified.

7-Zip (a) [32] 15.12 : Copyright (c) 1999-2015 Igor Pavlov : 2015-11-19
(...)

Subprocess call to '7za' returned non-nul error code: TEST FAILED.
---------------------------------------------------------
Below, test with shell=False
---------------------------------------------------------

7-Zip (a) [32] 15.12 : Copyright (c) 1999-2015 Igor Pavlov : 2015-11-19
(...)

Subprocess call to '7za' returned a nul error code: TEST PASSED.
---------------------------------------------------------
End of testing.
---------------------------------------------------------

"""

And here is the sample code that I used:

import os
import tempfile
import subprocess

SHARE_PATH = "C:\\vctemp\\cherrytree_0.38.7_win32_portable\\bin"
SZA_PATH = '"'+os.path.join(SHARE_PATH, "7za.exe")+'"'

def is_7za_available(isShell):
    """Check 7za binary executable to be available"""
    ret_code = subprocess.call("%s" % SZA_PATH, shell=isShell)
    if ret_code:
        print "Subprocess call to '7za' returned non-nul error code: TEST FAILED."
        return False
    print "Subprocess call to '7za' returned a nul error code: TEST PASSED."
    return True

def quicktest_190216_1_sub():
    print "---------------------------------------------------------"
    print "Below, test with shell=True"
    print "---------------------------------------------------------"
    is_7za_available(True)
    print "---------------------------------------------------------"
    print "Below, test with shell=False"
    print "---------------------------------------------------------"
    is_7za_available(False)
    print "---------------------------------------------------------"
    print "End of testing."
    print "---------------------------------------------------------"

def main():
    quicktest_190216_1_sub()

main()

Hi Pino, I will check myself shortly and if setting shell=False has no regressions I'll switch to that

Great, thanks!
Have a good week-end.
P.

Hi Pino, unfortunately shell=False fails to work on both Linux and my Windows XP virtual machine. In the future gtk3 C++ version anyway 7za will be built together with cherrytree so this problem will disappear.

hi. have similar problem on windows 10. a message "Binary Executable '7za' Not Found, Check The Package 'p7zip-full' to be Installed" appears if i try to open my archive.

@misty-morning I advise to install https://www.7-zip.org/ and extract your archive with that, then open with cherrytree the unencrypted document. At the moment I cannot find a solution to this while in the future version this problem will go (unless it is your antivirus that is doing something nasty)

Hi, I think I may have an hypothesis about this problem.

This might be due to the AutoRun capability of cmd.exe. In a nutshell, when starting cmd.exe and that there is an "AutoRun" entry under the key "HKCU\Software\Microsoft\Command Processor", it will run that. Now, if that script contains errors, the special ERRORLEVEL value will be carried over to the main shell session.

Now, considering that is_7za_available is using shell=true (ie. calling 7zip within a shell session, instead of just calling 7zip directly), and reading the exit code, we could be looking at some other failure poisoning the test result and triggering the error message.

@giuspen thank you for the advice. I like the app very much. Good luck with further development.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

afonsomatos picture afonsomatos  路  3Comments

HEDGHOK picture HEDGHOK  路  6Comments

Fixer-007 picture Fixer-007  路  5Comments

tliron picture tliron  路  8Comments

valentinbesse picture valentinbesse  路  8Comments