I'm having some trouble with Pyunpack.
The variable thing
is the path to the 7z file.
from pyunpack import Archive
Archive(thing).extractall(str(thing[0:thing.rfind('/')]))
This code is intended to extract the 7z file to its directory.
In this case, thing
is a relative path:
./relative/path/my_7z_file.7z
This returns a vague TypeError:
Traceback (most recent call last):
File "importItAll.py", line 33, in <module>
Archive(thing).extractall(str(thing[0:thing.rfind('/')]))
File "/usr/local/lib/python2.7/dist-packages/pyunpack/__init__.py", line 74, in extractall
self.extractall_patool(directory, patool_path)
File "/usr/local/lib/python2.7/dist-packages/pyunpack/__init__.py", line 41, in extractall_patool
'--outdir=' + directory,
File "/usr/local/lib/python2.7/dist-packages/easyprocess/__init__.py", line 108, in __init__
self.cmd_as_string = ' '.join(self.cmd) # TODO: not perfect
TypeError: sequence item 1: expected string, NoneType found
Taking a look at the code for pyunpack.Archive code. It would appear you are missing the patool dependency of the library. This appears to be a bug within pyunpack where it will return a None for the function, instead of giving a usable error message:
def _exepath(cmd):
for p in os.environ['PATH'].split(os.pathsep):
fullp = os.path.join(p, cmd)
if os.access(fullp, os.X_OK):
return fullp
Which is default behavior for any function within python that doesn't have a return. Installing the patool dependency with pip install patool
or easy_install patool
, should resolve the issue.