Author Topic: shutil.make_archive() not working  (Read 1193 times)

0 Members and 2 Guests are viewing this topic.

Offline HamedHem

  • Newbie
  • *
  • Posts: 11
shutil.make_archive() not working
« on: April 05, 2018, 06:47:48 am »
Hi ,

I'm writing an script to collect all project assets and store them into a zip file but when I'm using shutil.make_archive() , Keyshot gives me the following error :


Traceback (most recent call last):
  File "console", line 1, in <module>
  File "C:\Program Files\KeyShot7\bin\py-dist\shutil.py", line 784, in make_archive
    filename = func(base_name, base_dir, **kwargs)
  File "C:\Program Files\KeyShot7\bin\py-dist\shutil.py", line 684, in _make_zipfile
    compression=zipfile.ZIP_DEFLATED) as zf:
  File "C:\Program Files\KeyShot7\bin\py-dist\zipfile.py", line 1079, in __init__
    if isinstance(file, os.PathLike):
AttributeError: 'module' object has no attribute 'PathLike'


Anyone knows why I'm getting such an error ?

Regards.
« Last Edit: April 05, 2018, 06:55:03 am by HamedHem »

Offline Will Gibbons

  • Hero Member
  • *****
  • Posts: 2846
  • willgibbons.com
    • My Website
Re: shutil.make_archive() not working
« Reply #1 on: April 05, 2018, 07:26:41 am »
Curious as to why you would do this... 'Save KSP' in KeyShot does exactly this without requiring a script.

Offline DriesV

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2412
  • Product Specialist at Luxion
Re: shutil.make_archive() not working
« Reply #2 on: April 05, 2018, 08:16:43 am »
Curious to know the motivation as well.
Or would you like to save ksp files through scripting?

Dries

Offline HamedHem

  • Newbie
  • *
  • Posts: 11
Re: shutil.make_archive() not working
« Reply #3 on: April 07, 2018, 12:52:08 am »
Hi Guys ,

Thanks for your response ,

I'm not doing this script for myself , I've got a request for this and trying to see if possible , they want to have a packed file like zip instead of KSP file , when I've gone through the bip file in notepad , I found that all the assets paths are stored in the file so I'm collecting all the assets this way and after that I want to pack them all into a zip file but I've got the above error .

I've also run my script in 'pycharm' and it works just fine so not sure what is going wrong in keyshot console .

Thanks.

Offline MWo

  • Hero Member
  • *****
  • Posts: 803
  • Senior Technical Consultant @ INNEO (Germany)
    • german KeyShot page from INNEO Solutions
Re: shutil.make_archive() not working
« Reply #4 on: April 07, 2018, 11:52:06 pm »
It sounds stupid, but why don’t rename the .ksp to .ksp.zip? Cause it is an archive and can be opens with e.g. 7zip.