Unable to install editable
Search before asking
- [x] I have searched the Ultralytics YOLO issues and found no similar bug report.
Ultralytics YOLO Component
Install
Bug
I try to install Ultralytics in my python environment in the editable mode. But i get the following error in model import:
python -c "from ultralytics import YOLO"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: cannot import name 'YOLO' from 'ultralytics' (unknown location)
When I run the same command with non-editable installation, everything works just fine
Environment
The problem persists with newer and older versions: ultralytics==8.3.228 and ultralytics==8.2.40
I install the package from source:
git clone https://github.com/ultralytics/ultralytics.git
pip install -e ultralytics/
This produces the newest version 8.3.228 for me.
And for the the older version I also install from source using different tag:
git checkout v8.2.40
Minimal Reproducible Example
git clone https://github.com/ultralytics/ultralytics.git
pip install -e ultralytics/
python -c "from ultralytics import YOLO"
Additional
No response
Are you willing to submit a PR?
- [ ] Yes I'd like to help by submitting a PR!
๐ Hello @Dentikka, thank you for your detailed report and for using Ultralytics ๐! This is an automated response to help gather initial details; an Ultralytics engineer will review your issue and assist you further soon.
Youโve already shared a helpful Minimal Reproducible Example (MRE) ๐. For ๐ installation/import bugs like this, itโs especially useful to also include, if possible:
- Your OS and version (e.g., Ubuntu, Windows, macOS)
- Your Python version
- Your
pipversion and how you create/manage your environment (venv, conda, etc.) - The exact command you use to activate the environment before running
python -c "from ultralytics import YOLO"
If this is a ๐ Bug Report and you refine your minimum reproducible example further (for example by including full console logs from pip install -e ultralytics/ and the import error), that will help us debug it even faster.
If this is a custom training โ Question related to using editable installs for development, please provide as much information as possible, including what workflows you are trying to enable with pip install -e, and verify you are following our Tips for Best Training Results.
You can also connect with the community for more real-time or in-depth help:
- For real-time chat, join our Discord ๐ง
- For longer-form technical discussions, visit Discourse
- To share knowledge and see how others work with YOLO, check out our Subreddit
Upgrade
Before we dig in, please make sure youโve tested with the latest ultralytics package and all requirements in a Python>=3.8 environment with PyTorch>=1.8. This helps confirm the issue is not already resolved in the latest release:
pip install -U ultralytics
Environments
YOLO may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
- Notebooks with free GPU:
- Google Cloud Deep Learning VM. See GCP Quickstart Guide
- Amazon Deep Learning AMI. See AWS Quickstart Guide
- Docker Image. See Docker Quickstart Guide
These can be useful to compare behavior between your local editable install and a known-good reference environment.
Status
If this badge is green, all Ultralytics CI tests are currently passing. CI tests verify correct operation of all YOLO Modes and Tasks on macOS, Windows, and Ubuntu every 24 hours and on every commit.
You need to cd into the ultralytics folder.
Thanks! But what if I need to run some pipeline using Ultralytics in another working directory?
It would work. The original error is caused because you're importing the ultralytics repo directory instead of the package, because the ultralytics in your working directory is the cloned repo, not the package. When you cd into it or move to any other folder that doesn't contain ultralytics folder, Python will correctly import the package.
Okay, thanks! Now I understand how it works! Sorry for the disturbance
No worries at all, glad itโs clear nowโif you ever need a reference for install/editable setups, the steps in the Install Ultralytics guide stay up to date and are safe to follow.