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
  Which app do I import to fix this error? ErnestTBass 6 347 Apr-26-2020, 08:43 PM
Last Post: snippsat
  Error while humansize module import. johnkgson 3 469 Apr-26-2020, 08:37 AM
Last Post: johnkgson
  Importing module from a package results in import error goghvv 2 285 Mar-27-2020, 07:13 PM
Last Post: goghvv
  Python 2.7 Import error. Directory and filename conflict petcoo00 2 272 Feb-02-2020, 08:46 PM
Last Post: snippsat
  Error in python code 'import callbot' Lou_Reed 3 369 Jan-07-2020, 09:33 PM
Last Post: Clunk_Head
  import error (unknown location) pseudo 1 2,282 Nov-14-2019, 11:47 PM
Last Post: pseudo
  import module error german77 4 1,527 Feb-28-2019, 02:29 PM
Last Post: german77
  Running pytest gives " 'cannot import name 'session' " error jasonblais 2 1,158 Oct-10-2018, 05:02 PM
Last Post: jasonblais
  Import Error Bravoseeker 3 2,640 Oct-05-2018, 03:00 PM
Last Post: Larz60+
  module import error bobsmith76 4 1,125 Sep-18-2018, 03:41 AM
Last Post: bobsmith76

Forum Jump:

Users browsing this thread: 1 Guest(s)