Make sure you haven’t previously built one. In this tutorial, I’ll demonstrate how to get from the command-line to the terminal.
First, create a virtualenv. I’m using the official GitHub release because it includes a nice terminal-friendly interface that’ll open the terminal from within your workspace. Open the terminal, create the new directory, and create a new project. In the terminal, type:
$ virtualenv python3 -v pip install pycairo python setup.py develop
It doesn’t matter what your working directory looks like; it’s all gonna be C, so you don’t have a lot of control of that. I have a virtualenv with just the required Python dependencies and virtual filesystem.
The next step involves setting up environment variables. Let’s assume that you’re starting with virtualenv. We’ll need these variables:
PYTHONPATH : Path to the Python interpreter. It can be set directly, by placing the virtualenv in the PATH variable, but I prefer using a path relative to the environment variable (e.g., /home//.virtualenvs/python3 ).
: Path to the Python interpreter. It can be set directly, by placing the virtualenv in the variable, but I prefer using a path relative to the environment variable (e.g., ). VIRTUALENV : A temporary directory you’ll use for development.
When you run a project, the command you are about to run will be located there. The command is specified in the virtualenv settings file. For example, the following line would be equivalent to running python3 .
virtualenv myenv myenv/develop
Now you can create a new project in your virtual environment. Let’s assume that myenv is virtualenv/myenv/develop . In the command prompt, run these commands:
$ myenv create myenv/myenv/test
You’re almost done! In order to execute your project, you’ll need a shell script to do the thing! Here’s what myenv/bin/test.py looks like:
import sys @__init__ def hello(): print “Hello ” + str(sys.argv) sys.exit(0) def greeting(): return “Goodbye ” + str(sys.argv) print “World, I see you” print “Goodbye!” if __name__ == “__main__