# Python script problem

**URL:** https://www.finalbuilder.com/forums/t/python-script-problem/2516
**Category:** Discussion
**Created:** [January 19, 2017, 2:23am UTC](https://www.finalbuilder.com/forums/t/python-script-problem/2516 "2017-01-19T02:23:34Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![dumarjo](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/d/f475e1/32.png) [@dumarjo](https://www.finalbuilder.com/forums/u/dumarjo)
#### Post date: [January 19, 2017, 2:23am UTC](https://www.finalbuilder.com/forums/t/python-script-problem/2516/1 "2017-01-19T02:23:34Z")

</div>

Hi,  
  
I try to get my python script worling with finalbuilder 8. I have a small script that send rest api to a woordpress.&nbsp;  
  
The script is working well if executed from python 2.7. But if I execute it with final builder, the script could not find my librarie (installed from pip command.&nbsp;  
  
I have added the python lib path to the script option. The library as been installed in the c:\python27\lib\site-packages\wordpress\_json  
  
So here the script  
---------------------------------------------------------------------  
from wordpress\_json import WordpressJsonWrapper  
  
wp = WordpressJsonWrapper(‘[http://192.168.2.89/wp-json/wp/v2](http://192.168.2.89/wp-json/wp/v2)’, ‘admin’, ‘password’)  
  
wp.create\_post(data=dict(title=“My title3”, content=“My content”, status=“publish”))  
---------------------------------------------------------------------  
  
The problem is that the python could not find the library  
  
Run Script  
&nbsp; &nbsp; Status:&nbsp;  
&nbsp; &nbsp; &nbsp; Date: 2017-01-19  
&nbsp; &nbsp; &nbsp; Time: 08:20:02:691  
&nbsp; &nbsp; &nbsp; &nbsp;End: 08:20:05:860  
&nbsp; Duration: 00:00:03:169  
  
Action Messages:  
Traceback (most recent call last):  
&nbsp; File “script”, line 4, in   
ImportError: No module named wordpress\_json

  

So I try to add the full path to the library &nbsp;with this new path  
  
import sys  
sys.path.append(‘C:\Python27\Lib\site-packages’)  

  
No I get this error  
  
Run Script  
&nbsp; &nbsp; Status:&nbsp;  
&nbsp; &nbsp; &nbsp; Date: 2017-01-19  
&nbsp; &nbsp; &nbsp; Time: 08:21:42:936  
&nbsp; &nbsp; &nbsp; &nbsp;End: 08:21:45:863  
&nbsp; Duration: 00:00:02:927  
  
Action Messages:  
Traceback (most recent call last):  
&nbsp; File “script”, line 4, in   
&nbsp; File “C:\Python27\Lib\site-packages\wordpress\_json\__init_\_.py”, line 16, in   
&nbsp; File “C:\Python27\Lib\site-packages\requests\__init_\_.py”, line 52, in   
&nbsp; File “C:\Python27\Lib\site-packages\requests\packages\__init_\_.py”, line 27, in   
&nbsp; File “C:\Python27\Lib\site-packages\requests\packages\urllib3\__init_\_.py”, line 8, in   
&nbsp; File “C:\Python27\Lib\site-packages\requests\packages\urllib3\connectionpool.py”, line 11, in   
&nbsp; File “C:\Python27\Lib\site-packages\requests\packages\urllib3\exceptions.py”, line 2, in   
&nbsp; File “C:\Python27\Lib\site-packages\requests\packages\urllib3\packages\six.py”, line 701, in   
&nbsp; File “C:\Python27\Lib\site-packages\requests\packages\urllib3\packages\six.py”, line 692, in exec\_  
AttributeError: ‘module’ object has no attribute '\_getframe’  

  

I’m not an python expert, so this is now out of my knowlege. Is it possible to use the python 2.7 instead of using ironPython ?  
  
Here the official doc  
  
[https://pypi.python.org/pypi/wordpress\_json](https://pypi.python.org/pypi/wordpress_json)  
  
Regards  
  
Jonathan

---

<div class="post-metadata">

### Author: ![nevar](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/n/c4cdca/32.png) [@nevar](https://www.finalbuilder.com/forums/u/nevar)
#### Post date: [January 19, 2017, 10:52am UTC](https://www.finalbuilder.com/forums/t/python-script-problem/2516/2 "2017-01-19T10:52:04Z")

</div>

Hi Jonathan,   
  
 The python script engine inside FinalBuilder is iron-python. From my understanding (I will double check with Vincent when he gets in) it will not allow the loading of libraries from pip.   
  
 The solution here is to run the script through a shell command using python directly. Inside a execute program action use the following similar command.   
  
 C:\Python27\python.exe C:\Users\Username\Desktop\my\_python\_script.py   
  
 where “C:\Users\Username\Desktop\my\_python\_script.py” is a python script file containing the script you have listed above.

---

<div class="post-metadata">

### Author: ![dumarjo](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/d/f475e1/32.png) [@dumarjo](https://www.finalbuilder.com/forums/u/dumarjo)
#### Post date: [January 20, 2017, 2:35am UTC](https://www.finalbuilder.com/forums/t/python-script-problem/2516/3 "2017-01-20T02:35:56Z")

</div>

> Posted By [Jason Smith](https://www.finalbuilder.com/users/jason-duffy-smith) on 19 Jan 2017 03:52 PM  
> Hi Jonathan,   
>   
> The python script engine inside FinalBuilder is iron-python. From my understanding (I will double check with Vincent when he gets in) it will not allow the loading of libraries from pip.   
>   
> The solution here is to run the script through a shell command using python directly. Inside a execute program action use the following similar command.   
>   
> C:\Python27\python.exe C:\Users\Username\Desktop\my\_python\_script.py   
>   
> where "C:\Users\Username\Desktop\my\_python\_script.py" is a python script file containing the script you have listed above.

  
  
Hi Jason,  
  
How I will be able to access FinalBuilder Variable with external script ? With Environnement Variable ?  
  
Regards  
  
Jonathan

---

<div class="post-metadata">

### Author: ![nevar](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/n/c4cdca/32.png) [@nevar](https://www.finalbuilder.com/forums/u/nevar)
#### Post date: [January 22, 2017, 10:59am UTC](https://www.finalbuilder.com/forums/t/python-script-problem/2516/4 "2017-01-22T10:59:10Z")

</div>

Hi Johnathan,   
  
You will need to pass them as command line parameters to the python script. This is a good tutorial on how to achieve this locate at:   
  
[https://www.tutorialspoint.com/python/python\_command\_line\_arguments.htm](https://www.tutorialspoint.com/python/python_command_line_arguments.htm)  
  
When passing the variables as command line parameters you will need to quote each parameter if there are spaces in the values. For example:  
  
python test.py “%myVar1%” “%myVar2%” “%myVar3”&nbsp;
