Fix PyTorch ImportError
2025-09-044 turns7,698 charsgpt-5
Summary
User encountered a PyTorch ImportError when running a Python script with specific command-line arguments.
Messages
python3 main.py --interval_fetch 2 --persona "personas/tan.yaml" --guidance "Upscale the vocabulary and content of the segments to the highest level you can"
Traceback (most recent call last):
File "/Users/danielkliewer/news17/main.py", line 7, in <module>
from src.core.generator import NewsGenerator
File "/Users/danielkliewer/news17/src/core/generator.py", line 20, in <module>
from src.nlp.clustering import StreamClusterer
File "/Users/danielkliewer/news17/src/nlp/clustering.py", line 3, in <module>
from sentence_transformers import SentenceTransformer
File "/Users/danielkliewer/news17/venv/lib/python3.13/site-packages/sentence_transformers/__init__.py", line 9, i
n <module> from sentence_transformers.backend import (
...<3 lines>...
)
File "/Users/danielkliewer/news17/venv/lib/python3.13/site-packages/sentence_transformers/backend.py", line 11, i
n <module> from sentence_transformers.util import disable_datasets_caching, is_datasets_available
File "/Users/danielkliewer/news17/venv/lib/python3.13/site-packages/sentence_transformers/util.py", line 17, in <
module> import torch
File "/Users/danielkliewer/news17/venv/lib/python3.13/site-packages/torch/__init__.py", line 409, in <module>
from torch._C import * # noqa: F403
^^^^^^^^^^^^^^^^^^^^^^
ImportError: dlopen(/Users/danielkliewer/news17/venv/lib/python3.13/site-packages/torch/_C.cpython-313-darwin.so, 0
x0002): Symbol not found: __ZN2at3cpu21is_amx_fp16_supportedEv Referenced from: <35AA4B87-2EA4-3AA3-B094-AF14FDCF53FB> /Users/danielkliewer/news17/venv/lib/python3.13/site-pack
ages/torch/lib/libtorch_python.dylib Expected in: <02708A55-A57E-3D2F-9776-1A10E5BD6757> /opt/homebrew/Cellar/pytorch/2.5.1_4/libexec/lib/python3.
13/site-packages/torch/lib/libtorch_cpu.dylib
Got it — thanks for pasting the traceback. The important part is here:
```
ImportError: dlopen(...torch/_C.cpython-313-darwin.so, 0x0002):
Symbol not found: __ZN2at3cpu21is_amx_fp16_supportedEv
Referenced from: .../torch/lib/libtorch_python.dylib
Expected in: .../torch/lib/libtorch_cpu.dylib
```
This means **your PyTorch install doesn’t match your Python version (3.13) or system libraries**.
Right now, PyTorch does **not officially support Python 3.13** — the latest stable builds (as of 2.5.1) are for Python 3.12 and earlier.
### How to fix
You have a few options:
#### 1. Use Python 3.12 instead of 3.13 (recommended)
```bash
# Create a new virtual environment with Python 3.12
pyenv install 3.12.6 # if you use pyenv
pyenv virtualenv 3.12.6 news17-env
pyenv activate news17-env
# Or if you use homebrew:
brew install python@3.12
python3.12 -m venv venv
source venv/bin/activate
```
Then reinstall dependencies:
```bash
pip install -U pip
pip install torch sentence-transformers
```
#### 2. Try nightly builds (Python 3.13 support is experimental)
```bash
pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cpu
```
⚠️ This may still break — it’s bleeding-edge and not guaranteed stable.
#### 3. Use Docker
If you don’t want to downgrade your system Python, you can run your project inside a Python 3.12 Docker container with PyTorch pre-installed.
---
👉 Easiest path for now: **use Python 3.12** in your virtualenv for this project. That will eliminate the `dlopen` / `symbol not found` mismatch.
Do you want me to write out a one-liner that sets up a fresh Python 3.12 environment and installs everything cleanly?
gpt-5
python3 main.py --interval_fetch 2 --persona "personas/tan.yaml" --guidance "Upscale the vocabulary and content of the segments to the highest level you can"
Traceback (most recent call last):
File "/Users/danielkliewer/news17/main.py", line 7, in <module>
from src.core.generator import NewsGenerator
File "/Users/danielkliewer/news17/src/core/generator.py", line 20, in <module>
from src.nlp.clustering import StreamClusterer
File "/Users/danielkliewer/news17/src/nlp/clustering.py", line 3, in <module>
from sentence_transformers import SentenceTransformer
File "/Users/danielkliewer/news17/venv/lib/python3.13/site-packages/sentence_transformers/__init__.py", line 9, i
n <module> from sentence_transformers.backend import (
...<3 lines>...
)
File "/Users/danielkliewer/news17/venv/lib/python3.13/site-packages/sentence_transformers/backend.py", line 11, i
n <module> from sentence_transformers.util import disable_datasets_caching, is_datasets_available
File "/Users/danielkliewer/news17/venv/lib/python3.13/site-packages/sentence_transformers/util.py", line 17, in <
module> import torch
File "/Users/danielkliewer/news17/venv/lib/python3.13/site-packages/torch/__init__.py", line 409, in <module>
from torch._C import * # noqa: F403
^^^^^^^^^^^^^^^^^^^^^^
ImportError: dlopen(/Users/danielkliewer/news17/venv/lib/python3.13/site-packages/torch/_C.cpython-313-darwin.so, 0
x0002): Symbol not found: __ZN2at3cpu21is_amx_fp16_supportedEv Referenced from: <35AA4B87-2EA4-3AA3-B094-AF14FDCF53FB> /Users/danielkliewer/news17/venv/lib/python3.13/site-pack
ages/torch/lib/libtorch_python.dylib Expected in: <02708A55-A57E-3D2F-9776-1A10E5BD6757> /opt/homebrew/Cellar/pytorch/2.5.1_4/libexec/lib/python3.
13/site-packages/torch/lib/libtorch_cpu.dylib
Thanks for rerunning and sharing the full traceback — this is the same root issue:
`torch` was built against libraries that **don’t exist for Python 3.13 on macOS**. The missing symbol (`is_amx_fp16_supportedEv`) tells us your build of PyTorch is looking for CPU acceleration instructions it can’t find in your local libtorch.
👉 The key point: **PyTorch 2.5.1 does not officially support Python 3.13 yet.**
---
### ✅ Fix
The most stable path right now is to **switch your project’s virtual environment to Python 3.12**.
Here’s a safe set of steps:
```bash
# 1. Install Python 3.12 if you don’t already have it
brew install python@3.12 # if using Homebrew
# 2. Create a new virtual environment with 3.12
python3.12 -m venv venv312
source venv312/bin/activate
# 3. Upgrade pip
pip install -U pip setuptools wheel
# 4. Reinstall your project dependencies
pip install -r requirements.txt
```
That should give you a compatible `torch` build.
---
### ⚡ Alternative (experimental)
If you really want to stay on Python 3.13, you can try nightly builds of PyTorch:
```bash
pip install --pre torch torchvision torchaudio \
--index-url https://download.pytorch.org/whl/nightly/cpu
```
…but this is **unstable** and may break other libraries (`sentence-transformers` in particular).
---
Would you like me to give you a **drop-in script** that auto-detects if you’re on Python 3.13 and then spins up a Python 3.12 venv for your project so you don’t have to manage it manually?
gpt-5