Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

common.py cannot import export_formats from export.py #12758

Closed
1 of 2 tasks
jacobbreen25 opened this issue Feb 22, 2024 · 6 comments
Closed
1 of 2 tasks

common.py cannot import export_formats from export.py #12758

jacobbreen25 opened this issue Feb 22, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@jacobbreen25
Copy link

jacobbreen25 commented Feb 22, 2024

Search before asking

  • I have searched the YOLOv5 issues and found no similar bug report.

YOLOv5 Component

No response

Bug

I have been trying to create a ros2 node for yolov5. Using yolov5.7, I have fully created the driver but in running, I get the following error:

ImportError: cannot import name 'export_formats' from 'export' (/home/jbreen/.local/lib/python3.10/site-packages/export/__init__.py)

After uninstalling the export library, I got an error saying there is no library named export (I do not want to have to reinstall export so I will not put the error)

Environment

YOLO: yolov5.7
ROS2: Humble

Minimal Reproducible Example

python3 detect.py

Additional

No response

Are you willing to submit a PR?

  • Yes I'd like to help by submitting a PR!
@jacobbreen25 jacobbreen25 added the bug Something isn't working label Feb 22, 2024
Copy link
Contributor

👋 Hello @jacobbreen25, thank you for your interest in YOLOv5 🚀! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.

If this is a 🐛 Bug Report, please provide a minimum reproducible example to help us debug it.

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.

Requirements

Python>=3.8.0 with all requirements.txt installed including PyTorch>=1.8. To get started:

git clone https://github.com/ultralytics/yolov5  # clone
cd yolov5
pip install -r requirements.txt  # install

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

YOLOv5 CI

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training, validation, inference, export and benchmarks on macOS, Windows, and Ubuntu every 24 hours and on every commit.

Introducing YOLOv8 🚀

We're excited to announce the launch of our latest state-of-the-art (SOTA) object detection model for 2023 - YOLOv8 🚀!

Designed to be fast, accurate, and easy to use, YOLOv8 is an ideal choice for a wide range of object detection, image segmentation and image classification tasks. With YOLOv8, you'll be able to quickly and accurately detect objects in real-time, streamline your workflows, and achieve new levels of accuracy in your projects.

Check out our YOLOv8 Docs for details and get started with:

pip install ultralytics

@glenn-jocher
Copy link
Member

@jacobbreen25 hello! Thank you for reporting this issue. It seems like there might be a conflict with another package named export installed in your environment. YOLOv5's export.py should not be installed as a top-level package, so it's possible that Python is trying to import export_formats from the wrong export package.

To resolve this, please ensure that you are running your script from the root directory of the cloned YOLOv5 repository, and not from the site-packages directory. This way, Python should correctly reference the local export.py file rather than an installed package.

If you're still encountering issues, please refer to our documentation for further guidance on setting up your environment and running detection. If the problem persists, feel free to open a new issue with updated details. Thank you for your contribution to the YOLOv5 community! 🚀

@jacobbreen25
Copy link
Author

Closing because I found the issue. yolov5 library did not get added to python path so adding it fixed the issue immediately

@glenn-jocher
Copy link
Member

@jacobbreen25 Great to hear that you've resolved the issue! Adding the YOLOv5 library to the Python path is indeed a crucial step. If you have any more questions or run into any other issues, don't hesitate to reach out. Happy coding and best of luck with your ROS2 node development! 🎉

@sun-rabbit
Copy link

Closing because I found the issue. yolov5 library did not get added to python path so adding it fixed the issue immediately

Hello,

Could you please let me know how to add the YOLOv5 library to the Python path? Thank you.

@glenn-jocher
Copy link
Member

Hello @sun-rabbit,

I'm glad to hear you resolved the issue! To add the YOLOv5 library to your Python path, you can follow these steps:

  1. Locate the YOLOv5 Directory: Ensure you know the path to your cloned YOLOv5 repository. For example, if you cloned it to your home directory, the path might be /home/your_username/yolov5.

  2. Modify the Python Path: You can add the YOLOv5 directory to your Python path in your script or environment. Here are a couple of ways to do this:

    • Temporarily in a Script:
      Add the following lines at the beginning of your script:

      import sys
      sys.path.append('/path/to/yolov5')
    • Permanently in Your Environment:
      You can add the YOLOv5 directory to your PYTHONPATH environment variable. For example, in a Unix-like system, you can add the following line to your .bashrc or .bash_profile:

      export PYTHONPATH="$PYTHONPATH:/path/to/yolov5"

      Then, reload your shell configuration:

      source ~/.bashrc

By following these steps, Python should be able to locate the YOLOv5 library correctly. If you have any further questions or run into any other issues, feel free to ask. The YOLOv5 community and the Ultralytics team are here to help! 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants