# Python activity error

**URL:** <https://forum.uipath.com/t/python-activity-error/53409>\
**Category:** Help\
**Tags:** python, activities\
**Created:** [July 23, 2018, 10:44am UTC](https://forum.uipath.com/t/python-activity-error/53409 "2018-07-23T10:44:19Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![AJISHA\_P](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ajisha_p/32/63729_2.png) [@AJISHA\_P](https://forum.uipath.com/u/AJISHA_P)\
**Post date:** [July 23, 2018, 10:44am UTC](https://forum.uipath.com/t/python-activity-error/53409/1 "2018-07-23T10:44:19Z")

</div>

Main has thrown an exception

Source: Python Scope

Message: The specified Python path is not valid: C:\Python 3.7\Scripts\dist\imgprcs\imgprcs.exe

Exception Type: DirectoryNotFoundException

System.IO.DirectoryNotFoundException: The specified Python path is not valid: C:\Python 3.7\Scripts\dist\imgprcs\imgprcs.exe  
at UiPath.Shared.Activities.AsyncTaskNativeImplementation.BookmarkResumptionCallback(NativeActivityContext context, Object value)  
at UiPath.Shared.Activities.AsyncTaskNativeActivity.BookmarkResumptionCallback(NativeActivityContext context, Bookmark bookmark, Object value)  
at System.Activities.Runtime.BookmarkCallbackWrapper.Invoke(NativeActivityContext context, Bookmark bookmark, Object value)  
at System.Activities.Runtime.BookmarkWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)  
i have checked everything even path also .i copied the path and checked it is correct .dont know y it still throwing error

---

<div class="post-metadata">

**Author:** ![Aravind](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/aravind/32/14959_2.png) [@Aravind](https://forum.uipath.com/u/Aravind)\
**Post date:** [July 23, 2018, 11:42am UTC](https://forum.uipath.com/t/python-activity-error/53409/2 "2018-07-23T11:42:32Z")

</div>

Hai @AJISHA_P,

change the path directory to python.exe “C:\Python 3.7\python.exe”

Regards,  
D.Aravind

---

<div class="post-metadata">

**Author:** ![AJISHA\_P](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ajisha_p/32/63729_2.png) [@AJISHA\_P](https://forum.uipath.com/u/AJISHA_P)\
**Post date:** [July 24, 2018, 5:30am UTC](https://forum.uipath.com/t/python-activity-error/53409/3 "2018-07-24T05:30:23Z")

</div>

But my exe file is imgprcs.exe.  
How can i give path python.exe

---

<div class="post-metadata">

**Author:** ![MahalingPatil](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@MahalingPatil](https://forum.uipath.com/u/MahalingPatil)\
**Post date:** [July 24, 2018, 6:14am UTC](https://forum.uipath.com/t/python-activity-error/53409/4 "2018-07-24T06:14:58Z")

</div>

You have to create a folder called Python36 in the ‘‘C’’ drive(C:\Python36) and you have to install your python in that folder.Python should be 32 bit.

---

<div class="post-metadata">

**Author:** ![AJISHA\_P](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ajisha_p/32/63729_2.png) [@AJISHA\_P](https://forum.uipath.com/u/AJISHA_P)\
**Post date:** [July 24, 2018, 6:55am UTC](https://forum.uipath.com/t/python-activity-error/53409/5 "2018-07-24T06:55:06Z")

</div>

i created one folder python37 in C drive. And installed my python in that folder . and the python is 32 bit only.

Still the problem comes. and it is showing the same error  
Python Scope : The specified Python path is not valid: C:\Python 3.7\Scripts\imgprcs.exe

---

<div class="post-metadata">

**Author:** ![MahalingPatil](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@MahalingPatil](https://forum.uipath.com/u/MahalingPatil)\
**Post date:** [July 24, 2018, 7:04am UTC](https://forum.uipath.com/t/python-activity-error/53409/6 "2018-07-24T07:04:33Z")

</div>

UiPath will support only for the python version of 3.6 and below of it.I have attached a workflow go through it and let me know if you face any issue.

---

<div class="post-metadata">

**Author:** ![MahalingPatil](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@MahalingPatil](https://forum.uipath.com/u/MahalingPatil)\
**Post date:** [July 24, 2018, 7:05am UTC](https://forum.uipath.com/t/python-activity-error/53409/7 "2018-07-24T07:05:05Z")

</div>

[Python\_Workflow.zip](https://global.discourse-cdn.com/uipath/original/3X/2/4/2435a42e187d1abfc49adfca4960b1060e4e9c7b.zip) (617.8 KB)

---

<div class="post-metadata">

**Author:** ![AJISHA\_P](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ajisha_p/32/63729_2.png) [@AJISHA\_P](https://forum.uipath.com/u/AJISHA_P)\
**Post date:** [July 24, 2018, 7:34am UTC](https://forum.uipath.com/t/python-activity-error/53409/8 "2018-07-24T07:34:19Z")

</div>

{  
“message”: “Load Python Script : One or more errors occurred.”,  
“level”: “Error”,  
“logType”: “Default”,  
“timeStamp”: “13:03:34”,  
“processVersion”: “1.0.6767.29355”,  
“fileName”: “Main”,  
“jobId”: “eb8d7d4e-7b14-4c24-90bd-5cc79e3f04c3”,  
“robotName”: “AJISH”  
}

This error is coming

---

<div class="post-metadata">

**Author:** ![MahalingPatil](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@MahalingPatil](https://forum.uipath.com/u/MahalingPatil)\
**Post date:** [July 24, 2018, 7:37am UTC](https://forum.uipath.com/t/python-activity-error/53409/9 "2018-07-24T07:37:11Z")

</div>

Can you attach your workflow.

---

<div class="post-metadata">

**Author:** ![Sob](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/sob/32/27454_2.png) [@Sob](https://forum.uipath.com/u/Sob)\
**Post date:** [July 24, 2018, 7:51am UTC](https://forum.uipath.com/t/python-activity-error/53409/10 "2018-07-24T07:51:21Z")

</div>

[Main (13).xaml](https://global.discourse-cdn.com/uipath/original/3X/1/2/12bf7b08b4e3f9debc8471c3167881a7882235ac.xaml) (4.9 KB)

Kindly find my attachment.  
(I’m Ajisha\_P)

---

<div class="post-metadata">

**Author:** ![AJISHA\_P](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ajisha_p/32/63729_2.png) [@AJISHA\_P](https://forum.uipath.com/u/AJISHA_P)\
**Post date:** [July 24, 2018, 8:18am UTC](https://forum.uipath.com/t/python-activity-error/53409/11 "2018-07-24T08:18:08Z")

</div>

i attached the file. Can you please check it

---

<div class="post-metadata">

**Author:** ![MahalingPatil](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@MahalingPatil](https://forum.uipath.com/u/MahalingPatil)\
**Post date:** [July 24, 2018, 8:43am UTC](https://forum.uipath.com/t/python-activity-error/53409/12 "2018-07-24T08:43:56Z")

</div>

Can you attach imgprcs.py file also

---

<div class="post-metadata">

**Author:** ![AJISHA\_P](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ajisha_p/32/63729_2.png) [@AJISHA\_P](https://forum.uipath.com/u/AJISHA_P)\
**Post date:** [July 24, 2018, 8:48am UTC](https://forum.uipath.com/t/python-activity-error/53409/13 "2018-07-24T08:48:23Z")

</div>

import cv2  
import numpy as np  
import matplotlib.pyplot as plt  
from scipy.stats import itemfreq

#flags = [i for i in dir(cv2) if i.startswith(‘COLOR\_r’)]  
#print(flags)

def itemfreq(a):  
items, inv = np.unique(a, return\_inverse=True)  
freq = np.bincount(inv)  
return np.array([items, freq]).T

#def rgb\_2\_hex(rgb):

# return ‘#%02x%02x%02x’ % rgb

img = cv2.imread(‘img2.png’)  
average\_color = [img[:, :, i].mean() for i in range(img.shape[-1])]  
arr = np.float32(img)  
pixels = arr.reshape((-1, 3))

n\_colors = 5  
criteria = (cv2.TERM\_CRITERIA\_EPS + cv2.TERM\_CRITERIA\_MAX\_ITER, 200, .1)  
flags = cv2.KMEANS\_RANDOM\_CENTERS  
\_, labels, centroids = cv2.kmeans(pixels, n\_colors, None, criteria, 10, flags)

palette = np.uint8(centroids)  
quantized = palette[labels.flatten()]  
quantized = quantized.reshape(img.shape)  
dominant\_color = palette[np.argmax(itemfreq(labels)[:, -1])]

#print(b’#'+b16encode(bytes(dominant\_color)))  
#rgb2hex(dominant\_color)  
print("Average Color : ", average\_color)  
print(“Dominant Color :”, dominant\_color)

#rgb\_2\_hex((dominant\_color))

#print(rgb\_2\_hex(hex()))  
hex = (dominant\_color[0] \<\< 16) + (dominant\_color[1] \<\< 8) + (dominant\_color[2])  
print(hex)

---

<div class="post-metadata">

**Author:** ![AJISHA\_P](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ajisha_p/32/63729_2.png) [@AJISHA\_P](https://forum.uipath.com/u/AJISHA_P)\
**Post date:** [July 24, 2018, 8:49am UTC](https://forum.uipath.com/t/python-activity-error/53409/14 "2018-07-24T08:49:07Z")

</div>

image you can give anything  
i cant upload the file. because i m new user.  
This is the code

---

<div class="post-metadata">

**Author:** ![ajlakasic](https://avatars.discourse-cdn.com/v4/letter/a/b38774/32.png) [@ajlakasic](https://forum.uipath.com/u/ajlakasic)\
**Post date:** [July 24, 2018, 8:49am UTC](https://forum.uipath.com/t/python-activity-error/53409/15 "2018-07-24T08:49:10Z")

</div>

> [@MahalingPatil](#):
>
> n of 3.6 and below of it.I have attached a workflow go through it and let me know if you face any issue.

Hi, I am also trying to get a python script running… And I put the following into my code, but also getting an exception… (Before this, I tried the Path: “C:\Python27\python.exe” and I still have gotten the exception)…

Thanks!

 ![image](https://global.discourse-cdn.com/uipath/original/3X/c/7/c7e01ab16f34493a92191f1c51faaf10874a176b.png)

---

<div class="post-metadata">

**Author:** ![MahalingPatil](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@MahalingPatil](https://forum.uipath.com/u/MahalingPatil)\
**Post date:** [July 24, 2018, 9:13am UTC](https://forum.uipath.com/t/python-activity-error/53409/16 "2018-07-24T09:13:12Z")

</div>

Please follow the bellow steps.

1. Use Python Scope Activity and select the version of the Python and mention the installation path of the Python.
2. Use Load Python Script activity and mention the path of the script(.py).then create a variable with the data type called PythonObject and assign that variable to Result property of this activity.
3. Use Invoke Python Method activity and mention the Method in the property called Name, what you have defined in your Python code.Then you have to pass the Python Object in the property called “Instance”(as output created in the step 2.).Create a variable which of type PythonObject and assign that variable to property called “Output”.
4. Use Get Python Object activity,then you have to pass the Python Object in the property called “Python Object”(as output created in the step 3.)  
5.Create a variable to store the value which is return from your Python and assign that variable to the property called “Output”.Then print the result using write line.

---

<div class="post-metadata">

**Author:** ![ajlakasic](https://avatars.discourse-cdn.com/v4/letter/a/b38774/32.png) [@ajlakasic](https://forum.uipath.com/u/ajlakasic)\
**Post date:** [July 24, 2018, 9:50am UTC](https://forum.uipath.com/t/python-activity-error/53409/17 "2018-07-24T09:50:01Z")

</div>

Thank you for your detailed explanation… I have already done everything as you described (and also looked at your code that you posted above) → still getting the same exception : “Error initializing python engine”. I think I need to install 32bit Python (as I have already seen that many are saying it doesn’t work with the 64bit)…

The other thing I wanted to ask is: In case I have more functions in my python script - \> then your way won’t work? Correct me if I am wrong… Since here I was able to use just one method but in my script I have around 6 - \> that means it is better to use **Run Python Script Activity** within Python Scope?

Thank you very much!!!

---

<div class="post-metadata">

**Author:** ![AJISHA\_P](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ajisha_p/32/63729_2.png) [@AJISHA\_P](https://forum.uipath.com/u/AJISHA_P)\
**Post date:** [July 24, 2018, 10:12am UTC](https://forum.uipath.com/t/python-activity-error/53409/18 "2018-07-24T10:12:10Z")

</div>

An error has occured

Source: Newtonsoft.Json

Message: Error resolving type specified in JSON ‘Python.Runtime.PythonException, Python.Runtime’. Path ‘$type’, line 1, position 462.

Exception Type: JsonSerializationException

Newtonsoft.Json.JsonSerializationException: Error resolving type specified in JSON ‘Python.Runtime.PythonException, Python.Runtime’. Path ‘$type’, line 1, position 462. —\> Newtonsoft.Json.JsonSerializationException: Could not load assembly ‘Python.Runtime’.  
at Newtonsoft.Json.Serialization.DefaultSerializationBinder.GetTypeFromTypeNameKey(TypeNameKey typeNameKey)  
at Newtonsoft.Json.Utilities.ThreadSafeStore`2.AddValue(TKey key) at Newtonsoft.Json.Utilities.ThreadSafeStore`2.Get(TKey key)  
at Newtonsoft.Json.Serialization.DefaultSerializationBinder.BindToType(String assemblyName, String typeName)  
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ResolveTypeName(JsonReader reader, Type& objectType, JsonContract& contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, String qualifiedTypeName)  
— End of inner exception stack trace —  
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ResolveTypeName(JsonReader reader, Type& objectType, JsonContract& contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, String qualifiedTypeName)  
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadMetadataProperties(JsonReader reader, Type& objectType, JsonContract& contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue, Object& newValue, String& id)  
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)  
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)  
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateISerializableItem(JToken token, Type type, JsonISerializableContract contract, JsonProperty member)  
at Newtonsoft.Json.Serialization.JsonFormatterConverter.Convert(Object value, Type type)  
at System.Runtime.Serialization.SerializationInfo.GetValue(String name, Type type)  
at System.Exception…ctor(SerializationInfo info, StreamingContext context)  
at Void .ctor(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)(Object )  
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateISerializable(JsonReader reader, JsonISerializableContract contract, JsonProperty member, String id)  
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)  
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)  
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateISerializableItem(JToken token, Type type, JsonISerializableContract contract, JsonProperty member)  
at Newtonsoft.Json.Serialization.JsonFormatterConverter.Convert(Object value, Type type)  
at System.Runtime.Serialization.SerializationInfo.GetValue(String name, Type type)  
at System.Exception…ctor(SerializationInfo info, StreamingContext context)  
at System.AggregateException…ctor(SerializationInfo info, StreamingContext context)  
at Void .ctor(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)(Object )  
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateISerializable(JsonReader reader, JsonISerializableContract contract, JsonProperty member, String id)  
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)  
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)  
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)  
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)  
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)  
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)  
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)  
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)  
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)  
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)  
at UiPath.Shared.JsonParser.DeserializeObject[T](String jsonValue)  
at UiPath.Models.UiPathDuplexProxy.\<\>c\_\_DisplayClass18\_0.b\_\_0()  
at System.Threading.Tasks.Task.InnerInvoke()  
at System.Threading.Tasks.Task.Execute()

---

<div class="post-metadata">

**Author:** ![AJISHA\_P](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ajisha_p/32/63729_2.png) [@AJISHA\_P](https://forum.uipath.com/u/AJISHA_P)\
**Post date:** [July 24, 2018, 10:22am UTC](https://forum.uipath.com/t/python-activity-error/53409/19 "2018-07-24T10:22:07Z")

</div>

i m getting Json Serialization Exception now.  
Can you Check it out

---

<div class="post-metadata">

**Author:** ![Tron](https://avatars.discourse-cdn.com/v4/letter/t/3da27b/32.png) [@Tron](https://forum.uipath.com/u/Tron)\
**Post date:** [July 31, 2018, 12:45pm UTC](https://forum.uipath.com/t/python-activity-error/53409/20 "2018-07-31T12:45:03Z")

</div>

I have the same problem.

Error resolving type specified in JSON ‘Python.Runtime.PythonException, Python.Runtime’. Path ‘$type’, line 1, position 462.

Please advise if the problem resolves.

[Next page](https://forum.uipath.com/t/python-activity-error/53409.md?page=2)
