Find the answer to your Linux question:
Results 1 to 3 of 3
I'm just starting to program, and I'm using Python 2.5 on Ubuntu. I made a file for my programs under my home file. However, when I try to import my ...
  1. #1
    Linux Newbie danbuter's Avatar
    Join Date
    May 2007
    Posts
    108

    Python - where do I put my programs file in Linux?

    I'm just starting to program, and I'm using Python 2.5 on Ubuntu. I made a file for my programs under my home file. However, when I try to import my programs, I get the following error:

    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    ImportError: No module named chaos
    >>>

    I'm 99% sure I need to put my programs in the Python directory somehow, but I'm not sure how.

    Currently, the program is at:
    danbuter\pythonprogs\chaos.py

    Python is installed at:
    usr\lib\python2.5

    I tried to create a new file there, but it wouldn't let me. Even if I do, I am not sure if it needs to be in one of the subdirectories or should be directly after python2.5. I'm assuming I'll need to use a sudo command to accomplish this.

    Can anyone tell me what I need to do so that python will import my programs? Thanks!
    Dan

  2. #2
    Linux Engineer Javasnob's Avatar
    Join Date
    Jul 2005
    Location
    Wisconsin
    Posts
    942
    6. Modules

    As a rule of thumb, don't use root unless you have to.
    Flies of a particular kind, i.e. time-flies, are fond of an arrow.

    Registered Linux User #408794

  3. #3
    Linux User
    Join Date
    Aug 2006
    Posts
    458
    you can add your python progs path in sys.path in your script
    Code:
    import sys
    sys.path.append("/your/python/prog/path")
    import yourprog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...