ufal / udpipe

UDPipe: Trainable pipeline for tokenizing, tagging, lemmatizing and parsing Universal Treebanks and other CoNLL-U files
Mozilla Public License 2.0
359 stars 75 forks source link

RHEL8 #163

Closed KrisAbr19 closed 1 year ago

KrisAbr19 commented 1 year ago

Hello! Can I install udpipe on RHEL8? When I try, I get error "Unsupported platform el8".

foxik commented 1 year ago

Hi,

I assume you are compiling it manually. Could you try running make PLATFORM=linux? Maybe the environment variable PLATFORM is set.

KrisAbr19 commented 1 year ago

Thank you, it helped me! But now, when i try to build and install, I get this message

Sorry! Txt2tags aborted by an unknown error.
Please send the following Error Traceback to the author (verde@aurelio.net):
Traceback (most recent call last):
  File "/tmp/udpipe-1.2.0/doc/t2t_docsys/txt2tags.py", line 6114, in <module>
    exec_command_line()
  File "/tmp/udpipe-1.2.0/doc/t2t_docsys/txt2tags.py", line 6108, in exec_command_line
    convert_this_files(infiles_config)
  File "/tmp/udpipe-1.2.0/doc/t2t_docsys/txt2tags.py", line 4975, in convert_this_files
    for myconf,doc in configs:             # multifile support
  File "/tmp/udpipe-1.2.0/doc/t2t_docsys/txt2tags.py", line 4928, in process_source_file
    source = SourceDocument(file_)
  File "/tmp/udpipe-1.2.0/doc/t2t_docsys/txt2tags.py", line 2557, in init
    self.scan_file(filename)
  File "/tmp/udpipe-1.2.0/doc/t2t_docsys/txt2tags.py", line 2594, in scan_file
    self.scan(buf)
  File "/tmp/udpipe-1.2.0/doc/t2t_docsys/txt2tags.py", line 2606, in scan
    rgx = getRegexes()
  File "/tmp/udpipe-1.2.0/doc/t2t_docsys/txt2tags.py", line 2124, in getRegexes
    bank['linkmark'] = re.compile(
  File "/usr/lib64/python3.9/re.py", line 252, in compile
    return _compile(pattern, flags)
  File "/usr/lib64/python3.9/re.py", line 304, in _compile
    p = sre_compile.compile(pattern, flags)
  File "/usr/lib64/python3.9/sre_compile.py", line 764, in compile
    p = sre_parse.parse(p, flags)
  File "/usr/lib64/python3.9/sre_parse.py", line 958, in parse
    p.state.flags = fix_flags(str, p.state.flags)
  File "/usr/lib64/python3.9/sre_parse.py", line 925, in fix_flags
    raise ValueError("cannot use LOCALE flag with a str pattern")
ValueError: cannot use LOCALE flag with a str pattern
make: *** [Makefile:27: manual_bindings_api.txt] Error 1
tail: cannot open '../../doc/manual_bindings_api.txt' for reading: No such file or directory
./README.sh: line 59: warning: here-document at line 42 delimited by end-of-file (wanted `EOF')

But process goes on and at the end I see ufal.udpipe in my environment. But when i try to import ufal.udpipe, I get error

 from ufal.udpipe import Model
File "/opt/app-root/lib64/python3.9/site-packages/ufal/udpipe.py", line 13, in <module>
    from .ufal_udpipe import *
 ModuleNotFoundError: No module named 'ufal.ufal_udpipe'

I used this import before with python3.6. but now I am trying to move to python3.9 and I don't understand, what i am doing wrong. Can You help me again, please?

foxik commented 1 year ago

What version are you building? Is it the current master of stable or something else? The module .ufal_udpipe indicates you are building the current stable -- if that is the case, try building master, that should help.

If you want the Python building, start by running gen.sh 1.2.0.4 in releases/pypi (and never mind the error, the documentation system is so old it uses Python 2.7, but it happens at the end of the package generation process, so it is fine), and then you should be able to just python3 system.py build.

KrisAbr19 commented 1 year ago

I tried release package and master brunch. Both were built completely. I use these commands: "gen.sh 1.2.0.4", then "python3 setup.py", then "python3 setup.py install". There are no file "system.py" I tried gen.sh 1.2.0.4 and 1.2.0.3. It doesn't matter. I see the same behavior. I see that I installed udpipe, i see ufal.udpipe in my env, when I do "pip list". But when I try to import "from ufal.udpipe import Model", I see the error

File "/opt/app-root/lib64/python3.9/site-packages/ufal/udpipe.py", line 13, in <module>
    from .ufal_udpipe import *
 ModuleNotFoundError: No module named 'ufal.ufal_udpipe'

May be You have any other solutions to this problem?

foxik commented 1 year ago

Hi,

the gen.sh 1.2.0.4 should create a subdirectory ufal.udpipe with the created package -- there you need to run the python3 setup.py build, or even pip3 install .

KrisAbr19 commented 1 year ago

Oh, sorry. When I wrote you, missed the word 'build'. I meant that I did python3 setup.py build. It didn't help me. I will try pip3 install .

KrisAbr19 commented 1 year ago

Hello! Сongratulations on the holidays! I tried to install udpipe again, and i don't get the error No module named 'ufal.ufal_udpipe' any longer. Thank you! But when I try to use Model.load_bin (It was used before), I get AttributeError: type object 'ufal.udpipe.Model' has no attribute 'load_bin' How can I change it? Is it possible?

foxik commented 1 year ago

The load_bin is not really a method of ufal.udpipe.Model -- I am not sure how it could worked before. The Model class offers the following C++ methods converted to Python (taken from https://ufal.mff.cuni.cz/udpipe/1/api-reference#bindings_main_classes):

class Model {
 public:
  static Model* load(const char* fname);

  virtual InputFormat* newTokenizer(const string& options) const;
  virtual bool tag(Sentence& s, const string& options, ProcessingError* error = nullptr) const;
  virtual bool parse(Sentence& s, const string& options, ProcessingError* error) const;

  static const string DEFAULT;
  static const string TOKENIZER_PRESEGMENTED;
};

So just load should be fine; you can look at the examples at https://github.com/ufal/udpipe/tree/master/bindings/python/examples.

KrisAbr19 commented 1 year ago

Hi! I tried to use load instead of load_bin. But I faced the error TypeError: in method 'new_Pipeline', argument 2 of type 'std::string const &' it happened because somebody used Pipeline(self.model, 'conllu'.encode(), Pipelune.NONE, Pipeline.DEFAULT, 'conllu'.encode()) before Actually I think the problem is connected with the model or loading this model. May I be right?

foxik commented 1 year ago

Hi,

the Pipeline needs a string, but you passed it bytes instead; so just remove the .encode() and you should be fine. (Maybe you used the package previously on Python 2 and now started to use Python 3? It was possible to process bytes on Python 2.)

foxik commented 1 year ago

The ufal.udpipe package 1.2.0.3 now contains binary wheels for Python 3.6-3.11, for Linux, Windows, macOS platforms, and also manual compilation works, co I am closing the issue.