[Solved] Python script only runs from Explorer

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
ocnuybear
Pro Scripter
Posts: 100
Joined: Sun Jul 15, 2018 5:14 pm

[Solved] Python script only runs from Explorer

Post by ocnuybear » Mon Sep 03, 2018 4:33 pm

The code below runs 100% when double clicking the script in explorer under path 'C:\Users\John\Documents\Macro Scheduler 14', but when running it within MS it says 'Python is not properly initialized', the python27.dll file is also present in the same path as the script: 'C:\Users\John\Documents\Macro Scheduler 14'.

Restarted & reinstalled MS, but problem persists

Code: Select all

Let>url=http://ip.jsontest.com/
 
/*
python_code:
 
import urllib2
import json

 
# grab data from http://ip.jsontest.com/ - see www.jsontest.com
response = urllib2.urlopen('%url%')
 
# load the json
dict = json.loads(response.read())
 
# get the ip member
myip = dict["ip"]
 
# make a nice string representation of the dict
sdict = json.dumps(dict)
 
# Anything we print to IO is returned in the PYExec output var
print "All Done"
*/
 
//Load the Python code to a variable
LabelToVar>python_code,pcode
 
//Run the code and request the values of the sdict and myip variables ...
PYExec>pcode,output,sdict,myip
 
//Display the IP address
MessageModal>Your pubic IP is: %myip%
Last edited by ocnuybear on Tue Sep 04, 2018 5:13 am, edited 1 time in total.

User avatar
Grovkillen
Automation Wizard
Posts: 1023
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: Python script only runs from Explorer

Post by Grovkillen » Mon Sep 03, 2018 6:32 pm

You need to provide the libraries "urllib2" and "json" with the same folder/file structure as you see in the Python installation folder.
Let>ME=%Script%

Running: 15.0.24
version history

ocnuybear
Pro Scripter
Posts: 100
Joined: Sun Jul 15, 2018 5:14 pm

Re: Python script only runs from Explorer

Post by ocnuybear » Tue Sep 04, 2018 5:13 am

Just realized I have extracted the python files into the MS Documents folder 'C:\Users\John\Documents\Macro Scheduler 14' instead of using MS Installation folder 'C:\Program Files (x86)\Macro Scheduler 14' :shock:

One's eye tends to look at the last part & sometimes misses the first part :D

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts