Author Topic: Python implementation: urllib broken?  (Read 2942 times)

0 Members and 1 Guest are viewing this topic.

Offline ahoerl

  • Newbie
  • *
  • Posts: 5
Python implementation: urllib broken?
« on: December 02, 2015, 09:18:09 pm »
Good morning from Austria!

I am trying to use the (attached) Python File to retrieve the materials for our 3D-objects from our internal database.
If I use "python.exe" the file works as expected.

If I try to run those lines from Keyshot Script runner I get an error which complains about missing import modules in urllib.

The error from script runner is:

Traceback (most recent call last):
  File "<string>", line 8, in <module>
  File "C:\Program Files\KeyShot6\bin\py-dist\urllib\request.py", line 85, in <module>
    import bisect
ImportError: No module named 'bisect'

We have bought Keyshot yesterday, so my version of Keyshot 6 Pro should be recent.

Thanks for your help!

Andreas Hörl
Prolicht GmbH - Architectural Ligthing

Offline Morten Kristensen

  • root
  • Administrator
  • Full Member
  • *****
  • Posts: 128
  • Software Engineer, Luxion
Re: Python implementation: urllib broken?
« Reply #1 on: December 03, 2015, 12:54:22 am »
Good morning, Andreas.

The bisect module was trimmed away because it was thought not needed but I will add it back in a future update/release. Thanks for noticing.

I took a look at your code and you can actually refrain from using the os, io, and urllib modules. You only need urllib.request and json.

However, to solve it you can enable detecting a locally installed python 3.4 64-bit by going to "preferences", "advanced" and ticking the "Use local Python paths .." checkbox. Then save and restart KeyShot. To make sure it finds it install python to C:\Python or C:\Python34 (I saw you were on Windows).
« Last Edit: December 03, 2015, 01:02:18 am by Morten Kristensen »

Offline ahoerl

  • Newbie
  • *
  • Posts: 5
Re: Python implementation: urllib broken?
« Reply #2 on: December 03, 2015, 12:58:07 am »
Thank you Morten!

I will try to enable my local python instance.
JSON would improve the way I can use data from our existing systems/databases.

Thank you for the quick reply!

Andreas Hörl
Prolicht Gmbh - Architectural lighting

Offline ahoerl

  • Newbie
  • *
  • Posts: 5
Re: Python implementation: urllib broken?
« Reply #3 on: January 08, 2016, 01:49:11 pm »
Good evening!

Just tried to use the local python instance (again). It just does not work - I always get

Traceback (most recent call last):
  File "<string>", line 5, in <module>
  File "C:\Program Files\KeyShot6\bin\py-dist\urllib\request.py", line 85, in <module>
    import bisect
ImportError: No module named 'bisect'

It works from command line, python is in C:\Python34 (and now in C:\Python)
I have started Keyshot as Admin (same result)
If I start the command prompt as admin: no problem on the command line

python.exe (3.4) is in my System-Path (works)
I have set an additional "PYTHONPATH" --> C:\Python34

Still no luck :(
Unfortunately I need it now (it has been "I want it" for the last few weeks.