thorwhalen / oa

Python interface to OpenAi
Apache License 2.0
0 stars 0 forks source link

import oa and got error "re.error: incomplete escape \U at position 2" #6

Open StefanoGITA opened 8 months ago

StefanoGITA commented 8 months ago

Hi I'm trying to use the oa lib with python 3.9 on windows10 I generated a clean project: python -m venv _venv

And I activated it: _venv\Scripts\activate.bat

I've checked the status of the lib:

(_venv) C:\Users\Amministratore\PycharmProjects\dev>pip show oa
Name: oa
Version: 0.1.0
Summary: Python interface to OpenAi
Home-page: https://github.com/thorwhalen/oa
Author: Thor Whalen
Author-email:
License: apache-2.0
Location: c:\users\amministratore\pycharmprojects\dev\_venv\lib\site-packages
Requires: config2py, dol, graze, i2, jsonref, openai
Required-by:

But when i open a python shell and make import oa, I got this error:

>>> import oa
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Amministratore\PycharmProjects\dev\_venv\lib\site-packages\oa\__init__.py", line 3, in <module>
    from oa.util import openai, grazed, djoin, app_data_dir
  File "C:\Users\Amministratore\PycharmProjects\dev\_venv\lib\site-packages\oa\util.py", line 5, in <module>
    from config2py.tools import get_configs_local_store
  File "C:\Users\Amministratore\PycharmProjects\dev\_venv\lib\site-packages\config2py\__init__.py", line 4, in <module>
    from config2py.tools import (
  File "C:\Users\Amministratore\PycharmProjects\dev\_venv\lib\site-packages\config2py\tools.py", line 95, in <module>
    config_getter = simple_config_getter()
  File "C:\Users\Amministratore\PycharmProjects\dev\_venv\lib\site-packages\config2py\tools.py", line 78, in simple_config_getter
    central_configs = config_store_factory(configs_src)
  File "C:\Users\Amministratore\PycharmProjects\dev\_venv\lib\site-packages\config2py\tools.py", line 31, in get_configs_local_store
    return TextFiles(config_src)
  File "C:\Users\Amministratore\PycharmProjects\dev\_venv\lib\site-packages\dol\paths.py", line 745, in __init__
    Store.__init__(self, store=store_cls(*args, **kwargs))
  File "C:\Users\Amministratore\PycharmProjects\dev\_venv\lib\site-packages\dol\filesys.py", line 216, in __init__
    self._key_pattern = mk_pattern_from_template_and_format_dict(
  File "C:\Users\Amministratore\PycharmProjects\dev\_venv\lib\site-packages\dol\naming.py", line 325, in mk_pattern_from_template_and_format_dict
    return re.compile(template_to_pattern(named_capture_patterns, template))
  File "C:\Program Files\Python39\lib\re.py", line 252, in compile
    return _compile(pattern, flags)
  File "C:\Program Files\Python39\lib\re.py", line 304, in _compile
    p = sre_compile.compile(pattern, flags)
  File "C:\Program Files\Python39\lib\sre_compile.py", line 788, in compile
    p = sre_parse.parse(p, flags)
  File "C:\Program Files\Python39\lib\sre_parse.py", line 955, in parse
    p = _parse_sub(source, state, flags & SRE_FLAG_VERBOSE, 0)
  File "C:\Program Files\Python39\lib\sre_parse.py", line 444, in _parse_sub
    itemsappend(_parse(source, state, verbose, nested + 1,
  File "C:\Program Files\Python39\lib\sre_parse.py", line 526, in _parse
    code = _escape(source, this, state)
  File "C:\Program Files\Python39\lib\sre_parse.py", line 382, in _escape
    raise source.error("incomplete escape %s" % escape, len(escape))
re.error: incomplete escape \U at position 2

Why?

thorwhalen commented 8 months ago

Hi @StefanoGITA. I just looked into it for the last 45mn, but couldn't reproduce on my side -- probably due to the fact that I'm on a Mac machine, and what you're having is a windows-specific issue.

Test run fine both on Mac (my local) and linux (remote CI), but I don't have access to a windows machine to dig into it further. If you're interested, you can look into it yourself, and I can assist you. We could even do this over a screen-share session.

What I can tell you is it comes from config2py trying to make a "local file store" (using dol.TextFiles(config_src), and this errs when trying to make a regular expression using the string that dol.naming.template_to_pattern makes. But can't see what that string is from the traceback.

I'm the main author of config2py and dol, so I should be able to help.