Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RIDE with Python 2.7 and robotframework with Python 3 #1703

Closed
verybadsoldier opened this issue Jul 24, 2017 · 5 comments
Closed

RIDE with Python 2.7 and robotframework with Python 3 #1703

verybadsoldier opened this issue Jul 24, 2017 · 5 comments

Comments

@verybadsoldier
Copy link

Reading this issue (#1568) I have learned that it should be possible to use robotframework with Python 3 and still use RIDE with Python 2 (I need Python 3 functionality for my test cases).

So what I did (I am on Windows 7):
I installed Python 3.6 so that I have installed 2.7 and 3.6 in parallel now. Python 3 is in my PATH.

I start RIDE using Python 2.7 by this command:
C:\Python27\pythonw.exe -c "from robotide import main; main()"

So RIDE seems to run fine. Now when I run a test then RIDE actually tries to run pybot.bat using Python 3 but it fails to load the TestAgentRunner.py:

command: pybot.bat -L TRACE -V C:\Projects\testing\robot-framework-testing\trunk\myproject\configs\hi_lab.py --argumentfile c:\users\robin\appdata\local\temp\RIDEugz9lw.d\argfile.txt --listener C:\Python27\lib\site-packages\robotide\contrib\testrunner\TestRunnerAgent.py:58899:False C:\Projects\testing\robot-framework-testing\trunk\myproject\robot-framework
C:\Users\robin\AppData\Local\Programs\Python\Python36\lib\runpy.py:125: RuntimeWarning: 'robot.run' found in sys.modules after import of package 'robot', but prior to execution of 'robot.run'; this may result in unpredictable behaviour
  warn(RuntimeWarning(msg))
[ ERROR ] Taking listener 'C:\Python27\lib\site-packages\robotide\contrib\testrunner\TestRunnerAgent.py:58899:False' into use failed: Importing listener 'C:\Python27\lib\site-packages\robotide\contrib\testrunner\TestRunnerAgent.py' failed: SyntaxError: invalid syntax (TestRunnerAgent.py, line 196)
Traceback (most recent call last):
  None
PYTHONPATH:
  C:\Users\robin\AppData\Local\Programs\Python\Python36\python36.zip
  C:\Users\robin\AppData\Local\Programs\Python\Python36\DLLs
  C:\Users\robin\AppData\Local\Programs\Python\Python36\lib
  C:\Users\robin\AppData\Local\Programs\Python\Python36
  C:\Users\robin\AppData\Local\Programs\Python\Python36\lib\site-packages

The test still runs but no runtime info is displayed (expect console output) and no test result is displayed. I think this is the relevant error:

[ ERROR ] Taking listener 'C:\Python27\lib\site-packages\robotide\contrib\testrunner\TestRunnerAgent.py:58899:False' into use failed: Importing listener 'C:\Python27\lib\site-packages\robotide\contrib\testrunner\TestRunnerAgent.py' failed: SyntaxError: invalid syntax (TestRunnerAgent.py, line 196)

I can understand that it cannot import the TestRunnerAgent.py (from RIDE) into the Python 3 environment. But is there a solution to use robotframework with Python 3 while still using RIDE?

@HelioGuilherme66
Copy link
Member

Yes, there is a solution for your problem.
Install from my fork, and that problem is gone. (and new ones may appear ;))
pip2 install -U https://github.com/HelioGuilherme66/RIDE/archive/python3.zip
(branch python3, still only compatible with 2.7)

You should also see my fork releases page

@verybadsoldier
Copy link
Author

Thanks for fast reply!

I did that:

C:\Python27\Scripts>pip2 install -U https://github.com/HelioGuilherme66/RIDE/archive/python3.zip
Collecting https://github.com/HelioGuilherme66/RIDE/archive/python3.zip
  Downloading https://github.com/HelioGuilherme66/RIDE/archive/python3.zip
     \ 1.3MB 966kB/s
Installing collected packages: robotframework-ride
  Found existing installation: robotframework-ride 1.5.2.1
    Uninstalling robotframework-ride-1.5.2.1:
      Successfully uninstalled robotframework-ride-1.5.2.1
  Running setup.py install for robotframework-ride ... done
Successfully installed robotframework-ride-1.7.1

But now it cannot run anymore:

C:\Python27\Scripts>C:\Python27\python.exe -c "from robotide import main; main()"
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\robotide\__init__.py", line 78, in main
    _run(inpath, not noupdatecheck, debug_console)
  File "C:\Python27\lib\site-packages\robotide\__init__.py", line 97, in _run
    from robotide.application import RIDE
  File "C:\Python27\lib\site-packages\robotide\application\__init__.py", line 15, in <module>
    from .application import RIDE, Project
  File "C:\Python27\lib\site-packages\robotide\application\application.py", line 23, in <module>
    from robotide.ui.mainframe import RideFrame
  File "C:\Python27\lib\site-packages\robotide\ui\mainframe.py", line 33, in <module>
    from .tree import Tree
  File "C:\Python27\lib\site-packages\robotide\ui\tree.py", line 55, in <module>
    customtreectrl.TR_EDIT_LABELS | customtreectrl.TR_ELLIPSIZE_LONG_ITEMS | \
AttributeError: 'module' object has no attribute 'TR_ELLIPSIZE_LONG_ITEMS'

Maybe any dependencies to other packages?

@HelioGuilherme66
Copy link
Member

Oops, sorry about that.
That is a nice feature to ... for long names in the tree explorer, but it does not exist in wxPython 2.8.12.1.
Please edit the file and remove | customtreectrl.TR_ELLIPSIZE_LONG_ITEMS at line 55 "C:\Python27\lib\site-packages\robotide\ui\tree.py".
After that you could add:

if wx.VERSION >= (3, 0, 3, ''):
    _TREE_ARGS['agwStyle'] |= customtreectrl.TR_ELLIPSIZE_LONG_ITEMS

This is the original code, if you prefer:

if wx.VERSION >= (2, 8, 11, ''): # wx.VERSION_STRING >= '2.8.11.0':
    _TREE_ARGS['agwStyle'] = \
        customtreectrl.TR_DEFAULT_STYLE | customtreectrl.TR_HIDE_ROOT | \
        customtreectrl.TR_EDIT_LABELS

There maybe problems with your existings settings on C:\Users\%USERNAME%\AppData\Roaming\RobotFramework\ride

There will be no pybot selection, you must select robot.
This is change on settings.cfg:

[[Test Runner]]
show_message_log = True
profile = u'robot'
sash_position = 200
runprofiles = [('jybot', 'jybot.bat')]
auto_save = True
_enabled = True

(I am available at our Slack)

@verybadsoldier
Copy link
Author

It is working now! Thanks alot!

I reinstalled RIDE from your URL to do the change in the code but it seems you already did it in the meantime. So I did not have to change anything and it is working now.
As you said, my Execution Profile combo box was empty so I selected robot and it works now, thanks!

@pritamd7k
Copy link

Now how you will gonna use the Robot Framework for your upgraded versions for 64 bit upgraded system without facing issues:

I would like to mention few corrections,
1.while installing wxpython:
you might not need to download wxpython Separately,
Just Open your CMD>Type "pip install wxpython" //(without quote).
2.if you have 64 bit system , try to install 64 bit version of python so that there will be compatibility issues with Eclipse in future.
3.if you are using latest version win10, don't need to add path for Env.Variable Separately , just tick the checkbox "add path" while installing python.
4.While installing latest version of python in Win10, select customized installation and add the path location(where to install>create a new folder in C drive,>named it as Python>and install with providing that as a destination folder)

5.Now the main problem is while installing robotframwork-ride,
if you want install through :Step 1(Step 1 will not work , follow step 2)
C:\Users\pritam>pip install robotframework-ride
following erreor you will get , because Python 3.0 or above doesn't content exec file!
" Traceback (most recent call last):
File "", line 1, in
File "C:\Users\pritam\AppData\Local\Temp\pip-install-53rehg50\robotframework-ride\setup.py", line 20, in
execfile(join(ROOT_DIR, 'src', 'robotide', 'version.py'))
NameError: name 'execfile' is not defined"

Step 2:(Alternative way)
Type the following command it will download and install
C:\Users\pritam>pip install -U --pre https://github.com/HelioGuilherme66/RIDE/archive/python3.zip

6.write ride.py and click enter , it will not work showing the error

Thank you for helping developing and testing RIDE on Python 3 and wxPython 4
Traceback (most recent call last):
  File "c:\python\lib\site-packages\robotide\application\application.py", line 56, in OnInit
    coreplugins.get_core_plugins())
  File "c:\python\lib\site-packages\robotide\context\coreplugins.py", line 22, in get_core_plugins
    from robotide.editor.texteditor import TextEditorPlugin
  File "c:\python\lib\site-packages\robotide\editor\texteditor.py", line 41, in <module>
    from . import robotframeworklexer
  File "c:\python\lib\site-packages\robotide\editor\robotframeworklexer.py", line 17, in <module>
    from pygments.lexer import Lexer
ModuleNotFoundError: No module named 'pygments'
OnInit returned false, exiting...

reason:for the latest version there are having few compatible issues

to solve the issue follow the steps:known issue:
https://github.com/HelioGuilherme66/RIDE/releases/tag/v1.7.2
pip install -U -r https://raw.githubusercontent.com/HelioGuilherme66/RIDE/v1.7.2/requirements.txt
then,
pip install -U https://github.com/HelioGuilherme66/RIDE/archive/v1.7.2.tar.gz

7.now run ride.py
it will work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants