Forum Discussion

Ryu's avatar
Ryu
Contributor
7 years ago

Python in TestComplete - having trouble importing psutil

I am trying to import the psutil library for use in my tests with the following:

 

import sys
sys.path.insert(0, "C:\\Python\\Python36-32\\Lib\\site-packages\\psutil\\psutil-5.4.5-cp35-cp35m-win32.whl")

import psutil

 

Every time, I will get this error:

Python runtime error. ImportError: cannot import name '_psutil_windows'

 

I get the same error if I point PATH to the residing folder instead of the .whl file.  I get a "module not found" error if I point PATH to the site-packages folder.  What am I doing wrong?

 

Version info:

TC Version 12.5

TC Python Version: 3.6.0

Local Python Version: 3.6.0

pip version: 10.0.1 

psutil version: 5.4.5

  • So, in case anyone was wondering, I had one our devs in my office helping me figure it out and we found that I just wasn't pointing to the correct folder.  It is working now.  Took the two of us 5 hours to figure that out, after much trial and error.

8 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    What bit-wise version of TestComplete are you running (check Help | About)?  Based upon the path that you're using, you're trying to import and use a 32-bit library.  If you're using the 64-bit TestComplete installation, this could be the cause of your problem.

     

    The 64-bit version and 32-bit version of TestComplete are installed simultaneously on a machine.  

     

    64-bit -> C:\Program Files (x86)\SmartBear\TestComplete 12\x64\bin\TestComplete.exe

     

    32-bit -> C:\Program Files (x86)\SmartBear\TestComplete 12\bin\TestComplete.exe

    • Ryu's avatar
      Ryu
      Contributor

      Hi, tristaanogre,

       

       

      I have tried both bit-wise versions of TestComplete and get the same error in both.

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        Is it possible that psutil has dependencies that are not imported into TestComplete?  Quick google query shows it to be a free-ware/open source utility so there may be dependencies that are not compatible or work with TestComplete.

  • Ryu's avatar
    Ryu
    Contributor

    tristaanogre

     

    I have tried copying over to the TC folders and using just the path instead of the wheel file.  Copying over to the folders gives me a "can't find module" error and changing the path to the file path gives me the same error as in the original post.  :(

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      At this point, you're beyond me... I don't know Python.  Others up here perhaps can help.  You could also send a message directly to TestComplete support to see if this is something they can assist with.


  • Ryu's avatar
    Ryu
    Contributor

    So, in case anyone was wondering, I had one our devs in my office helping me figure it out and we found that I just wasn't pointing to the correct folder.  It is working now.  Took the two of us 5 hours to figure that out, after much trial and error.

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      OK, just gotta say...  I've been there, done that..   multiple hours trying to debug something that turns out to be a simple little problem.

      Glad that you got it worked out!  thanks for updating us!