Frank Fanelli
Frank Fanelli

Reputation: 351

Can't import whois in .py file, but can in shell

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?

Upvotes: 0

Views: 192

Answers (1)

Green Joffer
Green Joffer

Reputation: 820

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

Upvotes: 0

Related Questions