Categories: python, django, windows, conda, cmder

No module named 'settings_general' when module exists

1 answer

When I run manage.py in my terminal, I am getting the error ModuleNotFoundError: No module named 'settings_general'. But, this module does exist in the project in a subfolder. I've ran this manage.py many times, but on mac. And now that the pandemic is occurring I am working from home and am working on a PC with Windows 10. I am using cmder for my terminal and conda for my virtual environment. Any suggestions on how to solve this issue would be greatly appreciated.

Note: This is worked on with a team and there should not be changes made to the file hierarchy or the contents of the file.

Here's my traceback for running "python manage.py migrate":

C:\Users\user\work\urec (master -> origin) (urec) λ python manage.py migrate Traceback (most recent call last):   File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\django\core\management\base.py", line 328, in run_from_argv     self.execute(*args, **cmd_options)   File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\django\core\management\base.py", line 366, in execute     self.check()   File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\django\core\management\base.py", line 392, in check     all_issues = self._run_checks(   File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\django\core\management\commands\migrate.py", line 63, in _run_checks     issues = run_checks(tags=[Tags.database])   File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\django\core\checks\registry.py", line 72, in run_checks     new_errors = check(app_configs=app_configs)   File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\django\core\checks\database.py", line 9, in check_database_backends     for conn in connections.all():   File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\django\db\utils.py", line 222, in all     return [self[alias] for alias in self]   File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\django\db\utils.py", line 219, in __iter__     return iter(self.databases)   File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\django\utils\functional.py", line 48, in __get__     res = instance.__dict__[self.name] = self.func(instance)   File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\django\db\utils.py", line 153, in databases     self._databases = settings.DATABASES   File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\django\conf\__init__.py", line 76, in __getattr__     self._setup(name)   File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\django\conf\__init__.py", line 63, in _setup     self._wrapped = Settings(settings_module)   File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\django\conf\__init__.py", line 142, in __init__     mod = importlib.import_module(self.SETTINGS_MODULE)   File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.752.0_x64__qbz5n2kfra8p0\lib\importlib\__init__.py", line 127, in import_module     return _bootstrap._gcd_import(name[level:], package, level)   File "<frozen importlib._bootstrap>", line 1014, in _gcd_import   File "<frozen importlib._bootstrap>", line 991, in _find_and_load   File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked   File "<frozen importlib._bootstrap>", line 671, in _load_unlocked   File "<frozen importlib._bootstrap_external>", line 783, in exec_module   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed   File "C:\Users\Rachel\techops_work\urec\urec\settings.py", line 1, in <module>     from settings_general import * ModuleNotFoundError: No module named 'settings_general'  During handling of the above exception, another exception occurred:  Traceback (most recent call last):   File "manage.py", line 10, in <module>     execute_from_command_line(sys.argv)   File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line     utility.execute()   File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\django\core\management\__init__.py", line 395, in execute     self.fetch_command(subcommand).run_from_argv(self.argv)   File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\django\core\management\base.py", line 341, in run_from_argv     connections.close_all()   File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\django\db\utils.py", line 225, in close_all     for alias in self:   File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\django\db\utils.py", line 219, in __iter__     return iter(self.databases)   File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\django\utils\functional.py", line 48, in __get__     res = instance.__dict__[self.name] = self.func(instance)   File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\django\db\utils.py", line 153, in databases     self._databases = settings.DATABASES   File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\django\conf\__init__.py", line 76, in __getattr__     self._setup(name)   File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\django\conf\__init__.py", line 63, in _setup     self._wrapped = Settings(settings_module)   File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\django\conf\__init__.py", line 142, in __init__     mod = importlib.import_module(self.SETTINGS_MODULE)   File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.752.0_x64__qbz5n2kfra8p0\lib\importlib\__init__.py", line 127, in import_module     return _bootstrap._gcd_import(name[level:], package, level)   File "<frozen importlib._bootstrap>", line 1014, in _gcd_import   File "<frozen importlib._bootstrap>", line 991, in _find_and_load   File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked   File "<frozen importlib._bootstrap>", line 671, in _load_unlocked   File "<frozen importlib._bootstrap_external>", line 783, in exec_module   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed   File "C:\Users\Rachel\techops_work\urec\urec\settings.py", line 1, in <module>     from settings_general import * ModuleNotFoundError: No module named 'settings_general' 

This is the contents of the project:

(urec) λ ls AUTHORS        fabfiles/    lostfound/  Procfile                      templates/    util/ client_side/   facilities/  manage.py*  README.md                     test.py data/          fitness/     members/    requirements.txt              to-vagrant/ eventwaivers/  hr/          out.pdf     requirements_development.txt  urec/ fabfile.py     incidents/   partcount/  swipe/                        urec_crontab 

and the contents of the subfolder where settings_general is located:

(urec) λ ls __init__.py   settings.py              settings_general.py     settings_test.py     urls.py __pycache__/  settings_development.py  settings_production.py  settings_testing.py  wsgi.py 

All answers to this question, which has the identifier 60850597

The best answer:

You have this line in settings.py:

from settings_general import * 

The local directory is the location of manage.py, since that is the current script you're running. So when python searches for modules, it looks first for modules relative to the root of your project (after which it will look in sys.path which are paths to built-in packages and pip packages). In your case, urec.settings_general would work. settings_general cannot work, since it's not on the same path as manage.py.

Otherwise, you can use relative paths to modules, in which case you need to explicitly add a dot: .settings_general.

So: change the line to either

from .settings_general import * 

of

from urec.settings_general import * 

Last questions

how do i remove the switch on my home screen?
how to edit the JS date and time to update atuomatically?
How to utilize data stored in a multidimensional array
Powermockito not mocking URL constructor in URI.toURL() method
Android Bluetooth LE Scanner only scans when phone's Location is turned on in some devices
docker wordpress container can't connect to mysql container
How can I declare a number in java that is more than 64-bits? [duplicate]
Optaplanner solutionClass entityCollectionProperty should never return null error when simple JSON object passed to controller
Anylogic, get the time a pedestrain is in a queue
How do I fix this syntax issue with my .flex file?
Optimizing query in PHP
How to find the highest number of a column and print two columns of that row in R?
Ideas on “Error: Type com.google.firebase.iid.zzav is referenced as an interface from com.google.firebase.messaging.zzd”?
JCIFS SmbFile.exists() and SmbFile.isDirectory() return false when it exists and I can listFiles()
PHP total order
Laravel booking system design
neural net - undefined column selected
How to indicate y axis does not start from 0 in ggplot?
Fragments in backStack
Spinner how to change the data