No module named config ошибка

I’m trying to run my project from terminal but I keep on getting ModuleNotFoundError: No module named 'config'. The structure of my project is:

Project folder
   -config
      -settings.py
   -folder1
     -folder2
        -pythonfile.py

While in folder1/folder2/ I run the script —> python3 -m pythonfile.py but I get the No module named config. The Run button from PyCharm works like charm but I want to run the script from terminal. Also I’ve checked the sys.path and I’ve got the root path of the project /home/name/Desktop/Project and the /home/name/Desktop/Project/folder1/folder2/.

Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/usr/lib/python3.6/runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "/home/name/Desktop/Project/folder1/folder2/pythonfile.py", line 4, in <module>
    from config import settings as CONFIG
ModuleNotFoundError: No module named 'config'

ModuleNotFoundError is an error you get when the python interpreter is unable to find the module in your system. If you are getting the error no module named config then in this post you will know all the solutions that can solve the error modulenotfounderror no module named ‘config’ error.

Why modulenotfounderror no module named ‘config’  error occurs?

The reasons for getting this error can be many. But the following are the main reason that gives you an error,

1. The config module is not installed in your system.

The first reason that leads to this error is that your system has not found the config module. You will get the modulenotfounderror when you try to import the config module.

import config

Output

Modulenotfounderror no module named 'config'

Solution

To solve this issue you have to install the config module in your system.

For python 3. xx

pip3 install config

For python 2. xx

pip install config

2. Typo error

The second reason you may get the error is that there must be a spelling error in the module. Most developers write conf instead of config and it leads to modulenotfounderror.

Solution

To solve this error you must ensure that you are correctly using the word config. Don’t import conf instead import config.

import config

3. The system is unable to find the python path

The third reason for getting this Modulenotfounderror no module named ‘config’ error is that the python path is not properly set. And due to this config module is not set in your path environment variables.

Solution

Open your terminal or command prompt and type the following command to set the path of the environment variable PYTHONPATH.

export PYTHONPATH="your/path/of/python"

config module pypi website

config module pypi website

Conclusion

The config module is used to store configuration information for applications. Most of the developer name the config file config.py. This makes it very easy to import settings when you are building a large application. If you are getting the Modulenotfounderror no module named ‘config’ error then the above methods will solve it.

I hope you have liked this tutorial. If you are still getting this error then you can contact us for more help.

Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

We respect your privacy and take protecting it seriously

Thank you for signup. A Confirmation Email has been sent to your Email Address.

Something went wrong.

Писал код для бота в Discord

import discord  # импортируем библиотеку дискорд
from aiohttp import payload
from discord import utils, member  # импортируем utils

import config  # импортируем конфиг-файл


class MyClient(discord.Client):
    async def on_ready(self):
        print('Sucsessfully logged as {0}!'.format(self.user))  # вход

    async def on_raw_reaction_add(self, payload):
        channel = self.get_channel(payload.channel_id)  # получаем объект канала
        message = await channel.fetch_message(payload.message_id)  # получаем объект сообщения
        member = utils.get(message.guild.members,
                           id=payload.user_id)  # получаем объект пользователя который поставил реакцию

        try:
            emoji = str(payload.emoji)  # эмоджи который выбрал пользователь
            role = utils.get(message.guild.roles, id=config.ROLES[emoji])  # объект выбранной роли (если есть)

            if (len([i for i in member.roles if i.id not in config.EXCROLES]) <= config.MAX_ROLES_PER_USER):
                await member.add_roles(role)
                print('[SUCCESS] User {0.display_name} has been granted with role {1.name}'.format(member, role))
            else:
                await message.remove_reaction(payload.emoji, member)
                print('[ERROR] Too many roles on {0.display_name}'.format(member, role))

        except KeyError as e:
            print('[ERROR]: KeyError, no role found for' + emoji)
        except Exception as e:
            print(repr(e))

    async def on_raw_reaction_remove(self, payload):
        channel = self.get_channel(payload.channel_id)  # получаем объект канала
        message = await channel.fetch_message(payload.message_id)  # получаем объект сообщения
        member = utils.get(message.guild.members,
                           id=payload.user_id)  # получаем объект пользователя который поставил реакцию

        try:
            emoji = str(payload.emoji)  # эмоджи который выбрал пользователь
            role = utils.get(message.guild.roles, id=config.ROLES[emoji])  # объект выбранной роли (если есть)

            await member.remove_roles(role)
            print('[SUCCESS] Role {1.name} has been deleted from {0.display_name}'.format(member, role))

        except KeyError as e:
            print('[ERROR]: KeyError, no role found for' + emoji)
        except Exception as e:
            print(repr(e))


