Last modified: Aug 11, 2026

Fix ModuleNotFoundError: No module named ultralytics

Seeing the error ModuleNotFoundError: No module named 'ultralytics' can be frustrating. This is a common issue for Python beginners. It simply means Python cannot find the Ultralytics library in your current environment. The Ultralytics package is essential for running YOLO models. This guide will walk you through the causes and solutions step by step.

What Does This Error Mean?

This error indicates that the ultralytics module is not installed. Python relies on external packages to extend its functionality. When you try to import a missing package, the interpreter stops and raises this error. The solution is usually straightforward: install the package correctly.

However, sometimes the package is installed but Python still can't find it. This often happens due to environment mismatches. You might have multiple Python versions on your system. Or perhaps you are using a virtual environment that doesn't have the package. Let's explore the most effective solutions.

Solution 1: Install the Ultralytics Package

The first and most common fix is to install the package using pip. Open your terminal or command prompt. Then, run the following command. This will download and install the latest version of Ultralytics and its dependencies.


pip install ultralytics

If you are using Python 3, you might need to use pip3 instead. On some systems, pip is linked to Python 2. Always check your Python version first. If the installation is successful, you should see a message similar to this.


Successfully installed ultralytics-8.3.0

After installation, try importing the library again. If you still get the error, the issue is likely your environment. Don't worry; we have more solutions below.

Solution 2: Use a Virtual Environment

Virtual environments are crucial for Python projects. They create isolated spaces for your dependencies. This prevents conflicts between different projects. If you installed Ultralytics globally, your current project might not see it. Create a new virtual environment and install the package there.


python -m venv myenv
# Activate on Windows
myenv\Scripts\activate
# Activate on macOS/Linux
source myenv/bin/activate

Once activated, your terminal prompt will change. Now, install Ultralytics again within this environment. This ensures the package is available for your current project. This is a best practice for any Python development.


pip install ultralytics

Now, run your Python script. The error should be resolved. If you are working on a team, always use a requirements.txt file. This file lists all necessary packages. You can generate it with pip freeze > requirements.txt. This helps others set up the same environment easily.

Solution 3: Check Your Python Interpreter

Sometimes, your IDE or editor is using a different Python interpreter. This is a common issue in VS Code or PyCharm. You might have installed the package for one Python version but are running the code with another. Check your IDE's settings to confirm the correct interpreter is selected.

In VS Code, press Ctrl+Shift+P and type "Python: Select Interpreter". Choose the one that has Ultralytics installed. In PyCharm, go to Settings > Project > Python Interpreter. Ensure the correct environment is selected. This simple check often resolves the problem.

You can also verify which Python is being used from the terminal. Run which python on macOS/Linux or where python on Windows. This shows the full path to the Python executable. Compare this with the one in your IDE.

Solution 4: Upgrade Pip and Python

An outdated pip can cause installation issues. It might not find the correct package version or fail to install dependencies. Upgrade pip to the latest version first. This often fixes hidden installation problems.


pip install --upgrade pip

Also, ensure your Python version is supported. Ultralytics requires Python 3.8 or later. If you have an older version, the package might not install correctly. Check your Python version with python --version. If it's old, consider updating Python from the official website.

After upgrading, try installing Ultralytics again. Sometimes, a fresh install after an upgrade resolves all issues. This is a low-risk solution that often works.

Solution 5: Install in Jupyter Notebook

If you are using Jupyter Notebook, the installation process is slightly different. You need to install the package directly from the notebook cell. Use the exclamation mark before the pip command. This tells Jupyter to run it as a shell command.


# Install ultralytics directly in Jupyter
!pip install ultralytics

After running this cell, restart the kernel. This is important because the kernel might not recognize the new package until it restarts. Go to Kernel > Restart & Run All. Then, try importing the library again. This should solve the issue for Jupyter users.

For more advanced usage, you can also install from the GitHub repository. This gives you the latest development version. Use !pip install git+https://github.com/ultralytics/ultralytics.git. However, the standard PyPI version is more stable for beginners.

Common Pitfalls and Additional Tips

One common mistake is having a file named ultralytics.py in your project directory. This shadows the actual package. Python might import your empty file instead of the library. Delete any local files with the same name as the package.

Another issue is using the wrong package name. The correct name is ultralytics, all lowercase. Do not use uppercase letters. Also, check for typos in your import statement. The correct import is from ultralytics import YOLO. This is the main class you will use for object detection.

If you are still facing issues, consider using a package manager like Conda. Conda handles dependencies better in some cases. Create a new environment with conda create -n myenv python=3.9. Then activate it and install Ultralytics with pip install ultralytics. This combination often works well.

Test Your Installation

After following the steps, test your installation with a simple script. This will confirm everything is working. Create a new Python file and add the following code. It just imports the library and prints a success message.


# test_ultralytics.py
from ultralytics import YOLO

print("Ultralytics imported successfully!")

Run this script. If you see the success message, you are ready to go. If not, go back and review the solutions above. The issue is almost always an environment mismatch. Patience is key.


Ultralytics imported successfully!

Now you can start using YOLO models for your projects. The Ultralytics library is powerful and easy to use once set up correctly. You can load pre-trained models and run inference on images or videos.

Conclusion

Resolving ModuleNotFoundError: No module named 'ultralytics' is usually simple. Start by installing the package with pip. If that fails, check your virtual environment and Python interpreter. These are the most common culprits. Remember to upgrade pip and Python if necessary. For Jupyter users, install directly in the notebook and restart the kernel.

Always test your setup with a simple import script. This saves you time in the long run. By following this guide, you can get past this error and focus on building your computer vision applications. The Ultralytics library opens up many possibilities for AI development. Happy coding!