You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched the YOLOv8 issues and found no similar bug report.
YOLOv8 Component
Integrations
Bug
So I am trying to include YOLOV8 into my streamlit environment. In my venv YOLOv8 and ultralytics are installed (Version: 8.1.45) and confirmed to work.
In a separate script I have successfully integrated YOLO and can import it and run inference without issues.
In my streamlit dashboard I can call this script and it runs. However, in order to include the output to the dashboard, I want to include the functions of the script inside the streamlit script.
For whatever reason, when I include the line "from ultralytics import YOLO" this returns ModuleNotFoundError: No module named 'ultralytics'
This makes little sense to me since it runs within the same venv when I call the other script with the same line. Is this a known issue?
Can you help me solve it?
👋 Hello @WangfeETH, thank you for your interest in Ultralytics YOLOv8 🚀! We recommend a visit to the Docs for new users where you can find many Python and CLI usage examples and where many of the most common questions may already be answered.
If this is a custom training ❓ Question, please provide as much information as possible, including dataset image examples and training logs, and verify you are following our Tips for Best Training Results.
Join the vibrant Ultralytics Discord 🎧 community for real-time conversations and collaborations. This platform offers a perfect space to inquire, showcase your work, and connect with fellow Ultralytics users.
YOLOv8 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
If this badge is green, all Ultralytics CI tests are currently passing. CI tests verify correct operation of all YOLOv8 Modes and Tasks on macOS, Windows, and Ubuntu every 24 hours and on every commit.
Hey there! It sounds frustrating, but we'll figure this out. 🛠️
It seems like the issue arises from how Streamlit is interacting with your virtual environment. One common reason for such discrepancies might be the environment path that's active when Streamlit was initiated. Here's a quick thing to check:
Verify Environment Activation:
Make sure that when you're launching the Streamlit application, the correct virtual environment (venv) is activated. Sometimes, different shell instances or IDEs might have distinct paths or environments.
# In your terminal, activate the venvsource path_to_your_venv/bin/activate
# Then run streamlit
streamlit run your_script.py
Check Importing Directly:
Within the Streamlit script, add a debugging line to print out modules. It can help confirm if ultralytics is rightly accessible.
# Add this at the top of your Streamlit scriptimportsysprint(sys.executable)
print(sys.path)
fromultralyticsimportYOLO# your import statement
This will show you the Python executable being used and the PATH it's operating with. If the paths differ from what your other scripts use inside the same environment, then we'll need to adjust the PYTHONPATH or how Streamlit is started.
Try these steps out, and let's see if it helps resolve the error!
Search before asking
YOLOv8 Component
Integrations
Bug
So I am trying to include YOLOV8 into my streamlit environment. In my venv YOLOv8 and ultralytics are installed (Version: 8.1.45) and confirmed to work.
In a separate script I have successfully integrated YOLO and can import it and run inference without issues.
In my streamlit dashboard I can call this script and it runs. However, in order to include the output to the dashboard, I want to include the functions of the script inside the streamlit script.
For whatever reason, when I include the line "
from ultralytics import YOLO
" this returns ModuleNotFoundError: No module named 'ultralytics'This makes little sense to me since it runs within the same venv when I call the other script with the same line. Is this a known issue?
Can you help me solve it?
Environment
Ultralytics YOLOv8.1.45 🚀 Python-3.9.19 torch-2.4.0.dev20240411+cu121 CUDA:0 (NVIDIA GeForce RTX 2080, 8192MiB)
Setup complete ✅ (16 CPUs, 15.9 GB RAM, 24801.2/28000.0 GB disk)
Minimal Reproducible Example
No response
Additional
No response
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: