Python for Windows
Download Python
- https://www.python.org/download/
- by default, installs to c:\Python## where ## is version number, ex Python34
- installer updates/adds HKEY_LOCAL_MACHINE\SOFTWARE\PYTHON registry entry
Adding HKEY_CURRENT_USER Registry Entry
Some Python module installers look in the HKEY_CURRENT_USER registry entry for the Python settings so need
to get the info from there:
- http://choorucode.com/2012/04/28/python-version-not-found-in-registry-error/
- open regedit
- navigate to Computer->HKEY_LOCAL_MACHINE->SOFTWARE->Python->PythonCore
- right click 3.4->Export
- save as .reg file on your system, ex. c:\Users\yourname\python3.4.reg
- edit .reg file and change all HKEY_LOCAL_MACHINE to HKEY_CURRENT_USER
- open cmd box as administrator
- cd to where the .reg fiel was saved
- install using regedit command
- c:> regedit python3.4.reg
- keys should be successfully added to registry
- verify using that Computer->HKEY_CURRENT_USER->SOFTWARE->Python->PythonCore exists
- c:> regedit python3.4.reg
Python for Linux
Below are some Python libraries that I needed to download:
> sudo apt-get update
> sudo apt-get upgrade
> sudo apt-get
install
libpq-dev python-dev libjpeg-dev libpng-dev
Python Common
Installing Python Modules
Module install can be done using pip or by double clicking the module if it is an installer.
Python Communities
Python Coding Guidelines
Pep8 is the coding convention guideline for Python. There are different command line tools and IDE tools that can be used to help enforce the guidelines.
- pep8.py and autopep8.py are 2 modules that can be used
- PyDev (eclipse plugin) can be configured to use pep8
- in eclipse, go to Window->Preferences->PyDev->Editor->Code Analysis
- select pep8.py tab
- choose the radio button for warning and click Ok
- http://pep8online.com/
- browser based python code checker
- go to the url, paste in your code, see the code guideline violations
PyDev
PyDev is a Python IDE for Eclipse, which may be used for Python, Jython and IronPython development. It supports code creation, code refactoring, graphical debugging, code analysis and many other features.
Below are some helpful links:
- Python Development with PyDev Tutorial - a quick simple tutorial by Lars Vogella
In order to use PyDev, you must have Python (3.4) and Eclipse (Kepler or Luna) installed. This page assumes both are already installed.
PyDev Install
PyDev is a Python IDE for Eclipse, which may be used for Python, Jython and IronPython development. It supports code creation, code refactoring, graphical debugging, code analysis and many other features.
Below are some helpful links:
- Python Development with PyDev Tutorial - a quick simple tutorial by Lars Vogella
In order to use PyDev, you must have Python (2.7/3.4) and Eclipse (Kepler or Luna) installed. This page assumes both are already installed.
- install eclipse pydev plugin
- open eclipse -> Help -> Eclipse Marketplace...
- type Python in Find: box and hit enter
- in PyDev -Python IDE for Eclipse, click Install
- accept license and install
- configure Python install location in eclipse
- Window -> Preferences -> PyDev -> Interpreters -> Python Interpreter
- Press the New... button and enter Interpreter Name and path to your python.exe
- click OK, then click OK again on the System PYTHONPATH dialog box and OK on the Python Interpreters dailog box
- Window -> Preferences -> PyDev -> Interpreters -> Python Interpreter
Configure PyDev to use pep8
- in exclise, go to Window->Preferences->PyDev->Editor->Code Analysis
- select pep8.py tab
- choose the radio button for warning and click Ok
Unresolved Import Errors
Problem:
Imports cause compile errors even when path to module is appended to the sys path:
Solution:
- make sure any folders with modules you want to import has an __init__.py
- __init__.py file makes the folder a Python package which makes all modules in the package accessible via import statements
- right click your pydev project and select Properties
- select PyDev - PYTHONPATH -> External Libraries
- select Add source folders (any folder that has an
__init__.py
) and add any source files you want your project to have access to - click OK
- restart eclipse for change to take effect (File -> Restart)
- your project code will then be able to import modules from those source folders.
No comments:
Post a Comment