this was printed by a cgi program
$ENV{HTTP_HOST}=inst.eecs.berkeley.edu
$ENV{SERVER_NAME}=inst.eecs.berkeley.edu
Content-type: text/html
EECS Instructional public documentation

[
ISG home page
] [
who we are
] [
send us email
] [
search
] [
FAQ
]
University of California at Berkeley
Department of Electrical Engineering & Computer Sciences
Instructional Support Group
/share/b/pub/python.help
/share/b/pub/anaconda.help
/share/b/pub/conda.help
Apr 14 2023
CONTENTS
Python on the Instructional computers
Python on the Instructional WEB server
CVX for Python
Numpy and SciPy
Anaconda
Pycharm IDE
Jupyter Notebook
Boto3
Selenium
Python on the Instructional computers
-------------------------------------
Python is available on:
/usr/bin/python (Linux systems)
/usr/bin/python3 (Linux systems)
The versions may be different; type "python -V" to see the version.
Python mode for Emacs (python-mode.el) is available on our MacOSX
systems in Applications/Aquamacs.app/Contents/Resources/lisp/aquamacs/edit-modes/python-mode/python-mode.el
To find our computers, please see
https://inst.eecs.berkeley.edu/connecting.html#labs
Python on the Instructional WEB serveVr
--------------------------------------
To run Python scripts via the https://inst.eecs.berkeley.edu WEB server,
you can run them as *.cgi programs. The first line of your Python script
would be
#!/usr/bin/python
or
#!/usr/bin/python3
For details about running CGI programs on our WEB server, please see
https://inst.eecs.berkeley.edu/setup.html#cgi
CVX for Python
--------------
CVX (http://www.stanford.edu/~boyd/cvx/) is a Matlab-based modeling system
for convex optimization that also runs via Python. cvxmod libraries are
installed on our Linux computers.
To use them in Matlab, you can type (using the commands 'cvx_setup'
and 'quickstart' for example):
cd /share/instsww/pkg/matlab-xtra/cvx/
cvx_setup
cd /share/instsww/pkg/matlab-xtra/cvx/examples/
quickstart
or
run /share/instsww/pkg/matlab-xtra/cvx/cvx_startup.m
run /share/instsww/pkg/matlab-xtra/cvx/examples/quickstart.m
Two sample scripts in Python:
#!/usr/bin/python
# Must run this where cvxmod libraries are installed
from cvxmod import *
from cvxmod.atoms import log
A = randn(50, 8)
b = rand(50, 1)
x = optvar('x', 8)
p = problem(maximize(sum(log(b - A*x))))
p.solve()
print value(min(b - A*x))
printval(x)
#!/usr/bin/python
# Must run this where cvxmod libraries are installed
from cvxmod import *
from cvxmod.atoms import *
from cvxmod.sets import *
A = randn(10, 5)
b = randn(10, 1)
x = optvar('x', 5)
p = problem(minimize(norm1(A*x - b)), [x >= -0.5])
p.constr.append(x |In| probsimp(5))
p.solve()
print "Optimal problem value is %.4f." % p.value
printval(x)
Numpy and SciPy
---------------
NumPy is a Python library for scientific computing. The core of the NumPy
package is a multidimensional array object called ndarray.
SciPy is a collection of mathematical algorithms and convenience functions
built on the Numpy extension for Python. (see http://docs.scipy.org)
Numpy and Scipy are installed on the Ubuntu Linux machines:
in
/usr/lib/python2.7/dist-packages/numpy/
/usr/lib/python3/dist-packages/numpy/
/usr/lib/python2.7/dist-packages/scipy/
/usr/lib/python3/dist-packages/scipy/
Anaconda
--------
Anaconda (https://www.anaconda.com) is a Python
distribution for large-scale data processing, predictive analytics,
and scientific computing. It includes versions of Python 2 and
Python 3, conda (a package and environment manager) and Jupyter
Notebook (a web app for creating and sharing code and documents).
It is installed in
/share/instsww/anaconda3 on all our Linux systems
Before using Anaconda, activate with UNIX bash shell command:
source /share/instsww/anaconda3/bin/activate
e.g.
conda --help
jupyter notebook
Pycharm IDE
-----------
PyCharm is an Integrated Development Environment (IDE) for Python, from
https://en.wikipedia.org/wiki/JetBrains. It is installed for all our
Linux systems in /share/instsww/pkg/pycharm/. Start it with
/share/instsww/pkg/pycharm/bin/pycharm.sh
Jupyter Notebook
----------------
The 'jupyter-notebook' command is in /share/instsww/anaconda3/bin on our
Linux systems.
EECS Instructional Support
378/386 Cory, 333 Soda
inst@eecs.berkeley.edu