Closed bsteubing closed 5 years ago
If you use an up-to-date version of eidl installed via conda, it includes the eidl7zip
-dependency: https://github.com/haasad/EcoInventDownLoader/blob/b6aa722262524f74e2bdc1e8353d1c99af047a24/conda-recipe/meta.yaml#L28
This guarantees that you have 7za
on your path, ie C:\Path\to\miniconda\Scripts\7za.exe
. Is this not the case for you?
It is there, but it still throws this error, I don't really get it...
extract command: ['7za', 'x', 'C:/Users/steubingbrp/NO_BACKUP/v3.5/cutoff35.7z', '-oC:\Users\STEUBI~1\AppData\Local\Temp\tmpdp3wqu86']
Traceback (most recent call last): File "C:\Users\steubingbrp\surfdrive\Leiden\python\GitHub\LCA-ActivityBrowser\activity-browser\activity_browser\app\ui\wizards\db_import_wizard.py", line 457, in run self.run_ecoinvent() File "C:\Users\steubingbrp\surfdrive\Leiden\python\GitHub\LCA-ActivityBrowser\activity-browser\activity_browser\app\ui\wizards\db_import_wizard.py", line 472, in run_ecoinvent self.run_extract() File "C:\Users\steubingbrp\surfdrive\Leiden\python\GitHub\LCA-ActivityBrowser\activity-browser\activity_browser\app\ui\wizards\db_import_wizard.py", line 508, in run_extract self.downloader.extract(target_dir=self.tempdir) File "C:\Users\steubingbrp\AppData\Local\Continuum\miniconda3\envs\py36\lib\site-packages\eidl\core.py", line 158, in extract self.extraction_process = subprocess.Popen(extract_cmd) File "C:\Users\steubingbrp\AppData\Local\Continuum\miniconda3\envs\py36\lib\subprocess.py", line 709, in init restore_signals, start_new_session) File "C:\Users\steubingbrp\AppData\Local\Continuum\miniconda3\envs\py36\lib\subprocess.py", line 997, in _execute_child startupinfo) FileNotFoundError: [WinError 2] The system cannot find the file specified
@sonderegger had a similar problem some time ago. I strongly suspect that the windows 8.3 filenames are the problem here: C:\Users\STEUBI~1\AppData\Local\Temp\tmpdp3wqu86
If my assumption is correct, the OS finds 7za
, but doesn't find the temporary directory due to the "shortened" 8.3 filename.
I can't reproduce this error, because i don't have a windows machine with a username longer than 8 characters :smile:
Could you try if this solves the problem:
extract_cmd = ['C:\Program Files\7-Zip\7z.exe', 'x', self.out_path, '-o{}'.format(os.path.abspath(target_dir))]
If os.path.abspath
doesn't work, os.path.realpath
might also be worth a try. Maybe the 8.3 filenames are treated like symbolic links.
Does not work either. To be honest, I don't get it... this works: extract_cmd = ['C:\Program Files\7-Zip\7z.exe', 'x', self.out_path, '-o{}'.format(target_dir)]
But just using subprocess.Popen(extract_cmd) in a console (just like the original code), also works... extract_cmd = ['7za', 'x', r'C:\Users\steubingbrp\NO_BACKUP\v3.5\cutoff35.7z', '-oC:\Users\steubingbrp\NO_BACKUP\v3.5\unzipped1\']
From testing in the console it seems that it is indeed the first argument (7zip) that the error refers to.
another approach to determine if 7za
really is the problem:
import shutil
extract_cmd = [shutil.which('7za'), 'x', self.out_path, '-o{}'.format(target_dir)]
Resolved: it is a PyCharm issue...
Pycharm really hates subprocess it seems...
learned a bit more (although not sure this was a good time investment... grrr.)
I added a warning for this error if eidl is run from pycharm. #15
Currently there is not check whether the 7zip app is installed (or its path added to the windows path)... My workaround was this:
extract_cmd = ['7za', 'x', self.out_path, '-o {}'.format(target_dir)]
But a check / throwing an Error would be more informative