I'm running Rapbian on a Raspberry Pi Revision B.
I downloaded the module python-snap7 as instructed on this webpage: Snap7 Installation
I tried it twice: One time using pip and another doing it manually.
However, I installed it then via setup.py build
and then setup.py install
.
If i try to create a client, I get the following error:
Python 2.7.3 (default, Mar 18 2014, 05:13:23)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import snap7
>>> c = snap7.client.Client()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/snap7/client.py", line 29, in __init__
self.library = load_library()
File "/usr/local/lib/python2.7/dist-packages/snap7/common.py", line 48, in load_library
return Snap7Library(lib_location).cdll
File "/usr/local/lib/python2.7/dist-packages/snap7/common.py", line 40, in __init__
raise Snap7Exception(msg)
snap7.exceptions.Snap7Exception: can't find snap7 library. If installed, try running ldconfig
I did the following after getting this error:
I added some lines to the file so it looks like the following:
include /etc/ld.so.conf.d/*.conf
include /usr/local/lib/python2.7/dist-packages/snap7-full-1.2.1/
include /usr/local/lib/python2.7/dist-packages/snap7-full-1.2.1/release/Linux/ARMHF/Raspberry/
include /usr/local/lib/python2.7/dist-packages/snap7-full-1.2.1/src/lib/
include /usr/local/lib/python2.7/dist-packages/snap7-python/build/lib.linux-armv6l-2.7/snap7/
include /usr/local/lib/python2.7/dist-packages/snap7-python/
Then I issued the command sudo ldconfig
to update the cache file /etc/ld.so.cache
, but the error stays :(
include
instruction in fornt of each line?Sorry for my english and thanks in advance!
Looks like you didn't install SNAP7 library (it's not included in python-snap7)
To use snap7 library on Raspberry Pi with python-snap7 wrapper you need to do followed steps:
Download SNAP7 library
for example: snap7-full-1.2.1
in Pi command line:
wget http://sourceforge.net/projects/snap7/files/1.2.1/snap7-full-1.2.1.tar.gz/download
Unzip downloaded file
in Pi command line:
tar -zxvf snap7-full-1.2.1.tar.gz
Compile library for raspberry (arm_v6_linux.mk
is used for RPI 1. For RPI 2 use arm_v7_linux.mk
)
in Pi command line:
cd snap7-full-1.2.1/build/unix && sudo make -f arm_v6_linux.mk all
Copy compiled library to lib
directories
in Pi command line:
sudo cp ../bin/arm_v6-linux/libsnap7.so /usr/lib/libsnap7.so
sudo cp ../bin/arm_v6-linux/libsnap7.so /usr/local/lib/libsnap7.so
(optional) Install python pip if you don't have it
in Pi command line:
sudo apt-get install python-pip
Install python wrapper for SNAP7 lib
in Pi command line:
sudo pip install python-snap7