0

I am new to Python and am trying it for an automation project of mine. I am trying to use a 64-bit python (version 3.5.3) on windows 10 (64-bit). I have copied the .dll and .lib files of snap7 for win 64-bit into my Python Path which is added to my system path.I have downloaded the python-snap7 wrapper version 0.8

But despite all this, I am getting an import error: No module named snap7.

I did follow all that was said in the link below too. But nothing seems to work.

python snap7 windows - can't find snap7 library

Any help would be appreciated.

Edit: When I tried installing snap7 using pip..I got this error

>>> python -m pip install python-snap7
  File "<stdin>", line 1
    python -m pip install python-snap7
                ^
SyntaxError: invalid syntax
>>>

Traceback:

Traceback (most recent call last):
  File "C:\Users\Vrinda\Desktop\1.py", line 1, in <module>
    import snap7
ImportError: No module named 'snap7'

Solution: I had to install it from Command window..not python interpreter

Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614
vrindakm
  • 23
  • 1
  • 6
  • Why don't you install it using pip? `pip install python-snap7` – Ravi Kumar Apr 05 '17 at 06:46
  • 1
    Could you post stack trace? Which error are you getting? – Ravi Kumar Apr 05 '17 at 07:26
  • Just copy paste it as text and then select it and click on the braces on the question editor. Look at this question http://stackoverflow.com/questions/338768/python-error-importerror-no-module-named?rq=1 for example. – Ravi Kumar Apr 05 '17 at 07:55
  • Thank you @RaviKumar!..I took some time to figure out some trivial stuff but using pip worked :) – vrindakm Apr 05 '17 at 08:50

1 Answers1

0

If you installed Python from the official Microsoft Store, the pip installer is included. You need just to paste pip install python-snap7 in the command line, as Ravi Kumar said.

If you are using Visual Studio Code and get the warning, "Import "[module]" could not be resolvedPylance (reportMissingImports)", then just restart VS Code.

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83