cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
chughy
Observer
Observer
3,745 Views
Registered: ‎06-10-2019

Using Python within TCL script in Vivado 2019.1

Hello!

I'm having problems using Python within TCL in the same build scripts I have been using for ages. Since I installed Vivado 2019.1 it seems to call a built in Python 2.7.5 in Vivado (which is broken), not my installed versions. I've tried using the Python installation path directly to no avail - anyone having a similar problem or know a way around this?

Tags (4)
0 Kudos
12 Replies
viviany
Xilinx Employee
Xilinx Employee
3,697 Views
Registered: ‎05-14-2008

Could you post more details about what error/phenomenon you encountered?

-vivian

-------------------------------------------------------------------------------------------------
Don’t forget to reply, kudo, and accept as solution.
-------------------------------------------------------------------------------------------------
如果提供的信息能解决您的问题,请标记为“接受为解决方案”。
如果您认为帖子有帮助,请点击“奖励”。谢谢!
-------------------------------------------------------------------------------------------------
0 Kudos
chughy
Observer
Observer
3,680 Views
Registered: ‎06-10-2019

Sure... I've only tested this on Windows 10, and it appears that all Python scripts called from within the Vivado TCL environment are intercepted and instead use the following:

C:\Xilinx\Vivado\2019.1\tps\win64\python-2.7.5

Obviously the install location may be different... it doesn't matter how I try to specify the Python install path, it always utilizes the Xilinx packaged interpreter.

The error occurs within the GUI and on the command line (cygwin or DOS); the GUI error occurs in my situation post synthesis when executing a tcl.post script that calls a Python sort logs script. The command line error is similar and occurs at any point within the Vivado TCL shell - the following screenshot is an extremely simple example to demonstrate the bug:error.JPG

I have tried callling the install paths directly (even is desperation as a variable) to no avail.

0 Kudos
chughy
Observer
Observer
3,679 Views
Registered: ‎06-10-2019

The simple example in 2018.3.1:works.JPG

At least the last few versions before work as well.

0 Kudos
viviany
Xilinx Employee
Xilinx Employee
3,655 Views
Registered: ‎05-14-2008

Could you share your .tcl and .py scripts so that I can reproduce the issue at my end?

-vivian

-------------------------------------------------------------------------------------------------
Don’t forget to reply, kudo, and accept as solution.
-------------------------------------------------------------------------------------------------
如果提供的信息能解决您的问题,请标记为“接受为解决方案”。
如果您认为帖子有帮助,请点击“奖励”。谢谢!
-------------------------------------------------------------------------------------------------
0 Kudos
watari
Teacher
Teacher
3,645 Views
Registered: ‎06-16-2013

Hi @chughy 

 

Would you modify content at line 123 in <install dir>/tps/<win64 or lnx64>/python-2.7.5/lib/python2.7/encodings/__init

__.py as below ?

 

# original

raise CodecRegistryError,\

# revise

raise CodecRegistryError, \

 

Best regards,

 

0 Kudos
chughy
Observer
Observer
3,613 Views
Registered: ‎06-10-2019

Watari - I actually tried that already, cheers. I also removed the line breaks in frustration, nothing.

Vivian - In my previous post I included cat commands before the script to show what they are doing. Sorry, perhaps I should have made that more clear... the command just displays the contents of the scripts to console.

Does anyone know if there is a way to simply bypass the built-in Python and use our own installation? Version 2.7.5 is really quite old anyway...

0 Kudos
viviany
Xilinx Employee
Xilinx Employee
3,580 Views
Registered: ‎05-14-2008

The following thread may be helpful:

https://bugs.python.org/issue27054

Seems it is with environment variable settings or administrator priviledge.

-vivian

-------------------------------------------------------------------------------------------------
Don’t forget to reply, kudo, and accept as solution.
-------------------------------------------------------------------------------------------------
如果提供的信息能解决您的问题,请标记为“接受为解决方案”。
如果您认为帖子有帮助,请点击“奖励”。谢谢!
-------------------------------------------------------------------------------------------------
0 Kudos
chughy
Observer
Observer
3,541 Views
Registered: ‎06-10-2019

Thanks for that - it looks compelling but I think this is a different problem. Running as administrator makes no difference (in either DOS or CYGWIN shells), and as the post eventually hints on, the PYTHONHOME and PYTHONPATH environment variable are not meant to be set... unless you need to point to additional user libraries, etc.

Besides Python not working at all, the more crucial problem for me is that the Vivado interpreter forces the use of a Python version that is incompatable with a number of our companies scripts. This means even if we can get this to work, we still have a ton of re-writing to do that affects many people in many projects in many locations and isn't something easy to deploy. What I really need is a way to stop Vivado forcing a particular version and allow the user to determine the best tool for their flow.

Cheers!

amol_aeva
Visitor
Visitor
3,313 Views
Registered: ‎01-23-2018

I'm also having issues with this. Same script worked fine in 2018.3.

Its unable to import a python module I'm using. 

0 Kudos
abhimanyu2707
Newbie
Newbie
3,221 Views
Registered: ‎07-22-2019

Hi,

Same problem occured to me, see if below solution helps; Need to run these commands in Vivado 2019.1 before executing user Python:

unset ::env(PYTHONPATH)

unset ::env(PYTHONHOME)

 

amol_aeva
Visitor
Visitor
3,152 Views
Registered: ‎01-23-2018

Ok after the unset and resetting the pythonpath and pythonhome variables it works now. :)


unset ::env(PYTHONPATH)
unset ::env(PYTHONHOME)

set ::env(PYTHONHOME) "/usr"
set ::env(PYTHONPATH) "/usr/lib64/python2.7.zip:/usr/lib64/python2.7:/usr/lib64/python2.7/plat-linux2:/usr/lib64/python2.7/lib-tk:/usr/lib64/python2.7/lib-old:/usr/lib64/python2.7/lib-dynload:/usr/lib64/python2.7/site-packages:/usr/lib64/python2.7/site-packages/gtk-2.0"


To figure out how to set PYTHONPATH do the following on your command line:

$ python

>>> import sys

>>> sys.path

['', '/usr/lib64/python27.zip', '/usr/lib64/python2.7', '/usr/lib64/python2.7/plat-linux2', '/usr/lib64/python2.7/lib-tk', '/usr/lib64/python2.7/lib-old', '/usr/lib64/python2.7/lib-dynload', '/usr/lib64/python2.7/site-packages', '/usr/lib64/python2.7/site-packages/gtk-2.0', '/usr/lib/python2.7/site-packages']

amahpour
Observer
Observer
1,246 Views
Registered: ‎01-28-2015

Actually since Python is already included on my $PATH (Windows 10) I just had to unset those two variables and it worked.

unset ::env(PYTHONPATH)
unset ::env(PYTHONHOME)

Thanks for the tip!

0 Kudos