Pyrouge installation test results in "FAILED (errors=10)" - python-2.7

In a previous question I posted in Stackoverflow, I asked about Pyrouge installation. After receiving the answer, I applied it. From the pypi installation steps, I did
pip install pyrouge
Then (here is where I substituted the pypi original step 2,
pyrouge_set_rouge_path.py /absolute/path/to/ROUGE-1.5.5/directory
with the answer I received from stackoverflow):
set pyrouge_set_rouge_path=C:\rouge
Then, I ran the following command to make sure it installed correctly:
python -m pyrouge.test
I was supposed to receive the following output:
Ran 10 tests in 3.753s
OK
But instead got the following output:
Ran 10 tests in 0.034s
FAILED (erros=10)
Above that I received an Error for every test attempt.
Error1: test_config_file (pyrouge.tests.Rouge155_test.PyrougeTest)
Error2: test_convert_summaries (pyrouge.tests.Rouge155_test.PyrougeTest)
Error3: test_evaluation (pyrouge.tests.Rouge155_test.PyrougeTest)
Error4: test_options (pyrouge.tests.Rouge155_test.PyrougeTest)
Error5: test_paths (pyrouge.tests.Rouge155_test.PyrougeTest)
Error6: test_rouge_for_plain_text (pyrouge.tests.Rouge155_test.PyrougeTest)
Error7: test_text_conversion (pyrouge.tests.Rouge155_test.PyrougeTest)
Error8: test_write_config (pyrouge.tests.Rouge155_test.PyrougeTest)
Error9: test_wrong_model_pattern (pyrouge.tests.Rouge155_test.PyrougeTest)
Error10: test_wrong_system_pattern (pyrouge.tests.Rouge155_test.PyrougeTest)
The following are the detailed first and last errors:
First Error:
"""
EEEEEEEEEE
======================================================================
ERROR: test_config_file (pyrouge.tests.Rouge155_test.PyrougeTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\pyrouge\tests\Rouge155_test.py", line 138,
in test_config_file
rouge = Rouge155()
File "C:\Python27\lib\site-packages\pyrouge\Rouge155.py", line 88, in __init__
self.__set_rouge_dir(rouge_dir)
File "C:\Python27\lib\site-packages\pyrouge\Rouge155.py", line 402, in __set_r
ouge_dir
self._home_dir = self.__get_rouge_home_dir_from_settings()
File "C:\Python27\lib\site-packages\pyrouge\Rouge155.py", line 416, in __get_r
ouge_home_dir_from_settings
with open(self._settings_file) as f:
IOError: [Errno 2] No such file or directory: u'C:\\Users\\IQ\\AppData\\Roaming\
\pyrouge\\settings.ini'
"""
Last Error:
"""
ERROR: test_wrong_system_pattern (pyrouge.tests.Rouge155_test.PyrougeTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\pyrouge\tests\Rouge155_test.py", line 59,
in test_wrong_system_pattern
rouge = Rouge155()
File "C:\Python27\lib\site-packages\pyrouge\Rouge155.py", line 88, in __init__
self.__set_rouge_dir(rouge_dir)
File "C:\Python27\lib\site-packages\pyrouge\Rouge155.py", line 402, in __set_r
ouge_dir
self._home_dir = self.__get_rouge_home_dir_from_settings()
File "C:\Python27\lib\site-packages\pyrouge\Rouge155.py", line 416, in __get_r
ouge_home_dir_from_settings
with open(self._settings_file) as f:
IOError: [Errno 2] No such file or directory: u'C:\\Users\\IQ\\AppData\\Roaming\
\pyrouge\\settings.ini'
"""
I have opened the directory: C:\Users\IQ\AppData\Roaming\pyrouge\, but it was empty.
I would like to know what it is that is wrong, and how to fix it.
Thank you.

Starting with the answer to your initial question:
"Assuming a working ROUGE-1.5.5. installation" does not correspond to your pyrouge installation. It references to the following. (Maybe you got that right immediately, I did not)
https://github.com/andersjo/pyrouge/tree/master/tools/ROUGE-1.5.5
pyrouge_set_rouge_path is a script, not a variable you have to set.
The script is located at Python_PATH\Scripts.
Hence try something like:
python Python_PATH\Scripts\pyrouge_set_rouge_path C:\rouge
Alternatively you can create a file settings.ini at the corresponding location with this content:
[pyrouge settings]
home_dir = C:\rouge
Where C:\rouge should be the location of the file ROUGE-1.5.5.pl

You should first install ROUGE-1.5.5 by following this tutorial. Only the two commands to install and no configuration is needed. Keep in mind to generate the wordnet bd file. by running
./WordNet-2.0-Exceptions/buildExeptionDB.pl ./WordNet-2.0-Exceptions ./smart_common_words.txt ./WordNet-2.0.exc.db
Under the data directory.
Then install the pyrouge from source. Remember to comment out the print lines which will trigger errors.
Then all will just goes fine.

Related

KivyMD on a Mac: running kitchen_sink raises an error in kivytoast.py

On a Macbook Pro (Catalina), Python 3.8, interested in developing Android apps in Kivy using KivyMD. I took the following steps to install KivyMD:
create the virtual environment (virtmd), then activated it (source /virtmd/bin/activate)
in this virtual environment, installed the following via pip: Pillow, kivy
git-cloned KivyMD as per the link suggested on the GitHub page
Ran the pip install .
All this ran seamlessly with no hitch or errors. pip freeze shows the following installed items:
certifi==2021.5.30
charset-normalizer==2.0.4
docutils==0.17.1
idna==3.2
Kivy==2.0.0
Kivy-Garden==0.1.4
kivymd # file:///Users/robinhahn/PyProg/kvKivyMD/KivyMD
Pillow==8.3.1
Pygments==2.9.0
requests==2.26.0
urllib3==1.26.6
I was following a Codemy video tutorial and noticed that the presenter's pip freeze showed 4 more entries:
chardet==4.0.0
kivy-deps.angle==0.3.0
kivy-deps.glew==0.3.0
kivy-deps.sdl2==0.3.1
Cd'ed into the /demos/kitchen_sink folder, ran 'python3 main.py' which failed, raising this error, the last few lines of the traceback appear to focus on a file called kivytoast.py:
File "main.py", line 144, in <module>
KitchenSinkApp().run()
File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivy/app.py", line 949, in run
self._run_prepare()
File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivy/app.py", line 944, in _run_prepare
self.dispatch('on_start')
File "_event.pyx", line 709, in kivy._event.EventDispatcher.dispatch
File "main.py", line 65, in on_start
Builder.load_file(
File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivy/lang/builder.py", line 306, in load_file
return self.load_string(data, **kwargs)
File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivy/lang/builder.py", line 373, in load_string
parser = Parser(content=string, filename=fn)
File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivy/lang/parser.py", line 402, in __init__
self.parse(content)
File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivy/lang/parser.py", line 508, in parse
self.execute_directives()
File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivy/lang/parser.py", line 472, in execute_directives
mod = __import__(package)
File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivymd/toast/__init__.py", line 11, in <module>
from .kivytoast import toast
File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivymd/toast/kivytoast/__init__.py", line 3, in <module>
from .kivytoast import toast
File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivymd/toast/kivytoast/kivytoast.py", line 72, in <module>
class Toast(BaseDialog):
File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivymd/toast/kivytoast/kivytoast.py", line 90, in Toast
self, instance_label: Label, texture_size: list[int, int]
TypeError: 'type' object is not subscriptable
Still somewhat of a novice, and not really sure how to proceed from here.
ETA: I brought this up in VSCode and the last word:
list[int, int]
was squiggly-underlined, indicating it's the offending item. I have no idea what 'type' object is not subscriptable means or how to fix it.
Thanks to all who read and ponder this problem.
I'm on the same course right now and just got to that file with the same issue. I followed the path to the 'kivytoast.py' file and changed the following line (line 89):
def label_check_texture_size(self, instance_label: Label, texture_size: list([int, int])) -> NoReturn:
The kivymd devs seemed to have made a mistake and did list[int, int] instead of list([int,int]). You could also just leave it as [int,int] and it would work the same since it is alread in list format. Goodluck with the rest of your course!

Syntax error while using python trace

I'm running a script of which I need to see which statements of whichever files it touches. So, I'm using Python's trace.
This command runs perfectly on the linux terminal: /x/eng/bbsvl/users/nikhilh/C4563855_4563855_1710110159/test/nate/bin/ntest -noconsole NATE_HOSTS=/u/smoke/presub/tharnhosts/temp_remove/nikhilh NODES=p8020-5 /x/eng/bbsvl/users/nikhilh/C4563855_4563855_1710110159/test/lib/pynacl/ontap/test/cluster_ha.thpy
In another cluster_ha_original.py script I've this code:
import trace
cmd_to_run = '/x/eng/bbsvl/users/nikhilh/C4563855_4563855_1710110159/test/nate/bin/ntest -noconsole NATE_HOSTS=/u/smoke/presub/tharnhosts/temp_remove/nikhilh NODES=p8020-5 /x/eng/bbsvl/users/nikhilh/C4563855_4563855_1710110159/test/lib/pynacl/ontap/test/cluster_ha.thpy'
tracer = trace.Trace(count=False, trace=True)
tracer.run(cmd_to_run)
r = tracer.results()
r.write_results(summary=True)
The above cluster_ha_original.py file should have given me the complete trace which includes the files, functions and statements which cluster_ha.thpy internally calls but I'm getting a syntax error:
[nikhilh#cycl02 test]$ python3 cluster_ha_original.py
--- modulename: trace, funcname: _unsettrace
trace.py(78): sys.settrace(None)
Traceback (most recent call last):
File "cluster_ha_original.py", line 6, in <module>
tracer.run(cmd_to_run)
File "/usr/software/lib/python3.2/trace.py", line 501, in run
self.runctx(cmd, dict, dict)
File "/usr/software/lib/python3.2/trace.py", line 509, in runctx
exec(cmd, globals, locals)
File "<string>", line 1
/x/eng/bbsvl/users/nikhilh/C4563855_4563855_1710110159/test/nate/bin/ntest -noconsole NATE_HOSTS=/u/smoke/presub/tharnhosts/temp_remove/nikhilh NODES=p8020-5 /x/eng/bbsvl/users/nikhilh/C4563855_4563855_1710110159/test/lib/pynacl/ontap/test/cluster_ha.thpy
^
SyntaxError: invalid syntax
Any ideas?

Invalid syntax from ypolk -l

I having a lot of trouble to install and config Django and Postgres so I can use them in eclipse.
I try to follow the instructions from this youtube video
but when I typed
ypolk -l
i got:
C:\Users\yaira\Documents\YASMIN\virtual_enviroments>yolk -l
Traceback (most recent call last):
File "C:\Users\yaira\AppData\Local\Programs\Python\Python36-32\Scripts\yolk-script.py", line 11, in <module>
load_entry_point('yolk==0.4.3', 'console_scripts', 'yolk')()
File "c:\users\yaira\appdata\local\programs\python\python36-32\lib\site-packages\pkg_resources\__init__.py", line 565, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "c:\users\yaira\appdata\local\programs\python\python36-32\lib\site-packages\pkg_resources\__init__.py", line 2631, in load_entry_point
return ep.load()
File "c:\users\yaira\appdata\local\programs\python\python36-32\lib\site-packages\pkg_resources\__init__.py", line 2291, in load
return self.resolve()
File "c:\users\yaira\appdata\local\programs\python\python36-32\lib\site-packages\pkg_resources\__init__.py", line 2297, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "c:\users\yaira\appdata\local\programs\python\python36-32\lib\site-packages\yolk\cli.py", line 262
print " %s %s (%s)" % (project_name, dist.version,
^
SyntaxError: invalid syntax
I have no idea what does it mean, and what to do do with those results.
It would appear as though yolk does not support Python 3 too well according to this bug report.
Their suggested solution is to try using yolk3k and uninstall yolk
Make sure you uninstall yolk before installing yolk3k so you can use the "yolk" commands in yolk3k

portia (scrapy/slybot) errors on windows

i installed portia and got it to work i annotated some websites (looks really good)
but when i try to run the spiders i get some errors and nothing gets crawled
im running python 2.7.6 on win 7
C:\Python27\Scripts>python portiacrawl C:\portia\slyd\data\projects\new_project
Traceback (most recent call last):
File "portiacrawl", line 7, in <module>
execfile(__file__)
File "C:\portia\slybot\bin\portiacrawl", line 56, in <module>
main()
File "C:\portia\slybot\bin\portiacrawl", line 54, in main
subprocess.call(command_spec)
File "C:\Python27\lib\subprocess.py", line 522, in call
return Popen(*popenargs, **kwargs).wait()
File "C:\Python27\lib\subprocess.py", line 709, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 957, in _execute_child
startupinfo)
WindowsError: [Error 2] O sistema nÒo conseguiu localizar o ficheiro especificado
I am troubleshooting portia on Windows 8.1 and encountered the same error, exactly.
Try running 'python portiacrawl' by itself to determine if there is a subsequent menu. You should be able to see Help info on 'portiacrawl'. I suspect that you need to name the [spider] & [options] as well as change the terminal directory to see the output from the crawler. I suggest trying the following but rename [spider] to actual name of your spider w/o brackets:
Enter into terminal: C:\portia\slyd\data\projects <------Change to proper directory in cmd
Make sure you are in the terminal directory "C:\portia\slyd\data\projects"
The Cmd propmpt should look like: C:\portia\slyd\data\projects> <----waiting for portia initiation.
Enter into terminal:
python portiacrawl C:\portia\slyd\data\projects\new_project [spider] -t csv -o test.csv; or,
python portiacrawl [spider] -t csv -o test.csv
Report back. I am curious as to the terminal response. Did it initiate portiacrawl & return "access is denied."

issue with subprocess.call

Python 2.7.3 with ubuntu:
Trying to run a program, (youtube-dl in this example) with subprocess.call with some arguments, I encounter the following issue. consider the following script:
try.py:
#!/usr/bin/python
from subprocess import call
url = "https://www.youtube.com/watch?v=8SbUC-UaAxE"
myArray = ['./youtube-dl {}'.format(url),'-x','--audio-format mp3']
#print the array before executing:
for item in myArray:
print item,
#execute:
call(myArray)
This script prints outputs:
oris#oris:~/Desktop/YouTube/backend$ ./try.py
./youtube-dl https://www.youtube.com/watch?v=8SbUC-UaAxE -x --audio-format mp3
Traceback (most recent call last):
File "./try.py", line 16, in <module>
call(myArray)
File "/usr/lib/python2.7/subprocess.py", line 493, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1259, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Strangly, On the first line of the output I see the script does output ./youtube-dl https://www.youtube.com/watch?v=8SbUC-UaAxE -x --audio-format mp3 This command runs perfectly from bash directly, but produces an OSError from python. I also thought maybe to try and supply the url as an argument like this:
myArray = ['./youtube-dl', url,'-x','--audio-format mp3']
but than youtube-dl has an error of incorrect usage:
oris#oris:~/Desktop/YouTube/backend$ ./try.py
Usage: youtube-dl [options] url [url...]
youtube-dl: error: no such option: --audio-format mp3
./youtube-dl https://www.youtube.com/watch?v=8SbUC-UaAxE -x --audio-format mp3
I've read youtube-dl source to see how it handles the supplied arguments with optparse. I don't see the url as an argument there, so I'm guessing i'm passing the arguments to subprocess.call incorrectly.
Side note: another thing I find odd is the fact the print here takes effect after the subprocess call, as opposed to their order on my script. Is something happening here asynchronously?
What am I missing here? Many thanks
--audio-format and mp3 should be passed as separated arguments:
myArray = ['./youtube-dl', url, '-x', '--audio-format', 'mp3']