cancel
Showing results for 
Search instead for 
Did you mean: 

integrating WHL Python packages

SOLVED
Contributor

integrating WHL Python packages

Hi,

as far as i can understand from the documentation and examples here in the community - TC supports integrating external Python libraries using EGG files, which is a very old (since 2004) format.

Since 2012, the format in use is mostly WHL, and many libraries does not offer you the egg files anymore..

I know that there are converting tools, like HUMPTY but they are on a "it worked for me" bases, since no one can guarantee or promises that nothing won't get mixed up from that convert..

Is there a way to use WHL files too?

 

I've tried it with numpy WHL file and it did not work. (can't attach it here for some reason. you can download here: https://pypi.org/project/numpy/#files)

I'm not sure if it didn't work because the WHL is not supported or because of some other stuff (maybe not all external libs can be integrated? see the message from baxatob, 06-21-2017 11:45 AM, in this link(,): https://community.smartbear.com/t5/TestComplete-Mobile-Application/How-do-i-add-Python-Libraries-and...)

 

thanks,

Nadav.

1 ACCEPTED SOLUTION

Accepted Solutions
Contributor

Re: integrating WHL Python packages

Just to close the loop and save time for future users with the same problem, the solution is as followed:

1. open the WHL file with 7-zip

2. extract the folders in it to "C:\Program Files (x86)\SmartBear\TestComplete 12\Bin\Extensions\Python\Python36\Lib\site-packages" folder.

3. add these lines to the start of your code:

 

import sys

sys.path.insert(0, 'C:\Program Files (x86)\SmartBear\TestComplete 12\Bin\Extensions\Python\Python36\Lib\site-packages'

import <your lib name (in my case: numpy)>

 

that worked like a charm.

 

*** credit to Yuriy from SmartBear Customer Care for the solution ***

View solution in original post

10 REPLIES 10
Highlighted
Community Hero

Re: integrating WHL Python packages

According to https://support.smartbear.com/testcomplete/docs/scripting/specifics/python.html#importing-packages, there's nothing that specifically mentions using EGG vs. WHL.  It's using Python36 and all you really need is to indicate the path and the module name.  Whatever Python36 does from there is normal Python stuff.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
Contributor

Re: integrating WHL Python packages

Yeah,  i read that page many times looking for clues..

That's why i specified the community examples as well..

There it's only egg files.

 

Anyway, this whole procedure is not "normal Python stuff" because this is not how Python external libraries are installed.

 

Also, like i said - i'm not sure if it's an egg\whl issue, or some other limitation to integrate complected Python libraries..

 

Is there anyone here who knows how does this import really work?

Community Hero

Re: integrating WHL Python packages

So... what's not working for you?  I've seen folks importing packages here that are WHL so I know that works.  Are you getting errors? If so, what errors?

 

As for the community example... that's one example where someone is using EGG... Again, others are using WHL so those are working.

 

so... bit more information from you... what have you attempted (code examples from your TestComplete project would be helpful), version of TestComplete you're using, version of Python, any error messages you're getting, etc.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
Contributor

Re: integrating WHL Python packages

OK.. your right - i kind of started from the middle here..

so here it is:

i'm using the latest TC ( 12.50.4142.7) and running it with the X86 version.

No Python installed other than the one supplied by TC.

I've put the whl file in the site-packages folder as needed. (the regular bin, not the X64 one, since i'm using the X86)

my code:

 

numpy_location = 'C:\\Program Files (x86)\\SmartBear\\TestComplete 12\\Bin\\Extensions\\Python\\Python36\Lib\site-packages\\numpy-1.14.5-cp36-none-win32.whl'
from os import sys
sys.path.insert(0,numpy_location)

import numpy as np

def test():
a = [1,2,3]
b = np.array(a)
print(b)

when i ran it - i've stopped with breakpoint before this line:

b = np.array(a)

just to make sure that there are no errors before that line, and everything was ok.

but running this specific line (which is the must basic and simple action you can do with the numpy library), i get this error (screenshot attached as well):

Import error: Importing the multiarray numpy extension module failed. Most likely you are trying to import a failed build of Numpy

.

Just to make sure - i've redownloaded that file again and also made sure that it worked fine on another PC without TC.

 

thanks again.

Nadav.

 

Community Hero

Re: integrating WHL Python packages

@Nadav I got a notification via e-mail that you replied but your reply is not showing up.

 

In your reply, you indicate that you're including the whl file name in your sys.path.  First of all, if you're copying your file into TestComplete's environment, you shouldn't need the sys.path.insert line of code as per https://support.smartbear.com/testcomplete/docs/scripting/specifics/python.html#importing-packages.  If that doesn't work, replace your line of code with below... essentially, for importing packages, the path should be, simply, the path and not the actual file name (whl or egg).

 

Change this line of code:

numpy_location = 'C:\\Program Files (x86)\\SmartBear\\TestComplete 12\\Bin\\Extensions\\Python\\Python36\Lib\site-packages

Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
Contributor

Re: integrating WHL Python packages

removing the file name from the path did not help - i get this error:

Python runtime error.
ModuleNotFoundError: No module named 'numpy'

same when removing the insert to location.

 

 

 

Contributor

Re: integrating WHL Python packages

my other post disappeared again.

no idea why.

 

 

Community Hero

Re: integrating WHL Python packages

Try putting your package into the Lib folder and not the site-packages folder.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
Contributor

Re: integrating WHL Python packages

Just to close the loop and save time for future users with the same problem, the solution is as followed:

1. open the WHL file with 7-zip

2. extract the folders in it to "C:\Program Files (x86)\SmartBear\TestComplete 12\Bin\Extensions\Python\Python36\Lib\site-packages" folder.

3. add these lines to the start of your code:

 

import sys

sys.path.insert(0, 'C:\Program Files (x86)\SmartBear\TestComplete 12\Bin\Extensions\Python\Python36\Lib\site-packages'

import <your lib name (in my case: numpy)>

 

that worked like a charm.

 

*** credit to Yuriy from SmartBear Customer Care for the solution ***

View solution in original post

New Here?
Join us and watch the welcome video:
Top Kudoed Authors