-
Use
virtualenv
andvirtualenvwrapper
for development of isolated environment.- You should have a basic working pip tool setup available.(Python2: pip2/ Python3: pip3)
Use the distributions package manager to install the pip tool. - Follow the step to install
virtualenv
andvirtualenvwrapper
:Note: You should have# Use pip2 or pip3 according to the availabilty. # Referenced here as `pip` pip install --user virtualenv virtualenvwrapper
$HOME/.local/bin
in your$PATH
environment variable. - Setting up a virtualenvwrapper environment:
# Setup following lines in your ~/.bashrc export WORKON_HOME=$HOME/apps/pyenv # Locate Python3 executable using this command: $ which python3 export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3 source ~/.local/bin/virtualenvwrapper.sh
- Creating a virtualenvironment:
# For default Python 3 Environment mkvirtualenv py3grip # Check Virtualenv Python version python --version pip install grip # For Python 2 Environment mkvirutalenv py2grip -p python2 # Check Virtualenv Python version python --version pip install grip
- Activating the environment:
workon py3grip
- De-activating the virtual environment:
deactivate
- You should have a basic working pip tool setup available.(Python2: pip2/ Python3: pip3)
NOTE: Refer the documentation of virtualenvwrapper for user-defined hooks for setting up a development environment for C/C++ Projects.
Old steps
3. Setting up a virtual environment for development:
**Only one python executable can be used for the virtual environment setup.**
```sh
# For Python2 Development
virtualenv -p /usr/bin/python2.7 my_project
# For Python3 Development
virtualenv -p /usr/bin/python3 my_project
```
4. Activating the virtual environment:
For Linux:
```sh
source my_project/bin/activate
```
For Windows:
```bat
.\my_project\Scripts\activate
```
5. De-activating the virtual environment:
```sh
deactivate
```
-
Simple and easy accessible webserver for quick file sharing.
# For python 2.x python -m SimpleHTTPServer <custom_port_number> # For Python 3.x python3 -m http.server
-
Simple Python
HTTPS Server
.#!/usr/bin/python # taken from http://www.piware.de/2011/01/creating-an-https-server-in-python/ # generate server.xml with the following command: # openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes # run as follows: # python simple-https-server.py # then in your browser, visit: # https://localhost:4443 import BaseHTTPServer, SimpleHTTPServer import ssl httpd = BaseHTTPServer.HTTPServer(('localhost', 4443), SimpleHTTPServer.SimpleHTTPRequestHandler) httpd.socket = ssl.wrap_socket (httpd.socket, certfile='./server.pem', server_side=True) httpd.serve_forever()
Note: For key and certificate generation kindly search online for better generation process.
Notes:
- By default port number is:
8000
. - The
HTTP Server
is unsecured!!!, anybody with network access can access the directory from where the script is started. - Kindly use it only on Private and Trusted Network.
List of Python libraries and tools:
NOTE: Use the virtualenvwrapper to create separate virtual environment for these libraries/tools as they might have conflicting dependencies.
Available as command line
pip install --user \
flask \
gdbgui \
grip \
jupyter \
matplotlib \
numpy \
scipy
- Securing the Jupyter NoteBook installation.
- Add Code for QRCode Generator.
- Add the Python API Tracer.
- ......
- Ctypes library for calling
C/C++
API's from python. - Simple example available in ctypes directory.
- flask_tutorial: An exploration of Flask Tool.
- Jinja2: An exploration of Templating Engine can be used along with Flask
- Mako: An exploration of another Templating Engine.