954,557 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Importing modules

Hi, everyone! I'm new to python, and I'm having a few issues getting started with writing useful code on mac OSX.

I'm wanting to import a module, either wx or pygtk for GUI, but in either case I get the error that there is no such module. As far as I know, I have installed them correctly.

However, typing in help('modules') into IDLE shows no module for wx or anything else.

How can I go about finding where these modules are installed, and how can I let python know? Also, how can I set the current version of python for my machine?

Any help would be greatly appreciated; I have been at it for hours. :-/

Thanks!

Member 785010
Newbie Poster
2 posts since Jan 1970
Reputation Points: 10
Solved Threads: 0
 

you can search for the modules in the file search. It seems like a path problem.

Beat_Slayer
Posting Pro in Training
405 posts since Jun 2010
Reputation Points: 30
Solved Threads: 105
 

Ok, so I search pygtk and a number of folders come up. Could you be a little more specific as to what a "path" problem is? How do I modify the path, and in what way so that it includes the desired module?

Member 785010
Newbie Poster
2 posts since Jan 1970
Reputation Points: 10
Solved Threads: 0
 

You should revisit your install and see what went wrong there, I never work on Mac, but this will make a fix.

A slightly less convenient way is to edit the site.py file in Python’s standard library, and modify sys.path. site.py is automatically imported when the Python interpreter is executed, unless the -S switch is supplied to suppress this behaviour. So you could simply edit site.py and add two lines to it:

import sys sys.path.append('PATH_TO_MODULES')

Resource

Not the doc I was searching but it serves your needs.

Beat_Slayer
Posting Pro in Training
405 posts since Jun 2010
Reputation Points: 30
Solved Threads: 105
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: