Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8282273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:18:59+00:00 2026-06-08T10:18:59+00:00

I just pulled the latest version of opencv from source, and unfortunately for the

  • 0

I just pulled the latest version of opencv from source, and unfortunately for the moment I must have 2 different versions on one machine.

So I have the default location /usr/local/... for the older version, and a custom location for the newer version.

My issue is that if I open a python terminal and try to import cv2, I can only get the new version to load if I start in the opencv/lib directory of the new version.

I want to be able to toggle which version of opencv I use, ideally it would be in the python script itself.

I expected to be able to set either LD_LIBRARY_PATH or PYTHONPATH or both in the terminal, or change the environment variables using os.environ, but had no success.

First, I don’t understand why I have to be in the lib directory to get the new version to load, and second I don’t see why I cannot dynamically change where python looks to import the module using environment variables.

Any help is appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T10:19:01+00:00Added an answer on June 8, 2026 at 10:19 am

    You can use the imp module to import from a specified path.

    import imp
    fp, pathname, description = imp.find_module('cv2', ['/path/to/opencv/'])
    cv2 = imp.load_module('cv2', fp, pathname, description)
    

    http://docs.python.org/library/imp.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just pulled the 2010 ultimate from MSDN, and I see there's no Smart
I have just migrated my RoR dev environmnent over to Ubuntu. I pulled a
I just pulled from my github and tried to setup my application on my
I have a 3 tier applicaiton, winforms, business and data layers. I just pulled
I've just started using BoneCP and pulled the sample JDBC code from the authors
I just did a pull from github and pulled from the wrong github repository
I have a Git repository on my local machine that I cloned from my
Just downloaded IE9 and pulled up a webproject i have with an IHttpHandler that
In a team environment on a Linux system I just pulled the latest code
My friend just shared me this new application and I pulled it from heroku

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.