Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxWarning: "invalid escape sequence '\.'" coming from pypandoc dependency #1722

Open
Quidge opened this issue Sep 25, 2024 · 5 comments
Open
Labels
question Further information is requested

Comments

@Quidge
Copy link

Quidge commented Sep 25, 2024

Issue

$ aider
/opt/homebrew/Cellar/aider/0.57.1/libexec/lib/python3.12/site-packages/pypandoc/pandoc_download.py:61: SyntaxWarning: invalid escape sequence '\.'
  regex = re.compile(r"/jgm/pandoc/releases/download/.*(?:"+processor_architecture+"|x86|mac).*\.(?:msi|deb|pkg)")
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Aider v0.57.1
Main model: claude-3-5-sonnet-20240620 with diff edit format, prompt cache, infinite output
Weak model: claude-3-haiku-20240307
Git repo: .git with 33 files
Repo-map: using 1024 tokens, files refresh
Use /help <question> for help, run "aider --help" to see cmd line args
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
CONVENTIONS.md
>

This appears to be an issue on Python 3.12 for the pypandoc library which aider uses. There's a patch in pypandoc where they fix this but it isn't released yet. aider's requirements.txt is currently set to use pypandoc==1.13 which still has the syntax warning. I think Aider will need to do something like pypandoc>=1.14 once pypandoc releases to get rid of that warning.

Version and model info

Aider v0.57.1 (installed with playright as well)
Python 3.12

@Quidge Quidge changed the title SyntaxWarning: "invalid escape sequence '\.'" coming from bug in pypandoc SyntaxWarning: "invalid escape sequence '\.'" coming from pypandoc dependency Sep 25, 2024
@fry69
Copy link
Contributor

fry69 commented Sep 25, 2024

Thank you for filing this issue.

At first glance this looks like you installed aider in an environment with many other Python modules and aider's dependencies got mixed up. Can you please try to install aider in a separate Python environment? Either with venv or pipx?

This document may be helpful -> https://aider.chat/docs/troubleshooting/imports.html

@fry69 fry69 added the question Further information is requested label Sep 25, 2024
@savchenko
Copy link

savchenko commented Oct 4, 2024

I have noticed the same error in a different project, completely unrelated to aider. The issue is in the pypandoc.

Ref. https://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg1994136.html

@ngharrington
Copy link

The introduction of pydub also seems to have introduced more of these warnings

aider-sandbox$ uv venv --python 3.12 --no-project --seed venv312
aider-sandbox$ uv python find
/home/neal/workspace/aider-sandbox/venv312/bin/python3
neal@neal-xps:aider-sandbox$ uv pip install --no-cache aider-chat 
Resolved 84 packages in 1.41s
   Built pyperclip==1.9.0
Prepared 84 packages in 4.02s
Installed 84 packages in 48ms
 + aider-chat==0.59.1
 + aiohappyeyeballs==2.4.0
 + aiohttp==3.10.5
 + aiosignal==1.3.1
 + annotated-types==0.7.0
 + anyio==4.6.0
 + attrs==24.2.0
 + backoff==2.2.1
 + beautifulsoup4==4.12.3
 + certifi==2024.8.30
 + cffi==1.17.1
 + charset-normalizer==3.3.2
 + click==8.1.7
 + configargparse==1.7
 + diff-match-patch==20230430
 + diskcache==5.6.3
 + distro==1.9.0
 + filelock==3.16.1
 + flake8==7.1.1
 + frozenlist==1.4.1
 + fsspec==2024.9.0
 + gitdb==4.0.11
 + gitpython==3.1.43
 + grep-ast==0.3.3
 + h11==0.14.0
 + httpcore==1.0.5
 + httpx==0.27.2
 + huggingface-hub==0.25.0
 + idna==3.10
 + importlib-metadata==7.2.1
 + importlib-resources==6.4.5
 + jinja2==3.1.4
 + jiter==0.5.0
 + json5==0.9.25
 + jsonschema==4.23.0
 + jsonschema-specifications==2023.12.1
 + litellm==1.47.0
 + markdown-it-py==3.0.0
 + markupsafe==2.1.5
 + mccabe==0.7.0
 + mdurl==0.1.2
 + multidict==6.1.0
 + networkx==3.2.1
 + numpy==1.26.4
 + openai==1.47.0
 + packaging==24.1
 + pathspec==0.12.1
 + pexpect==4.9.0
 + pillow==10.4.0
 + prompt-toolkit==3.0.47
 + psutil==6.0.0
 + ptyprocess==0.7.0
 + pycodestyle==2.12.1
 + pycparser==2.22
 + pydantic==2.9.2
 + pydantic-core==2.23.4
 + pydub==0.25.1
 + pyflakes==3.2.0
 + pygments==2.18.0
 + pypandoc==1.13
 + pyperclip==1.9.0
 + python-dotenv==1.0.1
 + pyyaml==6.0.2
 + referencing==0.35.1
 + regex==2024.9.11
 + requests==2.32.3
 + rich==13.8.1
 + rpds-py==0.20.0
 + scipy==1.13.1
 + smmap==5.0.1
 + sniffio==1.3.1
 + sounddevice==0.5.0
 + soundfile==0.12.1
 + soupsieve==2.6
 + tiktoken==0.7.0
 + tokenizers==0.19.1
 + tqdm==4.66.5
 + tree-sitter==0.21.3
 + tree-sitter-languages==1.10.2
 + typing-extensions==4.12.2
 + urllib3==2.2.3
 + wcwidth==0.2.13
 + yarl==1.11.1
 + zipp==3.20.2