# RUN
client = MyClient()
client.run(config.TOKEN)  # добавляем токен

запускаю демку
Выдаёт ошибку

Traceback (most recent call last):
  File "D:/загрузки/папки/Shadow.py", line 5, in <module>
    import config  # импортируем конфиг-файл
ModuleNotFoundError: No module named 'config'

I read the docs. If you do not create the config file you get this:

[i] Searching for footprints on web pages... (limit=10)
Traceback (most recent call last):
  File "./phoneinfoga.py", line 89, in <module>
    main()
  File "./phoneinfoga.py", line 70, in main
    scanNumber(args.number)
  File "./phoneinfoga.py", line 37, in scanNumber
    osintScan(number)
  File "/opt/PhoneInfoga/scanners/footprints.py", line 173, in osintScan
    for result in search(req, stop=10):
  File "/opt/PhoneInfoga/lib/googlesearch.py", line 22, in search
    if google_api_key and google_cx_id:
NameError: name 'google_api_key' is not defined

The error I reported is clearly about the module.
ModuleNotFoundError: No module named 'config'
If you do not install the config module you don’t even reach the point where the file config.py is read. Actually if you install the module the program runs.

In this tutorial, we will discuss the solutions on how to solve the no module named config?

Also, we will discuss What is config module in Python? and What is ModuleNotFoundError?

What is ModuleNotFoundError?

The ModuleNotFoundError is an error that will occur if the python interpreter cannot find the installed module in your computer.

When you are encountered this error no module named config.

Then in this tutorial you’ll be able to know the solutions to solve the error modulenotfounderror no module named ‘config’

Also, read the other error: Modulenotfounderror: no module named ‘tensorflow.python’

What is config module in Python?

The config module in Python can be used to create a custom-built Python.

For example, the Python configuration can be used in your environment variables and the command line arguments.

The Confined Configuration will be able to used to install Python into an application system.

Why modulenotfounderror no module named ‘config’  error occurs?

The reasons for this error occurs can be frequent. Yet, the following below are the common reason that provides you an error.

  • It is either the spelling is incorrect or the capitalization of the module name.
  • The config package it is hasn’t been installed in your python library.
  • Make sure to check the spelling name before installing the module.
  • The system cannot find the python path.
  • Assured that the config module is installed correctly in the virtual environment.
  • The config module is installed but it is installed at the incorrect path environment path.

How to solve the no module named config?

Time needed: 3 minutes.

To solve the no module named config, here are the solutions we will provide to solve the error no module name config.

  • Solution 1: Install config module in Python 2

    This is the command to install the config module in Python 2:

    pip install config

    After you type the command above, it will show the following output below:

    pip installed in Modulenotfounderror no module named 'config'

  • Solution 2: Install config module in Python 3

    The following command below is for the installation in config module for Python 3:

    pip3 install config

Conclusion

In conclusion, we have given the best way of solution to solve the error Modulenotfounderror: no module named ‘config’. If you encountered the no module named config the above solutions will solve it.

I hope this tutorial was helpful to you to solve your problem with the error. Contact us for extra assistance if you continue to experience this error.

  • No space left on device ошибка субд
  • No mans sky ошибка the game has encountered an error and will now shutdown
  • No selection available ошибка на ауди а6 с6
  • No mans sky ошибка 0xc0000142
  • No mans sky ошибка 0xc000007b