Importing library 'RPA.Desktop' failed: ModuleNotFoundError: No module named 'RPA'

Hi guys,
I’m new to RPA. I want to learn more about desktop library.
I configured visual studio with plugins and downloaded example windows calculator project.
When I’m trying to run it I got error message

Importing library ‘RPA.Desktop’ failed: ModuleNotFoundError: No module named ‘RPA’

Code example:
*** Settings ***
Library RPA.Desktop.Windows
Library RPA.Desktop
Library String

*** Keywords ***
Open the Calculator
Open Executable calc.exe Calculator

How can I import Desktop and Desktop.Windows libraries as it looks like the RPAFramework does not recognize these.
All other libs works fine and are accessible.

1 Like

Hi @grinti01,

How are you running the bot?

…also please note that this robot when it is executed it fails on purpose as this highlights the difference of automating desktop applications based on application Ids instead of image-based detection.

vscode-run-bot

BR, Kari

Hi Kari,
thanks for your reply.
When I am trying to run the script in the way described by you I got results like:

[ ERROR ] Error in file ‘c:\Robocorp\example-windows-calculator-master\tasks.robot’ on line 2: Importing library ‘RPA.Desktop.Windows’ failed: SyntaxError: invalid syntax (init.py, line 381)
Traceback (most recent call last):
File “C:\Users\grinti\AppData\Local\robocorp\holotree\b1f3c244e_09529949\lib\site-packages\RPA\Desktop_init_.py”, line 10, in
import comtypes.client
PYTHONPATH:
c:\Robocorp\example-windows-calculator-master
c:\Robocorp\example-windows-calculator-master
C:\Users\grinti\AppData\Local\robocorp\holotree\b1f3c244e_09529949\python37.zip
C:\Users\grinti\AppData\Local\robocorp\holotree\b1f3c244e_09529949\DLLs
C:\Users\grinti\AppData\Local\robocorp\holotree\b1f3c244e_09529949\lib
C:\Users\grinti\AppData\Local\robocorp\holotree\b1f3c244e_09529949
C:\Users\grinti\AppData\Local\robocorp\holotree\b1f3c244e_09529949\lib\site-packages
C:\Users\grinti\AppData\Local\robocorp\holotree\b1f3c244e_09529949\lib\site-packages\win32
C:\Users\grinti\AppData\Local\robocorp\holotree\b1f3c244e_09529949\lib\site-packages\win32\lib
C:\Users\grinti\AppData\Local\robocorp\holotree\b1f3c244e_09529949\lib\site-packages\Pythonwin
[ ERROR ] Error in file ‘c:\Robocorp\example-windows-calculator-master\tasks.robot’ on line 3: Importing library ‘RPA.Desktop’ failed: SyntaxError: invalid syntax (init.py, line 381)
Traceback (most recent call last):
File “C:\Users\grinti\AppData\Local\robocorp\holotree\b1f3c244e_09529949\lib\site-packages\RPA\Desktop_init_.py”, line 10, in
import comtypes.client
PYTHONPATH:
c:\Robocorp\example-windows-calculator-master
c:\Robocorp\example-windows-calculator-master
C:\Users\grinti\AppData\Local\robocorp\holotree\b1f3c244e_09529949\python37.zip
C:\Users\grinti\AppData\Local\robocorp\holotree\b1f3c244e_09529949\DLLs
C:\Users\grinti\AppData\Local\robocorp\holotree\b1f3c244e_09529949\lib
C:\Users\grinti\AppData\Local\robocorp\holotree\b1f3c244e_09529949
C:\Users\grinti\AppData\Local\robocorp\holotree\b1f3c244e_09529949\lib\site-packages
C:\Users\grinti\AppData\Local\robocorp\holotree\b1f3c244e_09529949\lib\site-packages\win32
C:\Users\grinti\AppData\Local\robocorp\holotree\b1f3c244e_09529949\lib\site-packages\win32\lib
C:\Users\grinti\AppData\Local\robocorp\holotree\b1f3c244e_09529949\lib\site-packages\Pythonwin

Tasks

