I have to write automation scripts using python and Robot framework. I have installed python, Robotframework, RIDE, wxpython. I have installed sikuli library but when I import it in my project, library is not imported. I have tried 'Import Library Spec XML'. My question is from where do I import this .xml or how do I create it?
You might need to declare the Pythonpath on RIDE preferences (Tools>Preferences>Importing), you must add there your libraries location, it helped me with suds library.
I have added there:
C:\Python27\lib\site-packages\robot\libraries
(This could be little different for you if you have installed your python at different location)
Edit:
This could be an issue on the way you are trying to import your library, or you need to download a specific sikuli library that work with robot.
Please check then if you are loading your library like this:
*** Settings ***
Library SikuliLibrary
got it from: https://github.com/rainmanwy/robotframework-SikuliLibrary
First check whether Sikuli is installed in python directory's \Lib\site-packages.
Robot test should contain as below:
* Settings *
Documentation Sikuli Library Demo
Library SikuliLibrary mode=NEW
* Test Cases *
Sample_Sikuli_Test
blabh blabh etc
Related
I'm currently building a minimalist app following this CMake architecture:
-root
--QmlModule
---Component1.qml
---Component2.qml
--App1
---main.cpp
---main.qml
--App2
---main.cpp
---main.qml
I use "qt6_add_qml_module" to create a QML module at "QmlModule" level as a STATIC library.
qt_add_library(myComponentTarget STATIC)
qt6_add_qml_module(myComponentTarget
URI QmlModule
VERSION 1.0
QML_FILES
Component1.qml
Component2.qml
RESOURCES
logo.png)
Then, at App1 (and App2) level, a link to the module is done using "target_link_libraries". "qt6_add_qml_module" does some work behind the scenes in order to expose the module trough an automatically generated plugin named "your_component_URIplugin". More details about this here.
add_executable(App1Exe
main.cpp)
qt6_add_qml_module(App1Exe
URI App1
VERSION 1.0
QML_FILES
main.qml)
target_link_libraries(App1Exe
PRIVATE
myComponentURIplugin)
At Root level, I overload QML_IMPORT_PATH in order to link to the build folder and add all subdirectories.
set(QML_IMPORT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/qmlModule)
add_subdirectory(QmlModule)
add_subdirectory(App1)
add_subdirectory(App2)
I run CMake without any errors, and open App1/main.qml file.
On my import QmlModule, the module can't be found:
module "lupinComponentsplugin" is not installed
How to make my module visible from my Apps ?
What step am I missing ?
I'm currently doing something similar.
I have created a demo app where I import modules. The modules provide QML and C++ items to the main app. Check the comments in the CMAKE files to find out how this works.
Here is the link:
https://gitlab.com/basic53/DemoApp
Feel free to comment on this.
Another tip: If qt_add_qml_module is not working properly, sometimes it is necessary to remove the whole build folder and update the QML code model. You can check the generated files to see, if your plugin has been created with all its types.
CMake itself was fine, this was a runtime error and not a link error.
This issue was raised because the QQmlApplicationEngine wasn't finding path towards my module's QMLDIR.
In the end, the only thing missing was an additional import path ":/" in QQmlEngine:
QQmlApplicationEngine engine;
engine.addImportPath(":/");
I am attempting to import a shared object into my python code, like so:
import bz2
to which I get the following error:
ImportError: ./bz2.so: cannot open shared object file: No such file or
directory
Using the imp module, I can verify that Python can actually find it:
>>> import imp
>>> imp.find_module('bz2')
(<open file 'bz2.so', mode 'rb' at 0xb6f085f8>, 'bz2.so', ('.so', 'rb', 3))
The shared object file is in my PYTHONPATH and my LD_LIBRARY_PATH.
Any insights into why I can't import this shared object? Thanks!
bz2.so is the shared object the provides the bzip functionality (which was written in C) for the python modules. You don't import it directly when you do import bz2 , you are actually importing a python module called bz2 which then uses the .so file.
This usually means you haven't got the development version of the bzip library installed or you don't have a c compiler setup for the pip installer to use to build this for you.
You don't say which linux you are using but the general pattern is look in the package manager for bzip2 dev or devel packages and install those.
I'm using Pelican for a static blog, and attempting to install the figure-ref extension. Since I'm using Markdown, the plugin relies on the figureAltCaption third-party Markdown extension. However I have no idea how to install it.
Pelican has an MD_EXTENSIONS configuration option, but I've tried a few obvious options with no luck. It seems like this is a dead-simple gimme but it's not clear how to proceed. Would love some suggestions.
Unfortunately, the author of figureAltCaption appears to have not provided an install script. My suggestion would be to create one and contribute it as a pull request. This tutorial about creating Extensions for Python-Markdown covers creating an install script as well.
However, as a shortcut, you should be able to just copy the figureAltCaption.py file to the appropriate directory. Usually you want the site-packages directory. As this answer shows, just do the following from Python:
>>> import site; site.getsitepackages()
Then copy the figureAltCaption.py file to the first directory returned.
Now that the extension is on your PYTHONPATH, it should be importable. From the Python prompt, try:
import figureAltCaption
If you get no errors, then it worked and you just need to tell Pelican about it.
MD_EXTENSIONS = ['figureAltCaption']
I'm trying to deploy a django app to heroku.
I have several python libraries which are not on PyPi and so I can't just declare them in requirements.txt file
In local development I've used:
import sys
sys.path += [os.path.dirname(os.path.dirname(__file__))+"\\project-name\\lib"]
inside manage.py and it works fine there.
Obviously it doesn't work on heroku and I get import errors.
What is the recommended way to add libraries like that on heroku?
Thanks.
One way to do it is include the libraries in the repository itself, from which you can import them. That means simply moving the actual folder for each library into your main Django project folder.
- DjangoProject
- AppFolder1
- AppFolder2 ...
- python-library1
- python-library2
When the repository is pushed to Heroku your libraries will be pushed as part of the project.
From here, your imports of these libraries within a view/model etc within any app's folder would
import python-library1
from python-library2 import a_function, a_class
The reason why I suggest the directory structure above is that, most likely, you would not have go back and change any import codes.
If you have a large number of libraries and would like to keep the direcory structure simpler, simply create a folder with a name such as "importables" in the main DjangoProject folder and change the import statements to something such as...
from importables import python-library1
from importables.python-library2 import a_function, a_class
It's not exactly beautiful, but a quick way to get the job done. If you aren't sure where the libraries you'd like to include are located, there's a few ways to quickly see their location using Python (How do I find the location of Python module sources?).
I've already looked through the forums, but I haven't found an answer that is mavlink specific.
I am currently writing script in python, and I want to use a python module of mavlink.
The documentation for mavlink tells me to run mavgenerate.py from my mavlink folder. When I run this script, a gui appears asking for my xml files, a specified output directory, and what language I want my headers in. mavgenerate.py works when I choose to make headers for C, but it gives me the error: "attempted relative import in non-package" when I try to choose python.
my xml files is located at:
C:\Python27\mavlink\message_definitions\v1.0
and I have my python module output directory as:
C:\Python27\mavlink\pymavlink\include
below is a screenshot of my error.
can anyone tell me what I'm doing wrong?
This is quite an old question but i have just encountered with this problem. Solution that i have applied is: in mavgenerate.py replace following lines
sys.path.append(os.path.join('pymavlink','generator'))
from mavgen import *
with
from pymavlink.generator.mavgen import *
I dont know the exact reason of the problem but from
this thread i assume problem lies with python's interpretation of directories as packages.
I have used python 2.7. Tried though to do with python 3.4 but didn't had chance there.