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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:11:21+00:00 2026-06-10T12:11:21+00:00

I am trying to learn Python distribute package, and can’t seems figure out the

  • 0

I am trying to learn Python distribute package, and can’t seems figure out the /bin part myself. The Foo package installed and I can reference to it by using from FOO import Foo.

For example, if I had a project named foo, and I have a script, called use-foo, after I
put ‘use-foo’ inside my foo/bin, how I am suppose to use it?

The project source file/directory structure looks like this:

foo
-->FOO (source code for foo)
    -->Foo.py
-->bin (script uses Foo goes here)
    -->use-foo.py

I’ve tried import use-foo, from foo import use-foo not working, relative path?

Add setup.py:

try:
    from setuptools import setup
except ImportError:
    from distutils.core import setup

config = {
    'description': 'My Foo Project', 
    'author': 'Paul Liu',
    'url': 'URL to get it at.',
    'download_url': 'Where to download it.',
    'author_email': 'My email.',
    'version': '0.1',
    'install_requires':['nose'],
    'packages':['FOO'],
    'scripts':['bin/use-foo.py'],
    'name': 'foo'
}

setup(**config) 
  • 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-10T12:11:23+00:00Added an answer on June 10, 2026 at 12:11 pm

    The source directory alone is only where you will develop your code. It doesn’t really reflect the final product (installed) form until you have it build by one of the available commands (or manually add the various paths to your env).

    To develop, what you can do is run this: python setup.py develop
    This will install an egg in your python site-packages that is really just a link back to your source location. Meaning that you can actively edit code, and it will reflect in your PYTHONPATH. The build process will place the package FOO into your PYTHONPATH, and copy everything in your scripts to the python bin. For instance on my machine:

    Creating
    /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/foo.egg-link
    (link to .)
    Installing use-foo.py script to
    /Library/Frameworks/Python.framework/Versions/2.6/bin

    Now in your use-foo.py, you can refer to FOO as the import package, as it will exist in the python path. If you choose not to use the develop command, you would need to manually add foo/ to your PYTHONPATH, so that it will find the FOO package underneath.

    Most important here: add a __init__.py file (empty) to your FOO package. This is required for python to recognize it as a package.


    Manual environment paths

    Adding paths manually to your shell environment might look like this (bash shell):

    export PYTHONPATH=/path/to/foo:$PYTHONPATH
    export PATH=/path/to/foo/bin:$PATH
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to learn python and couldn't figure out how to translate the
Hi im trying to learn Python and have a err i can understand ,
part-time C# programmer here trying to learn Python. I am looking to be able
I'm trying to learn how to use Python's multiprocessing package, but I don't understand
I am trying to learn Python by myself using Zed A.Shaw's book Learn Python
I'm trying to learn python, and I'm pretty new at it, and I can't
I have been trying to learn python over the last couple of months and
I am trying to learn Python. Consider this simple anagram checker in C: bool
I'm trying to learn python and I'm attempting a hangman game. But when I
I am trying to learn python and am making a program that will output

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.