Run Examples | FAIL |
No keyword with name ‘Open Executable’ found.

Tasks | FAIL |
1 task, 0 passed, 1 failed

Output: c:\Robocorp\example-windows-calculator-master\output\output.xml
Log: c:\Robocorp\example-windows-calculator-master\output\log.html
Error: exit status 1
PS C:\Robocorp\example-windows-calculator-master>

Interesting thing is that when I am trying to add additional Library and start writing RPA. I can see all other libraries except these two related with DESKTOP.

I did not change yaml configration files.

I’m having the same problem too

This error is not about Library import, are you running example as its in Git or have you made some modifications?

No changes made. Downloaded the package, unzipped , added to visual studio and run as Kari presented above.
I can import other libs and run tests.

@gomesamantha2303 @grinti01

Apologies for the RPA.Desktop.Windows not functioning like expected. There was an issue with the rpaframework=12.1.1 in your Conda.yaml file that is most likely causing your issue. Please change the version in your Conda.yaml file to 12.2.0 and you should not get this error message on the next run. Let me know if you are still having issues.

Best,
Tim

Hi Tim,
I updated Conda.yaml with rpaframework version 12.1.1.

List of libs deployed
95 | rpaframework 12.1.1 pypi | N/A

  •   -        -       |   96  |  rpaframework-core                   6.5.1         pypi                |  N/A
    
  •   -        -       |   97  |  rpaframework-dialogs                0.4.2         pypi                |  N/A
    
  •   -        -       |   98  |  rpaframework-pdf                    1.30.4        pypi                |  N/A
    
  •   -        -       |   99  |  rpaframework-recognition            0.7.2         pypi                |  N/A
    

Unfortunately with new version the issue still appears

[ ERROR ] Error in file ‘c:\Robocorp\example-windows-calculator-master\tasks.robot’ on line 2: Importing library ‘RPA.Desktop.Windows’ failed: SyntaxError: invalid syntax (init.py, line 375)
Traceback (most recent call last):
File “C:\Users\grinti\AppData\Local\robocorp\holotree\b1f3c244e_791b5f1e\lib\site-packages\RPA\Desktop_init_.py”, line 10, in
import comtypes.client

Sorr Tim missunderstood :slight_smile: changing the rpaframework to version 12.2.0

And with 12.2.0 rpaframework I can see the same issue

  •   -        -       |   95  |  rpaframework                        12.2.0        pypi                |  N/A
    
  •   -        -       |   96  |  rpaframework-core                   6.5.1         pypi                |  N/A
    
  •   -        -       |   97  |  rpaframework-dialogs                0.4.2         pypi                |  N/A
    
  •   -        -       |   98  |  rpaframework-pdf                    1.30.4        pypi                |  N/A
    
  •   -        -       |   99  |  rpaframework-recognition            0.7.2         pypi                |  N/A
    

[ ERROR ] Error in file ‘c:\Robocorp\example-windows-calculator-master\tasks.robot’ on line 2: Importing library ‘RPA.Desktop.Windows’ failed: SyntaxError: invalid syntax (init.py, line 375)
Traceback (most recent call last):
File “C:\Users\grinti\AppData\Local\robocorp\holotree\b1f3c244e_59f207d3\lib\site-packages\RPA\Desktop_init_.py”, line 10, in
import comtypes.client

@grinti01

Thank you for changing the version. I will continue to look into this and get back to you when I have a solution.

Best,
Tim

One thing just caught my eye as a late Friday pick-up:

…the last line here suggests that the VS Code terminal is running Powershell… which is possibly a curve-ball that we have not looked at.
Need to get back to this on Monday.

Thanks for the patience and reporting @grinti01 !

Status report,

We are now hunting a problem related to RPA.Desktop and SetupTools that is probably causing this.
Will get back to here as soon as we figure out what is going on.

Sorry for the hassle.

Hi @grinti01,

The team has been working hard to solve this issue and it should now be resolved by updating your conda.yaml file rpaframework version to 12.5.1 (“rpaframework==12.5.1”). Please let me know if you have any questions or further issues.

Best,
Tim

3 Likes