Sunteți pe pagina 1din 6

Setting up 64-bit Windows7 PC for running

hal-4000 in dummy mode


Date: 25-08-2018

Notes:
Before setting up the hardware part of the microscope rig, being able to run the software without
hardware connected would verify whether the necessary dependencies are installed, and no files are
missing. The original python code runs on a Windows XP (the STORM PC). An updated version of the
storm-control code is available in the python2_pyqt4 branch of the Zhuang lab git repository.

Aim:
Make the hal-4000 code run without hardware connected, on a given 64-bit Windows7 PC (say, PC1)

Report:
20-08-2018
1. Windows 7 was installed in PC1. Here is a screenshot of system specs:

2. Python version 2.7.15 was installed from the official website. Downloaded the files and used
the windows installer package.
Link: https://www.python.org/downloads/windows/
21-08-2018
3. Edited the PATH environment variable to include the Python27 folder and subfolders, as
mentioned in this link so the interpreter can be run from any directory in the system.
Text to be added to the path:
C:\Python27;C:\Python27\Lib\site-packages\;C:\Python27\Scripts\;
To check the installation , open Command Prompt anywhere and type python

4. IDLE is the built-in IDE (Python GUI) that is used for editing scripts. Type help (“modules”) in
the Python Shell to view a list of all available modules.
22-08-2018
5. PyQt is a set of modules widely used for developing graphical interfaces that can be run on
various operating systems. Tutorials are available here . The installer package is found here .

6. There are 3 versions of hal-4000 saved in PC1 (D drive). Folder names are given below:
storm-control-python2_pyqt4_online (The latest version from github)
hal4000_10-11-12_receptorab (Email subject : receptor antibodies)
hal4000_03-27-12_fwd (Email subject : Fwd)

In all 3 folders, there is an INSTALL.txt file that specifies which dependencies are to be installed
and which c files are to be compiled. It is recommended to follow the instructions in the given
order instead of randomly installing dependencies and running the code each time.
7. The next step was to install MinGW. It was not mentioned whether the 32-bit or 64-bit version
was required. Since the official website was likely to be the most reliable source for
instructions, the files were downloaded from a link in the website. It was also mentioned that
all of MinGW’s software will execute on Windows 64-bit platforms. At this point , the role it
plays was not understood, and this caused problems later. (Meaning, installing 32-bit version
of MinGW was a mistake. DO NOT DO THIS)
The official site didn’t open in chrome, it opened in IE. Chose the automated installation. The
download link goes to Sourceforge. Installed the basic setup. Modified the PATH environment
variable by adding C:\MinGW\bin
To check installation, type gcc -v in Command Prompt (any location), the gcc version will be
displayed if MinGW is correctly installed.

23-08-2018
8. The python modules required were installed using pip. For example, typing in cmd :
pip install pywin32
will install pywin32 module.
Similarly, Numpy, Scipy, pywinusb, and Pillow were installed.
Pybluez cannot be installed, as it is meant for WindowsXP/Linux. Anyway we are not using
Bluetooth devices.
(Note: To open a cmd window in a specifiic directory, press shift then right click, and a menu
will appear)
9. Compile UI elements: Ideally, a newly extracted folder would contain a sub-folder named
qtdesigner, with only .ui files. By compiling these, .py files are produced.

The path of pyuic.py must be given. The format for compiling is as given in INSTALL.txt. It is
important to open the command window in that directory.
10. Compile C helper libraries : The mentioned C source files were compiled and this generated
an object file (.o) and .dll file for each.
Format: To compile example.c, navigate to that directory and type in cmd:
gcc -c example.c
gcc -shared
Since the 32-bit version of MinGW was installed, gcc produced 32-bit .dll files. 64-bit exes
cannot load 32-bit .dll files (and vice versa), since they cannot agree on the size of a pointer.
In this case, python is 64-bit and the .dll is 32-bit.
After completing all the steps in the INSTALL.txt file, including modifying the settings_default
xml file to set the software in dummy mode, the hal-4000 master code was run, and it
produced a set of errors.
Screenshots of errors encountered are given below:

Figure 1: Failed to load formatconverters


Figure 2: After bypassing the previous error, this is what we got

The pdb module is a good tool for troubleshooting/debugging in Python. Pdb.set_trace() will
help trace the source of errors in the code.
Note: The testing was done in folders receptorab and online. The online version had the Win32
error. Receptorab had an error related to image_log.txt. But when this was bypassed, it ended
up with the same Win32 error. In both cases, the cause of error was one of the C helper files,
andor\format_converters.c and focus_quality.c. And it was a dll error, python couldn’t access
the dll file. This is because all the compiled c source files produced 32-bit dlls.

The solution is to generate 64-bit dlls. For this, MinGW was uninstalled and mingw w64 was
installed.
To uninstall MinGW, go to it’s installation manager, and mark each green box for removal.
Then click Apply changes . After everything is removed, go to MinGW to verify whether gcc is
uninstalled. The bin folder will be mostly empty. Delete MinGW folder.
Site for downloading mingw w64 : https://sourceforge.net/projects/mingw-w64/files/
Choose the online installer.
During installation, select options :
Architecture : x86_64
Threads : win32
Exception : seh
Leave version and build revision as their default values.
Follow the wizard to complete installation.
Finally, edit the PATH to include the mingw w64 bin file. The final path, including some
changes made to the Python part:
C:\Python27;C:\Python27\Lib\site-packages\;C:\Python27\Lib\site-
packages\PyQt4\;C:\Python27\DLLs\;C:\Python27\Scripts\;C:\Python27\Lib\;C:\Python27\li
bs\;C:\Program Files\mingw-w64\x86_64-8.1.0-win32-seh-rt_v6-rev0\mingw64\bin\;

The gcc installation was checked, and the source files were compiled (for the online version
of hal-4000). This generated 64-bit dll files. The 32-bit ones were deleted. When hal-4000 was
run, it produced no errors, and ran in dummy mode.
Note: It is the ONLINE version that was finally run successfully in dummy mode, without errors.

Note : Before running the code, a folder was created in C:\ called Data and a subfolder named
logs.
Note: hal-4000 inside receptorab still shows the image_log.txt error.

S-ar putea să vă placă și