Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Nanpy import error
I've got an odd error when using nanpy. If I open a session of Python, and then load my module and run it, it works fine. If I try and load my module via the terminal (or SSH), I get an import error.

ImportError: no module named nanpy
And where it's getting stuck is the first line!

from nanpy import (ArduinoApi, SerialManager)
Any ideas why it works in one and not the other?
Then there is a difference with your environment. Are you using a virtual environment?
Have you activated it?
Maybe you are using the wrong Python version.

To check it, just make one file with following content:

import sys

print('Executable:', sys.executable)
print('Module paths:')
Call it one time direct, then over ssh.
Can you see a difference?

You can also import nanpy with your working environment and print(nanpy.__file__).
Then you know the exact path of the module. It should be in site-packages.
dist-packages is from the linux distribution itself.

Just try this show us the output.
My code examples are always for Python >=3.6.0
Almost dead, but too lazy to die:
All humans together. We don't need politicians!
Ok, so from a python session:

Executable: /usr/bin/python3
Module paths:

then from ssh

('Executable:', '/usr/bin/python')
Module paths:

Ahhh. Which would be different (same if ran from terminal).

So, how do I get both to be the same?

Wait, I've figured it....


rather than type "Python ...."
type "python3....."

And then it works!

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  import error (unknown location) pseudo 1 202 Nov-14-2019, 11:47 PM
Last Post: pseudo
  import module error german77 4 624 Feb-28-2019, 02:29 PM
Last Post: german77
  Running pytest gives " 'cannot import name 'session' " error jasonblais 2 720 Oct-10-2018, 05:02 PM
Last Post: jasonblais
  Import Error Bravoseeker 3 1,650 Oct-05-2018, 03:00 PM
Last Post: Larz60+
  module import error bobsmith76 4 834 Sep-18-2018, 03:41 AM
Last Post: bobsmith76
  Invalid Syntax Error on Import arjunsingh2908 3 5,197 Jul-07-2018, 05:02 PM
Last Post: ichabod801
  Import error when trying to import DDE (part of PyWin32) fbicalho 0 1,132 Apr-21-2018, 07:26 PM
Last Post: fbicalho
  python import sybpydb error: DLL load failed: The specified module could not be found andieDu 3 2,502 Apr-04-2018, 06:58 AM
Last Post: Larz60+
  CSV unable to import (traceback error) learnermarx 3 2,168 Feb-09-2018, 03:24 PM
Last Post: buran
  error in import numba Sara 1 2,894 Oct-22-2017, 08:07 PM
Last Post: metulburr

Forum Jump:

Users browsing this thread: 1 Guest(s)