RED & virtualenv

727 views
Skip to first unread message

Kevin O.

unread,
Aug 26, 2016, 4:31:00 PM8/26/16
to robotframework-users
I have no problem getting RED to pick up libraries installed in the system installation of Python.
But how to have it pick up libraries installed into the site-packages of a virtualenv?
In red.xml, I set the RF installation to point to the folder with the Python executable - $virualenv/bin
Then, when trying to do quickfix on unresolved library I get this error:









The error is referencing the correct folder. And it is a module that is used by RF if I run tests.

I also tried using the system Python/RF and added the site-packages of the virtualenv to the Python path in red.xml.
I got the same error.

Anyone using RED with virtualenv successfully that can share their experiences?

Thanks
Kevin


Michał Anglart

unread,
Aug 29, 2016, 4:13:22 AM8/29/16
to robotframework-users
Hi,

It seems that this is a bug in QuickFix. Could you please open ticket on github (https://github.com/nokia/RED) sharing some more details (how does the import look like inside suite file, how is your red.xml configured etc.) - it would be great if you could provide some small example. 

However when playing with with virtualenv and RED I was able to do the following:
- install virtualenv for python 2.7.9
- create new environment
- install robotframework, requests and robotframework-requests inside it using pip
- added this new environment in RED preferences page (Robot Framework -> Installed frameworks)
- choose this installation in red.xml file of my project
- created test suite with example taken from https://github.com/bulkan/robotframework-requests (Usage section)

At this point I wasn't able to add the library using quick fix. However this is what I was able to do:

- open red.xml, go to Referenced libraries page and under 'Add Python library' button choose $virtualenv/Lib/site-packages/RequestsLibrary/__init__.py file; then in next dialog choose RequestsLibrary
- if 'Auto discover libraries after test suite save action' option is enabled in red.xml (and it should be by default) then RED was also properly recognizing the library after some change&save in my suite file
- the latter can be also run manually by clicking RMB on project and choosing 'Robot framework' -> 'Automatically discover and add libraries to red.xml' from context menu

After any of those methods RED was properly recognizing the library, seeing keywords, providing assistance etc. Note that the example taken from robotframework-requests github page was importing the library using its name ("Library    RequestsLibrary"; inside suite settings section) - this may be important for proper setup. However as I mentioned earlier I wasn't able to import the library properly using QuickFix, so I think we have to look for a deeper cause and fix it.

Hope this will help you. Please report the issue on our github page - thanks in advance!

Michał

Kevin O.

unread,
Aug 29, 2016, 4:52:00 PM8/29/16
to robotframework-users
Thank you for the response.

I logged an issue. In more experimentation, I found steps to repro that did not involve virtualenv.

Thanks for the workaround. It works for me as well. For projects that import many libraries - its a bit tedious though.


Kevin

Michał Anglart

unread,
Aug 30, 2016, 2:59:21 AM8/30/16
to robotframework-users
Thanks. We'll have a closer look and provide fix in upcoming release if possible.

Mariusz Piliszek

unread,
Aug 30, 2016, 10:03:52 AM8/30/16
to robotframework-users
Hi,

I have the same issue with SSHLibrary. Unfortunately the workaround does not work for me. The error is following:
RED was unable to find classes/modules inside 'D:/pyenvs/ride_2.7/Lib/site-packages/SSHLibrary/__init__.py' module
Python interpreter returned following errors:

Traceback (most recent call last):
  File "C:\Users\MPILIS~1\AppData\Local\Temp\RobotTempDir4971081375947008316\module_classes_printer.py", line 53, in <module>
    modules.append(loader.find_module(name).load_module(name))
  File "D:\ProgramFiles\Python27\Lib\pkgutil.py", line 246, in load_module
    mod = imp.load_module(fullname, self.file, self.filename, self.etc)
  File "D:\pyenvs\ride_2.7\Lib\site-packages\SSHLibrary\abstractclient.py", line 25, in <module>
    from .config import (Configuration, IntegerEntry, NewlineEntry, StringEntry,
ValueError: Attempted relative import in non-package

Am I doing something wrong here?

adam.wyp...@gmail.com

unread,
Sep 5, 2016, 4:57:27 AM9/5/16
to robotframework-users
Hi,

You are still using Quick Fix, the workaround is to use Autodiscovery option - see my comment: https://github.com/nokia/RED/issues/36#issuecomment-243330605

Best Regards,
-Adam.

Mariusz Piliszek

unread,
Oct 3, 2016, 9:39:55 AM10/3/16
to robotframe...@googlegroups.com
Hi,

one more comment. Autodiscovery option is not working correctly when you want to use alias name for Library.
Example:
                 *** Settings ***
                 Library           SSHLibrary    timeout=60    WITH NAME    ssh

Gives error:
                 Additional info: RED was unable to find class 'ssh' inside 'D:\pyenvs\robot_framework_on_python27\lib\site-packages\SSHLibrary\library.py' module.

So it looks like it is trying to do:
from SSHLibrary import ssh
which is obviously wrong.

Krzysztof Jozefowicz

unread,
Oct 4, 2016, 2:23:16 AM10/4/16
to robotframework-users
Thanks for input, we will look into it.

br.
K

Mariusz Piliszek

unread,
Oct 4, 2016, 5:57:09 AM10/4/16
to robotframework-users
Two more:
- libraries with arguments are not supported
- dynamic libraries are not supported

adam.wyp...@gmail.com

unread,
Oct 4, 2016, 7:53:55 AM10/4/16
to robotframe...@googlegroups.com
Are Your points are related to Autodiscover or Quick Fix?

Mariusz Piliszek

unread,
Oct 4, 2016, 9:43:53 AM10/4/16
to robotframework-users
well it's hard to say about QuickFix as it is not working correctly at all. It is probably not working with two cases that i have reported as i can see the error is different than reported by Kevin.

Error when trying to do QuickFix on library with arguments:
Unable to import ****************** library
RED python session problem. Following exception has been thrown by python service:

            Traceback (most recent call last):
              File "*****\RobotTempDir6394369345841583571\robot_session_server.py", line 25, in inner
                result['result'] = func(*args, **kwargs)
              File "*****\RobotTempDir6394369345841583571\robot_session_server.py", line 45, in inner
                return func(*args, **kwargs)
              File "*****\RobotTempDir6394369345841583571\robot_session_server.py", line 89, in get_module_path
                module_path = red_modules.get_module_path(module_name)
              File "*****\RobotTempDir6394369345841583571\red_modules.py", line 20, in get_module_path
                raise e
            ImportError: No module named ******************

BTW I'm already on version 0.7.0

--
You received this message because you are subscribed to a topic in the Google Groups "robotframework-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/robotframework-users/7RPzHW10t_w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to robotframework-users+unsub...@googlegroups.com.
To post to this group, send email to robotframework-users@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

adam.wyp...@gmail.com

unread,
Oct 5, 2016, 2:45:27 AM10/5/16
to robotframe...@googlegroups.com
Hi Mariusz,

Thanks for input, in the new upcoming release (0.7.1) Your problems with import library should be solved. See issue: https://github.com/nokia/RED/issues/44 

Best Regards,
-Adam
To post to this group, send email to robotframe...@googlegroups.com.

Krzysztof Jozefowicz

unread,
Oct 5, 2016, 5:16:37 AM10/5/16
to robotframework-users
RED 0.7.1 release is avaliable, you can update from Eclipse or download as RED Product.
More info: https://github.com/nokia/RED/releases

Mariusz, in case of any other problems please create issue on GitHub so it will be proper tracked in release notes and source commits.

br.
K

Mariusz Piliszek

unread,
Oct 11, 2016, 8:47:12 AM10/11/16
to robotframework-users
Are you planning to add possibility to provide arguments for library imports? As I wrote I have some private libraries that needs arguments. They seems to be loading now whit Autodiscover option but on the list of Referenced libraries they are marked as non-accessible.

Krzysztof Jozefowicz

unread,
Oct 13, 2016, 7:23:10 AM10/13/16
to robotframework-users
Hi

Please rise an issue on GitHub: https://github.com/nokia/RED/issues ,I will add internal task for it.
We will have to discuss abot prio as we have a list of high prio items to do as well,I will reply on github issue though.

br.
K

Mariusz Piliszek

unread,
Oct 14, 2016, 6:16:22 AM10/14/16
to kjo...@gmail.com, robotframework-users

To unsubscribe from this group and all its topics, send an email to robotframework-users+unsubscrib...@googlegroups.com.

To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "robotframework-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/robotframework-users/7RPzHW10t_w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to robotframework-users+unsub...@googlegroups.com.
To post to this group, send email to robotframework-users@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages