Closed raceyman closed 4 years ago
You can use preferences to fix this issue.
Open Tools | Preferences | Importing and insert C:\\robot3\libs
there. That should fix the PYTHONPATH for the import.
Surprisingly, this still isn't working for me. If I put C:\\robot3\\libs
in either the "Auto imports", "Pythonpath", or "Library xml directories" field on this page (or all 3 at the same time), I still have the same problem (and, yes, I am restarting RIDE after I make each change).
Whoops - accidentally closed the issue, sorry.
I am running into the same issue with importing standard libraries in RIDE 1.4 using ROBOT 3.0. Was there ever a resolution posted for this error.
0160222 11:23:29.963 [WARN]: Importing test library "Collections" failed
Traceback (most recent call last):
Importing test library 'Collections' failed: ImportError: cannot import name type_name
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/robot/libraries/Collections.py", line 16, in
I don't have that problem (testing with Collections), in Linux with RIDE 1.5.2.1: echo $PYTHONPATH /usr/lib/python2.7/site-packages/robot:.:/usr/lib/jython/Lib/site-packages/robot
I also tested wit Mac OS X 10.8 in a virtualbox and no errors ($PYTHONPATH is empty in env and RIDE's settings).
I am facing the same issue. getting below error,
[ ERROR ] Error in file 'C:\project\atf_testcase\resources\ATFResources.txt': Importing test library 'ATFLibrary' failed: ImportError: No module named ATFLibrary Traceback (most recent call last): None PYTHONPATH: C:\Python27\lib\site-packages\lxml-3.5.0-py2.7-win-amd64.egg C:\Windows\system32\python27.zip C:\Python27\DLLs C:\Python27\lib C:\Python27\lib\plat-win C:\Python27\lib\lib-tk C:\Python27 C:\Python27\lib\site-packages C:\Python27\lib\site-packages\wx-2.8-msw-unicode
Please suugest how to resolve this problem.
It depends on how ATFLibrary is imported at ATFResources.txt, and where it is located. Show us the Library statement in ATFResources.txt and the Path to the file.
We have libraries in sub folders too, our simple solution, add all sub folders into pythonpath. Like "set pythonpath="c:\libs;c:\libs\sub1;c:\libs\sunb2:....."
I've found a solution that appears to work for me. I can't tell you why necessarily, but it seems to solve the initial problem where RIDE shows Libraries in red and the keywords in black - it also causes the funky error message to go away.
If you refer to the original description, my test libraries are in: c:/robot3/libs
, and the essential suggestions above says to put this path on the PYTHONPATH, either manually or via the Preferences item in RIDE. Neither worked for me at all.
After a number of exercises in futility trying to resolve this I found (quite accidentally) that if I used the path c:/robot3
instead, then finally RIDE would show the library as valid; the keywords show up in blue, and there is no error in the RIDE log.
So, in other words, I just put the root folder of my Robot project on the PYTHONPATH, and RIDE seems to find keywords in Python libraries in the main and sub folders of my project. Again, I don't know if it will work for you, but you could try it.
This isn't the perfect solution for me, as my Robot project is portable and I don't know where the user will put it - so it now becomes an educational exercise to try to get users of the project to set the PYTHONPATH properly.
I'm using virtual environment so I can't decide that what is the PYTHONPATH? I cannot import custom libraries with the same error logs.
@ezgiKy This is just a matter of not seeing the keywords help. Are the keywords in python files? If it is a virtual environment, is RIDE installed in it? If not installed, then you should add the full path to the parent of the libraries.
@HelioGuilherme66 Keywords are out of the Python folder. Should it be in Python folder or in virtualenv folder? wxPython and RIDE installed in virtualenv. This is my full Pythonpath as below. Installed custom libraries seem included in pythonpath. But I cannot import it in RIDE.
['', 'C:\Windows\SYSTEM32\python27.zip', 'C:\TAS-master\virtualenv\DLLs', 'C:\TAS-master\virtualenv\lib', 'C:\TAS-master\virtualenv\lib\plat-win', 'C:\TAS-master\virtualenv\lib\lib-tk', 'C:\TAS-master\virtualenv\Scripts', 'c:\python27\Lib', 'c:\python27\DLLs', 'c:\python27\Lib\lib-tk', 'C:\TAS-master\virtualenv', 'C:\TAS-master\virtualenv\lib\site-packages', 'c:\tas-master\rf_exlib', 'c:\tas-master\rf_seleniumbase', 'C:\TAS-master\virtualenv\lib\site-packages\wx-2.8-msw-unicode']
Well, I don't know about having a Zip file in PYTHONPATH.
Does the test run from command line (without errors)?
What errors do you have in Tools>RIDE Log?
Closing because is too old and we cannot reproduce, or lack of information.
I've found a solution that appears to work for me. I can't tell you why necessarily, but it seems to solve the initial problem where RIDE shows Libraries in red and the keywords in black - it also causes the funky error message to go away.
If you refer to the original description, my test libraries are in:
c:/robot3/libs
, and the essential suggestions above says to put this path on the PYTHONPATH, either manually or via the Preferences item in RIDE. Neither worked for me at all.After a number of exercises in futility trying to resolve this I found (quite accidentally) that if I used the path
c:/robot3
instead, then finally RIDE would show the library as valid; the keywords show up in blue, and there is no error in the RIDE log.So, in other words, I just put the root folder of my Robot project on the PYTHONPATH, and RIDE seems to find keywords in Python libraries in the main and sub folders of my project. Again, I don't know if it will work for you, but you could try it.
This isn't the perfect solution for me, as my Robot project is portable and I don't know where the user will put it - so it now becomes an educational exercise to try to get users of the project to set the PYTHONPATH properly.
Hi there, I just want to say that works for me too...it’s really confusing
@Kiwis2012 Since this is an old Closed Issue, maybe you could paste here the versions you are using of Python, RIDE and Robot Framework. Also it would be important to test if the libraries are found on a command window/terminal/shell, by a robot
run.
Python 2.8.11, with Robotframework 3.0 and RIDE 1.5a2, in Windows 7
I have a set of keyword libraries in my project in a structure like this:
The idea being the libs folder contains generic libraries, and there may be multiple "speclib" type folder to allow organization of large keyword libraries that use functions from the more generic libraries.
LibGen.py is
SpecLib.py is:
And I've built a simple test in RIDE to call a keyword in SpecLib:
The test runs fine in RIDE or in Robot, however, RIDE shows the Library in RED and the keyword in BLACK. Keywords for libraries that don't use this sort of importing show up correct in RIDE with the BLUE highlight. Additionally there is an error in the RIDE log:
I've also tried setting the PYTHONPATH to the Library folder, but that does not fix the problem. E.g., using a batch file like this:
Ideally we should be able to use simple imports like this and have RIDE do the proper keyword highlighting.