Forum Discussion

matju's avatar
matju
Senior Member
9 years ago

Calling 3rd party packages from scripts written in Python

Hello,   I'm trying to import external 3rd party packages from my scripts written in Python language. Is there a way to use Python installed in different folder? I was trying to use default "site...
  • ghuff2's avatar
    9 years ago

    TestComplete installs it's own python instance so the third-party package in the site-packages folder won't work. If you copy the third-party package you want from the site-packages into the TestComplete python folder it will work.

     

    For example I use the pytz and tzlocal packages. After installing through pip, I copied those folders from the site-packages folder into C:\Program Files\SmartBear\TestComplete 11\Bin\Extensions\Python\Python34\Lib . Then just import like regular and it should work.

     

     

    I think you could also add the site-packages folder to the sys path like you are in your code, I think the mistake you are making is not escaping the backslash character in your string or using a raw string. So it should be sys.path.append("C:\\Data\\Python\\Lib\\site-packages") or sys.path.append(r"C:\Data\Python\Lib\site-packages")