Python modules

IDE
IDLE is the standard python IDE included with every python installation.

Modules
Python uses sys.path to look for modules, it includes the contents of PYTHONPATH. We can check the current contents of sys.path from IDLE through File > Path Brower, or by the following command:

import sys
sys.path

To load modules from different locations into IDE we can issue the following command:

sys.path.append('C:\\Users\\<user>\\your-python-libs')

Note the escaped backslashes, otherwise we will receive ‘Unicode Error‘.

After this we can import ay module from the added location.

If we are on Unix\Linux we can use the following technique to append entries to PYTHONPATH on command line:

PYTHONPATH=/foo/bar/baz python somescript.py somecommand

Source:

http://stackoverflow.com/questions/4580101/python-add-pythonpath-during-command-line-module-run

Advertisements
Tagged with:
Posted in Python

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: