can't find snap7 library - linux

◇◆丶佛笑我妖孽 提交于 2019-12-06 04:52:10

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:

  1. 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

  2. Unzip downloaded file
    in Pi command line:
    tar -zxvf snap7-full-1.2.1.tar.gz

  3. 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

  4. 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

  5. (optional) Install python pip if you don't have it
    in Pi command line:
    sudo apt-get install python-pip

  6. Install python wrapper for SNAP7 lib
    in Pi command line:
    sudo pip install python-snap7

You have not installed snap7 library that is why you have this problem.

In order to solve this problem I suggest you to install it in a proper way. What I describe below is a horrible hacky way, but I have not found time to make better.

For a quick fix you can

  • download this: http://sourceforge.net/projects/snap7/files/1.1.0/
  • unar it, and
  • in folder 'build/unix'
  • run command make -f x86_64_linux.mk all
  • then cp ../../build/bin/x86_64_linux /usr/local/lib/
  • then modify common.py in order to manually point to your '.so' file in 'init' function

I added this line at start of this function : lib_location = "/usr/local/lib/libsnap7.so"

Henk

I got a solution:

sudo chown -R $USER /usr/local/lib/python2.7/dist-packages/snap7

To give permissions to edit files in the snap7 library directory.

Then edit the complaining files, below the init with an additional line like this:

def __init__(self):
    lib_location='/usr/local/lib/libsnap7.so' # add this line here
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!