aider-sandbox$ aider
/home/neal/workspace/aider-sandbox/venv312/lib/python3.12/site-packages/pydub/utils.py:300: SyntaxWarning: invalid escape sequence '\('
  m = re.match('([su]([0-9]{1,2})p?) \(([0-9]{1,2}) bit\)$', token)
/home/neal/workspace/aider-sandbox/venv312/lib/python3.12/site-packages/pydub/utils.py:301: SyntaxWarning: invalid escape sequence '\('
  m2 = re.match('([su]([0-9]{1,2})p?)( \(default\))?$', token)
/home/neal/workspace/aider-sandbox/venv312/lib/python3.12/site-packages/pydub/utils.py:310: SyntaxWarning: invalid escape sequence '\('
  elif re.match('(flt)p?( \(default\))?$', token):
/home/neal/workspace/aider-sandbox/venv312/lib/python3.12/site-packages/pydub/utils.py:314: SyntaxWarning: invalid escape sequence '\('
  elif re.match('(dbl)p?( \(default\))?$', token):
/home/neal/workspace/aider-sandbox/venv312/lib/python3.12/site-packages/pypandoc/pandoc_download.py:61: SyntaxWarning: invalid escape sequence '\.'
  regex = re.compile(r"/jgm/pandoc/releases/download/.*(?:"+processor_architecture+"|x86|mac).*\.(?:msi|deb|pkg)")

Notably when you run for the second time using the same python env, the pycache may cause the warnings to be suppressed. You can get around that by running the following after creating a fresh environment to shutoff bytecode.

python -B $(which aider)

Notably, the master branch of the pydub repo actually works fine

Install aider-chat in a fresh environment then update pydub:

neal@neal-xps:aider-sandbox$ uv venv --python 3.12 --no-project --seed venv312
Using CPython 3.12.6
Creating virtual environment with seed packages at: venv312
 + pip==24.2
Activate with: source venv312/bin/activate
neal@neal-xps:aider-sandbox$ source venv312/bin/activate
(venv312) neal@neal-xps:aider-sandbox$ uv pip install aider-chat
...


neal@neal-xps:aider-sandbox$ uv pip install --upgrade --no-cache git+https://github.com/ngharrington/pydub.git
 Updated https://github.com/ngharrington/pydub.git (996cec4)
Resolved 1 package in 2.42s
   Built pydub @ git+https://github.com/ngharrington/pydub.git@996cec42e9621701edb83354232b2c0ca0121560
Prepared 1 package in 620ms
Uninstalled 1 package in 0.33ms
Installed 1 package in 0.67ms
 - pydub==0.25.1
 + pydub==0.25.1 (from git+https://github.com/ngharrington/pydub.git@996cec42e9621701edb83354232b2c0ca0121560)
(venv312) neal@neal-xps:aider-sandbox$ python -B $(which aider) 
/home/neal/workspace/aider-sandbox/venv312/lib/python3.12/site-packages/pypandoc/pandoc_download.py:61: SyntaxWarning: invalid escape sequence '\.'
  regex = re.compile(r"/jgm/pandoc/releases/download/.*(?:"+processor_architecture+"|x86|mac).*\.(?:msi|deb|pkg)")
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Aider v0.59.1
Main model: gpt-4o-2024-08-06 with diff edit format
Weak model: gpt-4o-mini
Git repo: .git with 2 files
Repo-map: using 1024 tokens, auto refresh
VSCode terminal detected, pretty output has been disabled.
Use /help <question> for help, run "aider --help" to see cmd line args
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
>  

As you see only the pandoc warning remains in this case.

@ngharrington
Copy link

I've added an issue here

jiaaro/pydub#814

@fry69
Copy link
Contributor

fry69 commented Oct 8, 2024

If possible, do not install or update other Python modules in the same Python environment.

Please use venv or pipx to isolate aider as much as possible.

See also -> https://aider.chat/docs/troubleshooting/imports.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants