ImportError: No module name 'conf'

I imported conf
but I am getting an
ImportError: No module named 'conf’

also I am getting
AttributeError: module 'conf' has no attribute 'API_KEY'

type
sudo nano conf.py
this will open conf.py file
and correct the spelling of API_KEY

conf%20error-2

the spelling of API_KEY is correct

Hi @akif.iqbal,

Can you share the screenshot of your latest code? Also, share the screenshot of the error?

Hey @akif.iqbal,
conf is not a python module. It’s a python file that the user creates to store some confidential details that he/she doesn’t intend to share with the public such as SID, AUTH_TOKEN, API_KEY. Hence we store these details in a separate file(conf.py) and import it to our main program file.

Hope this helped you :slight_smile:

Sir,

below is the latest code:

and the error:
error

Hi @akif.iqbal,

it’s odd,
Ok Lets type the below command and send me the screenshot of the outout. (listing)
ls

Again type the below command and attach the screenshot. (Blur some part of the key)

sudo cat conf.py

Then use the python terminal and run the below commands and send me the screenshot of the output.

sudo python3
import conf
print (conf)
print dir(conf)
print (conf.API_KEY)

Do let me know in case you need any other information.

1 Like

Sir,
Here are the screenshots,

  1. ls
    ls

  2. sudo cat conf_sms.py
    py

3)import conf

Hi @akif.iqbal,

As you can see in the ls command there is no conf.py file in your directory. You have created the file with the name conf_sms.py.

Copy the conf_sms.py file to conf.py by typing the below command.

sudo cp conf_sms.py  conf.py

Do let me know in case you need any other information.

1 Like

Thank You very much sir for solving this issue

The code works and I am receiving the SMS!

1 Like