0

I have recently installed whois.

When I try to import the whois module in a .py file I get a ModuleNotFoundError. However, when I give the import command in a Python shell the problem does not occur, and the module imports as expected. Each time I am using the same command:

import whois

When using the shell I can get more information about the location the module was imported from:

import whois
whois
<module 'whois' from 'C:\\Users\\Name\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\whois\\__init__.py'>

Why would a python shell in the same directory as the .py file have different behavior than said file? hat can I do to rectify it?

Frank Fanelli
  • 321
  • 1
  • 3
  • 19
  • Please [edit] your question to show `sys.path` in the failed instance and information about where exactly the module is installed. – tripleee Aug 03 '19 at 13:32
  • So figure out why `C:\\Users\\Name\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages` is not in `sys.path`, and probably show how exactly you invoke Python when you get that. – tripleee Aug 03 '19 at 13:39
  • If you have multiple pythons installed, then you likely have whois installed for just one of them. If it is the same python binary (`print(sys.executable)`), then path needs to be examined. – Terry Jan Reedy Aug 03 '19 at 20:34
  • "I have recently installed whois." You may want to start by explaining how you installed it exactly... – Patrick Mevzek Aug 05 '19 at 22:07

1 Answers1

0

Try

from .folder import whois

if doesn't work - try to create in that folder empty file __init__.py, restart ide or what and try again

Green Joffer
  • 580
  • 1
  • 4
  • 16