Link to home
Start Free TrialLog in
Avatar of FrancisSong
FrancisSong

asked on

CRC in python


I would like to write python code to check CRC for a given binary file to find any changes.

I think there is module in python which is crcmod but I do no know how to use it.

So could you please help?
Avatar of HonorGod
HonorGod
Flag of United States of America image

The crcmod is available here: http://pypi.python.org/pypi/crcmod/1.7

Have you installed it?

The test directory under ...\crcmod-1.7\test contains two files:

examples.py
test_crcmod.py

As seen on the module page, you can verify installation using:

python test_crcmod.py

The examples.py can be executed like this:

python examples.py

To create an examples.c file using the code generator method.

Have you read the first two paragraphs on the package page?
Avatar of FrancisSong
FrancisSong

ASKER


The problem is when I tried to install it, it gives me an error:

[root@localhost ~]# python setup.py install
python: can't open file 'setup.py': [Errno 2] No such file or directory
[root@localhost ~]#

-------------------
I have tried to download the crcmod-1.6 package from the internet and i put it under the root:

[root@localhost ~]# cd /root/crcmod-1.6
[root@localhost crcmod-1.6]# make
make: *** No targets specified and no makefile found.  Stop.
[root@localhost crcmod-1.6]# ls -l
total 36
-rw-r--r-- 1 1000 1000  545 2010-01-24 17:31 changelog
drwxr-xr-x 2 1000 1000 4096 2010-01-24 17:31 crcmod
drwxr-xr-x 5 1000 1000 4096 2010-01-24 17:31 py3
-rw-r--r-- 1 1000 1000 5921 2010-01-24 17:31 README
-rw-r--r-- 1 1000 1000  342 2010-01-24 17:31 setup.py
-rw-r--r-- 1 1000 1000  216 2010-01-24 17:31 setup_py.py
drwxr-xr-x 2 1000 1000 4096 2010-01-24 17:31 src
drwxr-xr-x 2 1000 1000 4096 2010-01-24 17:31 test
cd test
[root@localhost test]# python setup.py install
python: can't open file 'setup.py': [Errno 2] No such file or directory
[root@localhost test]#
Ah.  You need to be in the untar'd directory containing the setup.py

cd /root/crcmod-1.6
python setup.py install

it gave me this error:

[root@localhost home]# cd /root/crcmod-1.6
[root@localhost crcmod-1.6]# python setup.py install
running install
error: invalid Python installation: unable to open /usr/lib/python2.6/config/Makefile (No such file or directory)
[root@localhost crcmod-1.6]#
what is the result of typing:

which python

[root@localhost crcmod-1.6]# which python
/usr/bin/python
Install python-dev (package with Python header files needed for compilation c extension modules ; you will also need c compiler ;)
Instead of this error message:

error: invalid Python installation:

I think that a more accurate and helpful one would have been:

error: incomplete or partial Python installation:

I think that mish33 is probably right in that you'll have to have a complete installation of Python 2.x in order to get the crcmod to install.
ASKER CERTIFIED SOLUTION
Avatar of pepr
pepr

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial