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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:23:19+00:00 2026-05-22T01:23:19+00:00

I am having difficulties importing a script from a directory that is not stored

  • 0

I am having difficulties importing a script from a directory that is not stored in sys.path. I have a script saved as test.py in a directory called “Development” and am trying to add the development directory to sys.path so I can import a function from my current script called index.py.

Here is my code for index.py:

import sys
sys.path.append ('/Users/master/Documents/Development/')
import test

printline()

printline() is defined in test.py as:

def printline():
    print "I am working"

Here is the error I am receiving:

Traceback (most recent call last):
  File "/Users/master/Documents/index.py", line 6, in <module>
    printline()
NameError: name 'printline' is not defined

Any ideas on how I can get this to work?

Thanks.

  • 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-22T01:23:20+00:00Added an answer on May 22, 2026 at 1:23 am
    1. If you do import test, the function you defined is imported into its own namespace, so you must refer to it as test.printline().

    2. test may be the name of another module in your Python path, and since the directory you insert is appended to the path, it will be considered only if test is nowhere else to be found. Try inserting the path to the head of sys.path instead:

      sys.path.insert(0, "...")
      

    In a vanilla Python, the culprit is likely #1, but if you do not want your scripts to break in the future, you should also get used to #2.

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

Sidebar

Related Questions

I am having difficulties sending the UDID from the iPhone to a PHP script
I'm having difficulties working with some legacy enums that have multiple zero values. Whenever
I have been having difficulties with a piece of script I am creating, and
I am having difficulties with a program that I have been working on all
I am having difficulties with pages that have more than one <audio> when I
I'm having difficulties getting XslCompiledTransform.Load method to take a server path. I googled around
I am having difficulties with forms, specifically ModelMultipleChoiceField. I've pieced together this code from
I am having difficulties how to construct my question, but if I have to
I'm having difficulties adding momentum to my spinning wheel. I have this wheel (something
I'm having difficulties reading an app.config using the ConfigurationManager. I have a custom section,

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.