Archived entries for Python

Windows 7 64 bit Python 2.7 Installation

Python 2.7  64

http://www.python.org/ftp/python/2.7.2/python-2.7.2.amd64.m

Create PYTHONPATH variable:

  1. Start -> Right click on ‘Computer’ and select ‘Properties’ ->  Advanced system settings -> ‘Environment Variables’
  2. Under ‘System variables’, click ‘New…’
  3. Variable name: PYTHONPATH
  4. Variable value: c:python27;c:python27dlls;c:python27lib;c:python27liblib-tk

Append PYTHONPATH to PATH variable:

  1. Start -> Right click on ‘Computer’ and select ‘Properties’ ->  Advanced system settings -> ‘Environment Variables’
  2. Under ‘System variables’ find ‘Path’
  3. Highlight and select ‘Edit…’
  4. Add ‘;%PTYHONPATH%’ to the end.

setuptools

http://peak.telecommunity.com/dist/ez_setup.py

ez_setup.py adds ‘easy_install’ to c:python27scripts, you must tell your command line where to find it if you want to run the ‘easy_install’ command.  You can either append it to your ‘PYTHONPATH’ variable (see above) or append it to your ‘Path’.

  1. Start -> Right click on ‘Computer’ and select ‘Properties’ ->  Advanced system settings -> ‘Environment Variables’
  2. Under ‘System variables’ find ‘PYTHONPATH’ (or ‘Path)
  3. Highlight and select ‘Edit…’
  4. Add ‘;c:python27scripts’ to the end.

pyserial 64

http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyserial

scipy 64

http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy

numpy 64

http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy

matplotlib 64

http://www.lfd.uci.edu/~gohlke/pythonlibs/#matplotlib

openpyxl

‘easy_install openpyxl’ from your command line, this is not to be confused with your python command line. You must have setuptools installed, see above.

xlrd

http://pypi.python.org/packages/source/x/xlrd/xlrd-0.7.1.zip#md5=851bd20873224d97cfb5ccca2d22b81c

Beautiful Soup

Great for screen scraping.

http://www.crummy.com/software/BeautifulSoup/download/3.x/BeautifulSoup-3.2.0.tar.gz

Install with ‘setup.py install’ from a standard windows command prompt within the Beautiful Soup folder that contains the setup.py file .

mechanize

Python web browser with HTML parsing.

http://wwwsearch.sourceforge.net/mechanize/download.html

Install with ‘easy_install mechanize’ from your windows command prompt.

 

 

 

python-congress

python-congress is simple Python function that returns an Excel .xlsx file of the U.S. House of Representatives Roll Call Votes  for a given year.

The function accesses the Roll Call XML data provided by the Clerk of the House through their website, it then parses the data and arranges it by Roll Call number and Representative, then dumps it to a Excel file (.xlsx).

For example,  112_Congress_Roll_Call_Data is data for the current 112th Congress up to the 770 Roll Call.

Required for Use

Python Dependencies

The following are the Python modules python-congress requires.  For more information on installing modules, see the Python 2.7.2 documentation on the subject.

urllib and datetime are included in the Python 2.7.2 Standard Library, the BeautifulSoup and openpyxl will need to downloaded and installed.  The easiest way to go about this is to download the module, install with Python setup.py install .  You will  need Python 2.7.2 set  in your PATH variable and the  setuptools module to do this.

If you need help installing the dependencies, reference the installation notes.  Note however the links in the article are only for 64 bit distributions and will not work for 32 bit machines.

Use

Download and install all the dependencies required to run the script as listed above.  Place a copy of congress.py in the ‘Lib’ directory of your python install, most likely it is: C:\Python27\Lib   

Open your python terminal, type in:

>>>import congress

>>>congress.roll_call_to_xlsx(2012)

The script will then run through each Roll Call and then add them to an Excel workbook.  Once finished, you can find the workbook in the main Python folder, most likely: C:\Python27

 

Pronterface on Windows 7 64 bit

While working on getting Pronterface up and running as a front end for my RAMPS 1.3  based Mendel, I ran in to a bit of a snag involving the number of bits on my machine (Windows 7, 64 bit).

Kliment (Pronterface author) provides great instructions for installing the dependencies  on different platforms, I have reprinted the windows set here:

Download the following, and install in this order:

  1. http://python.org/ftp/python/2.7.2/python-2.7.2.msi
  2. http://pypi.python.org/packages/any/p/pyserial/pyserial-2.5.win32.exe
  3. http://downloads.sourceforge.net/wxpython/wxPython2.8-win32-unicode-2.8.12.0-py27.exe
  4. http://launchpad.net/pyreadline/trunk/1.7/+download/pyreadline-1.7.win32.exe

These dependencies are geared towards a 32 bit install of Python 2.7.2 however I already had a 64 bit installation.  I searched for 64 bit versions of the other dependencies but could only find one for wxPython.  So, for pyserial and pyreadline I downloaded the source and compiled the modules with Python setup.py install.

With dependencies installed, I ran python pronterface.py and the GUI popped up however I couldn’t connect to the printer.  I received the following error “SerialException: WriteFile failed ([Error 6] The handle is invalid.) in the command line whenever I pressed ‘Connect’:

SerialException: WriteFile failed ([Error 6] The handle is invalid.)I did some research and quickly found a post for using Pronterface with 64 bit Windows 7.  Two options are presented in the post;  1. a precompiled Pronterface for Windows and 2. using all 32 bit Python modules and distributions.  The precompiled version didn’t work for me (other errors) and I didn’t like the idea of running a 32 bit version of Python 2.7.  I did a bit more googling for a solution, and found a pyserial specific post for 64 bit platforms.  The fix outlined in the post is to modify the serialwin32.py file in the pyserial source.  I made this modification and luckily this worked.

Incorporating the fix, the dependency installation  instructions for a Pronterface Windows 7 64 bit platform is as follows:

  1. Download and install Python 2.7.2 64 bit: http://www.python.org/ftp/python/2.7.2/python-2.7.2.amd64.msi
  2. Download the source, http://pypi.python.org/packages/source/p/pyserial/pyserial-2.5.tar.gz#md5=34340820710239bea2ceca7f43ef8cab,to unpack the tar.gz  I recommend 7-Zip.  You will need to modify the serielserialwin32.py according to the post or you can download it: serialwin32.  Next, compile the module with Python setup.py install.  You may also need to install the pywin32 module and other missing modules.
  3. Download and run wxPython 64 bit: http://downloads.sourceforge.net/wxpython/wxPython2.8-win64-unicode-2.8.12.1-py27.exe
  4. Download and compile the source for pyreadline with Python setup.py install: http://launchpad.net/pyreadline/trunk/1.7/+download/pyreadline-1.7.zip

You will probably have to close any open command line windows and perhaps even restart your machine to get everything set.  Let me know if you have any problems.



Copyright © 2011. All rights reserved.

RSS Feed.