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 7062289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:34:34+00:00 2026-05-28T04:34:34+00:00

I am trying to import one python script from another. I have a few

  • 0

I am trying to import one python script from another. I have a few common functions defined in one script and then lots of other scripts that want to import those functions. No classes, just functions.

The importing script needs to import from a relative path e.g. ../../SharedScripts/python/common.py

I then a have a few functions def f1(...) defined which I will call.

I found the imp module which seemed to be the right thing to use but I was unable to figure out the exact syntax that would work for my example.

Can someone suggest the correct code to use or the simplest approach if imp is not the right module?

SOLUTION from the answers below I was able to get this working…

projectKey = 'THOR'

# load the shared script relative to this script
sys.path.append(os.path.dirname(__file__) + '/../../SharedScripts/python')
import jira

jira.CheckJiraCommitMessage(sys.argv[1], sys.argv[2], projectKey)

Where I had an empty __init__.py and a jira.py in the SharedScripts/python directory with plain function definitions.

  • 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-05-28T04:34:34+00:00Added an answer on May 28, 2026 at 4:34 am

    Why not adding ../../SharedScripts/python/ to the python path? Then you could use common.py like any other module:

    import common
    common.f1()
    

    You can alternate the Python path through the system variable PYTHONPATH or by manipulating it directly from python: sys.path.append("../../SharedScripts/python/")

    Please notice that it is probably wiser to work with absolute pathes… (The current directory of the app could change)

    To get the absolute path could can call use the function os.path.abspath: os.path.abspath('../../SharedScripts/python/')

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

Sidebar

Related Questions

I am trying to write a Python script that will copy files from one
I have one python script which i am trying to convert and stuck in
Im trying to fix a Python script which takes the posts from a specific
I am trying to migrate microsoft office settings from one system to other system
I'm trying to execute a python script (through a python process) under another user.
I am trying to write a python script for Sieve of Eratosthenes. I have
I'm trying to create a simple python script and import a couple of custom
I have an .x3d code which references a python script. I am trying to
I've been trying to pass my login and password from Python script to the
I am trying to import an access database to mysql. I have created a

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.