Unable to import FlaUI.FlaUI3 library in pythonnet - python

I am trying to load FlaUI libraries using pythonnet. The code is able to load the FlaUI.UIA3.dll. However, importing FlaUI.UIA3 namespace fails.
Here is my code,
import clr
import sys
dll_path = 'C:\\Users\\amit_tendulkar\\.nuget\\packages\\flaui.core\\3.2.0\\lib\\net45'
dll_path2 = 'C:\\Users\\amit_tendulkar\\.nuget\\packages\\flaui.uia3\\3.2.0\\lib\\net45'
sys.path.append(dll_path)
clr.AddReference('FlaUI.Core')
sys.path.append(dll_path2)
clr.AddReference('FlaUI.UIA3')
from FlaUI.Core import Application
from FlaUI.Core.Conditions import ConditionFactory
from FlaUI.Core.Tools import Retry
from FlaUI.UIA3 import UIA3Automation
from FlaUI.UIA3 import UIA3PropertyLibrary
The error I am getting is below (using command python sample.py),
Traceback (most recent call last):
File ".\ToadApp.py", line 12, in <module>
from FlaUI.UIA3 import UIA3Automation
ModuleNotFoundError: No module named 'FlaUI.UIA3'; 'FlaUI' is not a package
If I don't include the FlaUI.UIA3 library then I am able to Launch the application with Application.Launch('software.exe').
Here is the content of my directory containing FlaUI3.UIA3.dll,
C:\Users\amit_tendulkar>dir C:\Users\amit_tendulkar\.nuget\packages\flaui.uia3\3.2.0\lib\net45
Volume in drive C has no label.
Volume Serial Number is 8692-D75E
Directory of C:\Users\amit_tendulkar\.nuget\packages\flaui.uia3\3.2.0\lib\net45
25-01-2022 22:28 <DIR> .
25-01-2022 22:28 <DIR> ..
17-07-2020 02:05 105,472 FlaUI.UIA3.dll
17-07-2020 02:05 28,095 FlaUI.UIA3.xml
2 File(s) 133,567 bytes
Dotnet version (using Windows 10),
C:\Users\amit_tendulkar>dotnet --version
6.0.101

Looks like FlaUI.UIA3.dll has dependency on Interop.UIAutomationClient.dll.
Updating the code to the below solved my issue.
import clr
import sys
flaui_core_path = 'C:\\Users\\amit_tendulkar\\.nuget\\packages\\flaui.core\\3.2.0\\lib\\net45'
flaui_uia3_path = 'C:\\Users\\amit_tendulkar\\.nuget\\packages\\flaui.uia3\\3.2.0\\lib\\net45'
interop_uiautomation_path = 'C:\\Users\\amit_tendulkar\\.nuget\\packages\\interop.uiautomationclient\\10.18362.0\\lib\\net45'
sys.path.append(flaui_core_path)
clr.AddReference('FlaUI.Core')
sys.path.append(interop_uiautomation_path)
clr.AddReference('Interop.UIAutomationClient')
sys.path.append(flaui_uia3_path)
clr.AddReference('FlaUI.UIA3')
from FlaUI.Core import Application
from FlaUI.Core.Conditions import ConditionFactory
from FlaUI.Core.Tools import Retry
from FlaUI.UIA3 import UIA3Automation
from FlaUI.UIA3 import UIA3PropertyLibrary

Related

ImportError: cannot import name 'OldCsv' from 'pyflink.table.descriptors'

I have recently started using flink for data processing. When I tried to execute table api for hashtag count by importing pyflink, Im not able to import OldCsv and FileSystem from pyflink.table.descriptors.
I have also downloaded apache-flink using: pip install apache-flink
Libraries imported:
from pyflink.table import DataTypes, TableEnvironment, EnvironmentSettings
from pyflink.table.descriptors import Schema, OldCsv , FileSystem
from pyflink.table.expressions import lit
Code:
t_env.get_config().get_configuration().set_string("parallelism.default", "1")
t_env.connect(FileSystem().path(input_file)) \
.with_format(OldCsv()
.field('word', DataTypes.STRING())) \
.with_schema(Schema()
.field('word', DataTypes.STRING())) \
.create_temporary_table('Source')
error:
File "/home/samarth/Data-Engg/Flink/HashtagCounts/hashtag.py", line 4, in <module>
from pyflink.table.descriptors import Schema, OldCsv , FileSystem
ImportError: cannot import name 'OldCsv' from 'pyflink.table.descriptors' (/home/samarth/.local/lib/python3.8/site-packages/pyflink/table/descriptors.py)
Link followed for the above code:
https://nightlies.apache.org/flink/flink-docs-release-1.13/docs/dev/python/table_api_tutorial/

Why can't Python import a file from a relative path?

I found this question helpful, but Python is unable still to find the folder.
I have a Django folder structure that looks like this:
todoproject
pythonDiscordChatbot
processLessons.py
todoapp
testChatFunctions.py
I'm trying to import a function called 'routes' into testChatFunctions.py, but I keep getting this error:
File "c:\Users\Kaij\Documents\chatSiteDjango\todoproject\todoapp\testChatFunctions.py", line 6, in <module>tSiteDjango\todoproject\todoapp\tesssLesson import *tChatFunctions.py", line 6, in <modd 'pythonDiscordChatbot'ule> atSiteDjango> & C:/Users/Kaij/Documents/djangoTests/django_tailwind_project/env/Scripts/
from pythonDiscordChatbot.procechatSiteDjango/todoproject/todoapp/testChatFunctions.pyssLesson import *
ModuleNotFoundError: No module nametSiteDjango\todoproject\todoapp\testChatFunctions.py", line 6, in <module>d 'pythonDiscordChatbot
Here's what I have tried:
# Bring your packages onto the path
import sys, os
sys.path.append(os.path.abspath(os.path.join('..', 'pythonDiscordChatbot')))
# Now do your import
from pythonDiscordChatbot.processLesson import *
# from pythonDiscordChatbot.processLesson import routes
routes("hello", "website_180.02.1")

import in python file has imported file

I have python project like
/project
|__main.py
|__/graph
|____grapher.py
|____object_map_genaration.py
In grapher: import object_map_genaration
In main: import grapher
But I got this error:
ModuleNotFoundError: No module named 'object_map_genaration'
First add an init here:
/project/
|__/main.py
|__/graph/
|____/__init__.py
|____/grapher.py
|____/object_map_genaration.py
Then in grapher.py:
from . import object_map_genaration
And in main.py:
from graph import grapher
You need from grapher import object_map_genaration not just import object_map_genaration, since imports are relative to the root of the main file.

Imported module fails to import sub-module

I have the following folder-structure
premier_league/
|_cli_stats/
|__ __init__.py
|__cli_stats.py
|__get_data/
|__get_stats.py
|__get_id.py
|__api_scraper/
|__api_scraper.py
In cli_stats.py I have the following import:
from get_data.get_stats import SeasonStats
In get_stats.py I have the following import:
from api_scraper.api_scraper import Football.
When running python cli_stats.py from the cli_stats folder the following error occurs.
File "cli_stats.py", line 36, in <module>
from get_data.get_stats import SeasonStats
File "/Users/name/Desktop/Projekt/premier_league_api/cli_stats/get_data/get_stats.py", line 12, in <module>
from api_scraper.api_scraper import Football
ModuleNotFoundError: No module named 'api_scraper'
But when running python get_stats.py from the get_data folder, the import is successful. Why does the import not work when running cli_stats.py from the cli_stats folder?
You have to adjust the import to a relativ one. From theget_stats.pyyou have to step into the directory. The error is that from api_scraper.api_scraper import Football is an absolut import.
Try: in get_stats.py
from .api_scraper.api_scraper import Football
(1 dot before the api_scraper)

Python import error while deploying as package

Following is my project structure:
root directory
| - __init__.py
| - notdoneyet.py
| - helpers.py
| - opencv_generators.py
| - seam_carve.py
| - imgtovideos.py
notdoneyet.py file contains the entry point of project and the remaining scripts are imported as modules and when required.
My __init__.py contains following code:
from .notdoneyet import user_input
from .helpers import createFolder
from .helpers import getFileExtension
from .helpers import writeImage
from .opencv_generators import generateEnergyMap
from .opencv_generators import generateColorMap
from .imagetovideos import generateVideo
from .imagetovideos import getToProcessPaths
from .seam_carve import cropByColumn
from .seam_carve import cropByRow
I have published the package on testPyPI. But when I try to import it after installing on local machine, I get the import error.
Initial code for notdoneyet.py:
import os, sys, cv2, argparse
#Local imports
import imgtovideos as itv
import helpers as hp #Error on this line
import opencv_generators as og
import seam_carve as sc
def main(argsip):
#usr inpt
I am getting the error "no module named helpers"
Here is screenshot of the error:
Please help me.
Thank you.

Categories

Resources