Closed ck81 closed 5 years ago
Thanks CK for trying out TagUI for Python and sharing detailed replications steps!
I've tested on Windows 10 before and can't get something like above. Have borrowed a Windows 10 laptop just now and tested again, can't replicate the error that you are seeing. I also tried including into path a local TagUI installation but still, can't replicate the error message above (from CasperJS).
Can you try running the following in command prompt to see if there is any clue on the error message? Change username to your username. That error happens when CasperJS cannot find PhantomJS, but it should be there and detected.
cd C:\Users\username\AppData\Roaming/tagui/src/samples
C:\Users\username\AppData\Roaming/tagui/src/tagui 1_yahoo chrome
If running above gives the same error as you had, can you try doing the following from Python? It will try to download TagUI Windows zip again and unzip. My best guess is somehow the download is corrupted and some folders missing after unzip.
import tagui as t
t.setup()
If you can, upgrade to v1.4 before doing t.setup(). I've just released this version today which fixes issues (eg in #14) with reading text that has special characters from websites. Some computers have their own text encoding, which gives error when trying to read the UTF-8 encoding from TagUI.
pip install tagui --upgrade
Can you try running the following in command prompt to see if there is any clue on the error message? Change username to your username. That error happens when CasperJS cannot find PhantomJS, but it should be there and detected.
cd C:\Users\username\AppData\Roaming/tagui/src/samples C:\Users\username\AppData\Roaming/tagui/src/tagui 1_yahoo chrome
No errors. My TagUI is good.
can you try doing the following from Python? It will try to download TagUI Windows zip again and unzip. My best guess is somehow the download is corrupted and some folders missing after unzip.
import tagui as t t.setup()
The command prompt shows the following and stops there forever:
[TAGUI][INFO] - setting up TagUI for use in your Python environment
[TAGUI][INFO] - downloading TagUI (~200MB) and unzipping to below folder...
[TAGUI][INFO] - C:\Users\user\AppData\Roaming
If you can, upgrade to v1.4 before doing t.setup(). I've just released this version today which fixes issues (eg in #14) with reading text that has special characters from websites. Some computers have their own text encoding, which gives error when trying to read the UTF-8 encoding from TagUI.
Yes, have upgraded to v1.4. Still the same - shows the 3 lines and stops forever
Reply 1/2 - for the downloading hangs issue can you try below (need to use your username)
Then see if it still downloading / hang after 10 minutes -
# if using Python 2
import urllib; urllib.urlretrieve('https://github.com/tebelorg/Tump/releases/download/v1.0.0/TagUI_Windows.zip', 'C:\Users\user\AppData\Roaming/TagUI_Windows.zip')
# if using Python 3
import urllib.request; urllib.request.urlretrieve(urllib.urlretrieve('https://github.com/tebelorg/Tump/releases/download/v1.0.0/TagUI_Windows.zip', 'C:\Users\user\AppData\Roaming/TagUI_Windows.zip')
If it completes, then check that the zip file below is there, and run below (your username)
import tagui as t
t.unzip('C:\Users\user\AppData\Roaming/TagUI_Windows.zip', 'C:\Users\user\AppData\Roaming')
The above debugging steps will find out where the hang happens and hopefully why.
Reply 2/2 - for the fatal access is denied error, first create a tagui_python file with just 1 line
live
Then, launch Python and type the following to see if the error happens or works
import os
os.system('C:\Users\username\AppData\Roaming/tagui/src/tagui tagui_python chrome')
The above tries to isolate further by running the individual Python statement that triggered the error to check for clues why the error is showing when run from t.init() but works when you type manually from command prompt.
Appreciate your patience!! This is hard to debug for me because it is not replicable on the Windows 10 laptop I borrowed. But I'm definitely very keen to figure out what could be going wrong here.
# if using Python 3 import urllib.request; urllib.request.urlretrieve(urllib.urlretrieve('https://github.com/tebelorg/Tump/releases/download/v1.0.0/TagUI_Windows.zip', 'C:\Users\user\AppData\Roaming/TagUI_Windows.zip')
Run the above
import urllib.request; urllib.request.urlretrieve(urllib.urlretrieve('https://github.com/tebelorg/Tump/releases/download/v1.0.0/TagUI_Windows.zip', 'C:\Users\user\AppData\Roaming\TagUI_Windows.zip'))
Get the following error message:
File "test.py", line 1
import urllib.request; urllib.request.urlretrieve(urllib.urlretrieve('https://github.com/tebelorg/Tump/releases/download/v1.0.0/TagUI_Windows.zip', 'C:\Users\user\AppData\Roaming\TagUI_Windows.zip'))
^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
Did some googling. The above error is due to the backslash.
So change to the following:
import urllib.request; urllib.request.urlretrieve(urllib.urlretrieve('https://github.com/tebelorg/Tump/releases/download/v1.0.0/TagUI_Windows.zip', 'C:/Users/user/AppData/Roaming/TagUI_Windows.zip'))
Error message:
Traceback (most recent call last):
File "test31.py", line 1, in <module>
import urllib.request; urllib.request.urlretrieve(urllib.urlretrieve('https://github.com/tebelorg/Tump/releases/download/v1.0.0/TagUI_Windows.zip', 'C:/Users/user/AppData/Roaming/TagUI_Windows.zip'))
AttributeError: module 'urllib' has no attribute 'urlretrieve'
Using the following:
import urllib.request; urllib.request.urlretrieve(urllib.urlretrieve('https://github.com/tebelorg/Tump/releases/download/v1.0.0/TagUI_Windows.zip', r'C:\Users\user\AppData\Roaming\TagUI_Windows.zip'))
Same error message:
Traceback (most recent call last):
File "test33.py", line 1, in <module>
import urllib.request; urllib.request.urlretrieve(urllib.urlretrieve('https://github.com/tebelorg/Tump/releases/download/v1.0.0/TagUI_Windows.zip', 'C:\\Users\\user\\AppData\\Roaming\\TagUI_Windows.zip'))
AttributeError: module 'urllib' has no attribute 'urlretrieve'
Reply 2/2 - for the fatal access is denied error, first create a tagui_python file with just 1 line
live
Then, launch Python and type the following to see if the error happens or works
import os os.system('C:\Users\username\AppData\Roaming/tagui/src/tagui tagui_python chrome')
Running the above give me the following error message:
Fatal: Access is denied; did you install phantomjs?
Hi CK, I'm sorry I missed out the double backslash \\ in my example above. Don't have a Windows laptop, trying to trace mentally from the code the response from os.environ['APPDATA']
.
It looks like you are using Python 3, to make sure Python 3 is launched instead of Python 2, type python3 from command prompt (it should should Python version). After that -
# if using Python 3
import urllib.request; urllib.request.urlretrieve('https://github.com/tebelorg/Tump/releases/download/v1.0.0/TagUI_Windows.zip', 'C:\\Users\\user\\AppData\\Roaming/TagUI_Windows.zip')
If it completes, then check that the zip file below is there, and run below (your username)
import tagui as t
t.unzip('C:\\Users\\user\\AppData\\Roaming/TagUI_Windows.zip', 'C:\\Users\\user\\AppData\\Roaming')
Above mix of \\ and / is intentional to mash the retrieved path and the filename.
UPDATED - typo above when copy and pasting for the url retrieve() parameters
For the runtime fatal error, after trying to resolve the download error then try again. I can't think of why the download fails and can't replicate on a Windows 10 laptop I borrowed previously.
A remote possibility may be the network access? I've encountered situations where the network in institutions blocks certain URLs from being accessed. Maybe the redirect programmatically fails.
In the meantime, keeping issue open for clues from other Windows users who may have this problem.
Solution found when you drop by my place just now. Firewall / virus scanner issue!
No wonder can't replicate on the Windows laptop I borrowed. After you exclude the 'C:\Users\user\AppData\Roaming\tagui\src\phantomjs' folder from the scanner, it works. The downloading may or may not be related to this firewall. Closing the issue for now, but do post here if you can replicate the download issue with firewall / scanner turned off!
I meet a similar issue with win10 1903
import tagui as t
t.init()
t.url('https://www.google.com')
t.type('//*[@name="q"]', 'decentralization[enter]')
print(t.read('resultStats'))
t.snap('page', 'results.png')
t.close()
when i install c++ dependency by install flow
phantomjs://code/bootstrap.js:113 in __die
[TAGUI][ERROR] - use init() before using url()
[TAGUI][ERROR] - use init() before using type()
[TAGUI][ERROR] - use init() before using read()
[TAGUI][ERROR] - use init() before using snap()
[TAGUI][ERROR] - use init() before using close()
Hi @zengzhengrong can you tell me how you install the package, is it pip install tagui
?
Can you run following script to tell me where TagUI has been installed? I googled and found that this error could be the folder of installation has a space in the folder name.
import os
print(os.environ['APPDATA'] + '/' + 'tagui' + '/' + 'src' + '/' + 'tagui')
After you find the folder, can you try go to the directory tagui\src
in your command prompt, after that run tagui samples\1_yahoo
to see if there are other useful error messages on screen?
Hi, @kensoh I was looking to use Rpa for Python but I'm facing the same issue.
The following code:
import tagui as t
t.init()
t.url('https://www.google.com')
t.type('//*[@name="q"]', 'decentralization[enter]')
print(t.read('resultStats'))
t.snap('page', 'results.png')
t.close()
returns:
[RPA][INFO] - to use RPA for Python on Windows, avoid space in folder path name
[RPA][ERROR] - use init() before using url()
[RPA][ERROR] - use init() before using type()
[RPA][ERROR] - use init() before using read()
[RPA][ERROR] - use init() before using snap() [RPA][ERROR] - use init() before using close()
I already did the above steps of looking for "tagui samples\1_yahoo" (it worked fine and returned no error) and running with the Firewall/virus scanner disabled. I will keep looking for a solution and try to help in any way possible.
Update If the path has some spaces in it the error will appear. I don't know if this is some kind of bug, or expected.
Hi @Lmac99 yes this is expected behaviour, and will show above error message [RPA][INFO] - to use RPA for Python on Windows, avoid space in folder path name
. If the folder user uses to run the package has a space it will have this error, have to choose another folder without space.
However, if a username for Windows has space, then no matter what folder there will be a space on the full path to the Desktop folder. In that case, a workaround is having a dummy user account name with no space.
Unfortunately, this is a limitation (space in file path name) of the CasperJS / PhantomJS engine used by the package which I could not override this limitation from my side.
Hi @kensoh sorry by doing a dummy question, I've already run thes sugested code to detect the cause of the error "[RPA][INFO] - to use RPA for Python on Windows, avoid space in folder path name", an it returned: C:\Users\josue\AppData\Roaming/tagui/src/tagui So no visible spaces. Do You have any ideas, how to avoid this error?
Tried another sample code on windows 10:
Error message
Should have phantomjs installed. I'm running TagUI on this machine.