Error on importing: "re.PatternError: global flags not at the start of the expression at position 24"
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 10.5k
- Forks
- 1.2k
- Avg merge
- 4m
- Merged PRs (30d)
- 1
Description
I'm running ollama 0.9.0 and ollama-python 0.5.1 on Python 3.13.3 on macOS Sequoia 15.5. I get this error when I try to import the module:
>>> from ollama import chat
Traceback (most recent call last):
File "<python-input-0>", line 1, in <module>
from ollama import chat
File "/Users/al/Scripts/.venv/lib/python3.13/site-packages/ollama/__init__.py", line 1, in <module>
from ollama._client import AsyncClient, Client
File "/Users/al/Scripts/.venv/lib/python3.13/site-packages/ollama/_client.py", line 42, in <module>
import httpx
File "/Users/al/Scripts/.venv/lib/python3.13/site-packages/httpx/__init__.py", line 15, in <module>
from ._main import main
File "/Users/al/Scripts/.venv/lib/python3.13/site-packages/httpx/_main.py", line 9, in <module>
import pygments.lexers
File "/Users/al/Scripts/.venv/lib/python3.13/site-packages/pygments/__init__.py", line 37, in <module>
from pygments.util import StringIO, BytesIO
File "/Users/al/Scripts/.venv/lib/python3.13/site-packages/pygments/util.py", line 27, in <module>
tag_re = re.compile(r'<(.+?)(\s.*?)?>.*?</.+?>(?uism)')
File "/opt/homebrew/Cellar/python@3.13/3.13.3/Frameworks/Python.framework/Versions/3.13/lib/python3.13/re/__init__.py", line 289, in compile
return _compile(pattern, flags)
File "/opt/homebrew/Cellar/python@3.13/3.13.3/Frameworks/Python.framework/Versions/3.13/lib/python3.13/re/__init__.py", line 350, in _compile
p = _compiler.compile(pattern, flags)
File "/opt/homebrew/Cellar/python@3.13/3.13.3/Frameworks/Python.framework/Versions/3.13/lib/python3.13/re/_compiler.py", line 748, in compile
p = _parser.parse(p, flags)
File "/opt/homebrew/Cellar/python@3.13/3.13.3/Frameworks/Python.framework/Versions/3.13/lib/python3.13/re/_parser.py", line 980, in parse
p = _parse_sub(source, state, flags & SRE_FLAG_VERBOSE, 0)
File "/opt/homebrew/Cellar/python@3.13/3.13.3/Frameworks/Python.framework/Versions/3.13/lib/python3.13/re/_parser.py", line 459, in _parse_sub
itemsappend(_parse(source, state, verbose, nested + 1,
~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
not nested and not items))
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.13/3.13.3/Frameworks/Python.framework/Versions/3.13/lib/python3.13/re/_parser.py", line 841, in _parse
raise source.error('global flags not at the start '
'of the expression',
source.tell() - start)
re.PatternError: global flags not at the start of the expression at position 24
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the import using Python 3.13 and follow the traceback from ollama/_client.py through httpx/_main.py to pygments/util.py, where tag_re is compiled. Check the dependency versions involved and verify that importing ollama succeeds without the re.PatternError; run any available project checks after the change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100