Python Help

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Quick Python Help - Prof. M.

Torres-Torriti
Department of Electrical Engineering
Pontificia Universidad Católica de Chile

Quick Python Help


/ Version 1.0 .

Contents
1. First: Install WinPython . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
2. Second: Install Useful Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
3. Third: Running Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
4. Fourth: Tips & Tricks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

1. First: Install WinPython

1. Install WinPython 3.5: http://winpython.github.io/


https://github.com/winpython/winpython/wiki/Roadmap

2. Unpack WinPython to some directory such as C:\WinPython35

3. Register WinPython so that Windows becomes aware of Python using the WinPython Control Panel.exe
in C:\WinPython35.

4. Add to the WinPython path to the system’s PATH variable:

(a) From the desktop, right-click My Computer and click Properties.


(b) In the System Properties window, click on the Advanced tab.
(c) In the Advanced section, click the Environment Variables button.
(d) Finally, in the Environment Variables window, highlight the PATH variable in the Systems Variable
section and click the Edit button. Add or modify the path lines with the paths you wish the
computer to access. Each different directory is separated with a semicolon as shown below:
C:\Program Files; C:\WinPython

For further information see also:

• See Scientific Python distribution recommendations:


https://www.scipy.org/install.html

• Should I use Python 2 or Python 3 for my development activity?


https://wiki.python.org/moin/Python2orPython3

R
https://www.python.org/downloads/

Did you know that.... . .


There exist complete system distributions equivalent to WinPython for Linux and Mac, such as Ana-
conda, Enthought Python Distribution, PythonXY, and Sage. Pick the one that suits you best and try
it.

2016.07.01 1
Quick Python Help - Prof. M. Torres-Torriti
Department of Electrical Engineering
Pontificia Universidad Católica de Chile Quick Python Help

2. Second: Install Useful Libraries

1. Download useful libraries not included in WinPython from:


http://www.lfd.uci.edu/~gohlke/pythonlibs/
Use the appropriate compiled version.
Useful libraries include:
pygame: pygame-1.9.2a0-cp35-none-win amd64.whl
control: control-0.7.0-py2.py3-none-any.whl

See also packages at: PyPI (Python Package Index) https://pypi.python.org/pypi

2. From the WinPython Control Panel, select Install/Upgrade Pacakges, then Add Packages. Once the
packages have been read, proceed with the install.

3. Third: Running Programs

Run Python code from a command window (e.g. PowerShell with administrator privleges) by typing either:
program_name.py
python program_name.py
or run Spyder and load the script and then run them using the interface buttons.

Some examples included in the WinPython installation can be executed with the following steps:

1. Start Menu/All Programs/WinPython/Jupyter Notebook. This will launch a Jupyter interface in your
default web browser.

2. Select ”docs” in Jupyter, and then select ”Begginer’s FAQ.ipynb” (the iPython Notebook file).

3. Select ”QT libraries Example”, and press play three times until # PyQtgraph (Scientific Graphics and
GUI Library for Python) import pyqtgraph.examples; pyqtgraph.examples.run()

4. The previous step should start a Window with pyqtgraph examples. Select any example, e.g. ”Basic
Plotting”, ”Demos/Optics”, or ”Demos/Verlet chain” and then ”Run Example” to visualize the results.

Check also the examples in:


Pygame examples —
C:\WinPython\python-3.5.1.amd64\Lib\site-packages\pygame\examples\ such as: glcube.py

Matplotlib examples —
http://matplotlib.org/examples/index.html

More links in: http://ipython.org/ and https://www.scipy.org/.

2016.07.01 2
Quick Python Help - Prof. M. Torres-Torriti
Department of Electrical Engineering
Pontificia Universidad Católica de Chile Quick Python Help

4. Fourth: Tips & Tricks

Google: python real time keyboard input.


The best option for real time keyboard input is PyGame:
http://stackoverflow.com/questions/34551340/python-real-time-keyboard-input
https://github.com/SavinaRoja/PyUserInput
https://sourceforge.net/projects/pyhook/
https://docs.python.org/2/library/msvcrt.html#console-i-o

Pygame Tutorials
Check your installation directories:
C:\WinPython\python-3.5.1.amd64\Lib\site-packages\pygame\docs\tut

ODE Integration
Google: matlab ode45 python
http://sys-bio.org/wp-content/uploads/2015/01/introMatlabPythonODEs.pdf
http://modelling3e4.connectmv.com/wiki/Software_tutorial/Integration_of_ODEs

SciPy: NumPy for Matlab Users


http://scipy.github.io/old-wiki/pages/NumPy_for_Matlab_Users.html

Time Measurement
Google: tic toc equivalent python
http://stackoverflow.com/questions/5849800/tic-toc-functions-analog-in-python
https://docs.python.org/3.5/library/time.html?highlight=time#time.process_time

Control Systems Library for Python


https://pypi.python.org/pypi/control/0.7.0
https://sourceforge.net/projects/python-control/
http://python-control.readthedocs.io/en/latest/
http://python-control.readthedocs.io/en/latest/intro.html#some-differences-from-matlab
http://python-control.readthedocs.io/en/latest/generated/control.tf.html#control.tf

Python Documentation
https://docs.python.org/3.5/
https://docs.python.org/3.5/library/index.html

2016.07.01 3

You might also like