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

  • Home
  • SEARCH
  • 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 3501304
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:50:32+00:00 2026-05-18T12:50:32+00:00

I’ve written a Python script that uses a package that I’ve created. I need

  • 0

I’ve written a Python script that uses a package that I’ve created. I need to package it, so I can install it on several servers, but I can’t get setup.py to find my scripts.

There’s two parts to my script: connections.py and a module that is imported as X.utils.printing (where X is my group name).
I need to bundle both with distutils.

I’ve read the Python Distutils documentation about five times, and I just don’t get it.

Here’s what I need to do:
1) Make sure that my printing module is installed and can be imported with

from X.utils.printing import PrettyPrint as PP

2) Put connections.py in /usr/sbin/

This should be very straightforward, but it’s become maddening.

Here’s my current setup.py that doesn’t work:

from distutils.core import setup

setup(name='connections', version='0.1.1', 
      description='Print number of IHS connections',    
      author='fandingo', author_email='fandingo@fandingo.com', 
      package_dir = {'X.utils' : 'X'}, 
      packages=['X.utils.printing'], py_modules=['printing', 'connections'])

setup.py resides and is run from a directory called ‘python’ and has connection-stats/ and X inside. connection-stats has connections.py inside. X has init.py, utils/init.py, and utils/printing.py.

When I try to run setup.py, I get the following output:

python setup.py bdist

running bdist running bdist_dumb

running build running build_py file

printing.py (for module printing) not

found file connections.py (for module

connections) not found error: package

directory ‘X/printing’ does not exist

Could someone help me fix my setup.py, so I can package my script and module?

Thanks for all the help.

Edit: I haven’t made any attempt to copy connections.py to /usr/sbin/. I haven’t gotten beyond distutils not finding my modules.


Edit 2:
I think that I’m getting much closer, but I can’t get my package hierarchy to work.

Using,

setup(name='connections', version='0.1.1', description='Print number of IHS connections',
      author='fandingo', author_email='fandingo@fanding.com',
      package_dir = {'printing' : 'X/utils'}, packages=['printing'], 
      scripts=['connection-stats/connections.py'])

I get a successful build that has connections.py in what should become /usr/sbin/ when an installation is performed.
The only problem is that printing gets imported without the X.utils.printing.

I can change it to include X, but it doesn’t include child packages.

setup(name='connections', version='0.1.1', 
      description='Print number of IHS connections', 
      author='fandingo', 
      author_email='fandingo@fandingo.com', 
      packages=['X'],
      scripts=['connection-stats/connections.py'])

The problem here is that X is imported, but only the init.py. utils/ isn’t included, which means I don’t get utils/printing.py

It’s like I need some sort of recursive option, so I can add X and everything below it. Any thoughts?

Thanks,

———————-

Edit 3:

Just about completed. I figured out that I need to explicitly list every sub-package in X. Here’s the corrected setup.py

setup(
    name='connections',
    version='0.1.1',
    description='Print number of IHS connections',
    author='fandingo',
    author_email='fandingo@fandingo.com',
    package_dir = {'utils' : 'X/', 'printing' : 'X/utils/'},
    packages=['X', 'X.utils'],
    py_modules = ['printing'],
    scripts=['connection-stats/connections.py'])

The only other thing is that connections.py isn’t moved to /usr/sbin/. I think that I will just add a post-install option to manually move it.

  • 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-18T12:50:33+00:00Added an answer on May 18, 2026 at 12:50 pm

    I think you’ll want something like the following:

    from distutils.core import setup
    
    setup(name='connections',
          version='0.1.1',
          description='Print number of IHS connections',
          author='fandingo',
          author_email='fandingo@fandingo.com',
          packages=['X'],
          scripts=['connection-stats/connections.py'])
    

    UPDATE: fix packages list

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

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.