Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time



how to create a python module.

this is a tutorial by aarón montoya-moraga. it is based on classes i took at nyu itp.


python modules are collections of functions, that live on a single .py file, and can be imported in other python scripts, using import.

your module should live on one .py file. i suggest using github to have a verson control system and online backup.

create a file, that includes:

  • name
  • version
  • url
  • author
  • description
  • license
  • packages
  • install_requires
  • package_data

to distribute, do on terminal

python sdist
twine upload dist/name-x.y.z.tar.gz

installing python modules

we will use two python modules to install other modules: pip and virtualenv. pip is the recommended tool for installing python packages.

first, install pip and virtualenv globally on your machine.

when you want to use python on your software project, we will create a virtual environment where all the python dependencies will live. go to your terminal and create a virtualenv with the command-line-tool virtualenv.

in this example, we will call env our virtual environment

virtualenv env

to make the python interpreter aware of this virtual environment, we have to activate it

source env/bin/activate

your terminal should now say (env) at the beginning of each new line. this means that the environment is activated.

to install packages on this virtual environment, use pip install.

in this example we will be installing numpy

pip install numpy

when you want to quit the virtual environment, deactivate it




  • allison parrish: for making me learn and love python and computer-generated poetry, for her great classes.
  • sam lavigne: for making me appreciate software libraries as art, for his great tutorials.


how to create a python module



No releases published


No packages published
You can’t perform that action at this time.