Results 1 to 3 of 3

Thread: Python module import help?

  1. #1
    Join Date
    Nov 2012
    Beans
    2

    Post Python module import help?

    I have a folder on my desktop called game. in it it contains python files. I want to make a program that imports the files into the program and executes them, how would I do this?

  2. #2
    Join Date
    May 2008
    Location
    UK
    Beans
    1,450
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: Python module import help?

    Several ways of doing this :
    1. Copy the contents of your desktop folder into the folder containing your application. Pros - very simple. Cons - you get duplicates.
    2. Create a symbolic link of youir desktop folder into your application folder. Pros - reasonably simple and quick. No duplication. Cons - you have to do this for ever programe you want to write.
    3. Add the folder on your desktop into the PYTHONPATH environment variable. Pros - the recommended way of including extra modules in the search. Cons - you will need to edit your .profile or .bashrc to make the permanent change to your environment variable. Only applies to your user account.
    4. Copy the folder into one of the folders already included in PYTHONPATH. Pros - available for everyone on the system. Cons - Could contaminate other installed modules.

    I would go for option 3 - unless you need every users to have access to the modules - in which case go with option 4 - if you have a proper DEB installation package for the modules.

    If you go with option 3 - don't leave them on your desktop - too easy to loose them with a tidy up.
    Tony - Happy to try to help.
    Unless otherwise stated - all code posted by me is untested. Remember to Mark the Thread as Solved.
    Ubuntu user number # 24044 Projects : TimeWarp - on the fly Backups

  3. #3
    Join Date
    Nov 2012
    Beans
    2

    Re: Python module import help?

    Thank you sooooooo much!

Tags for this Thread

Bookmarks

Posting Permissions

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