ModuleNotFoundError: No module named configs.Environment - python

I'm trying to run this project https://github.com/Progyan1997/fastapi-example
locally, but I'm getting the following error:
Process SpawnProcess-1:
Traceback (most recent call last):
File "/home/omar/.pyenv/versions/3.8.13/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
self.run()
File "/home/omar/.pyenv/versions/3.8.13/lib/python3.8/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/home/omar/.local/share/virtualenvs/fastapi-example-tXminANK/lib/python3.8/site-packages/uvicorn/subprocess.py", line 76, in subprocess_started
target(sockets=sockets)
File "/home/omar/.local/share/virtualenvs/fastapi-example-tXminANK/lib/python3.8/site-packages/uvicorn/server.py", line 60, in run
return asyncio.run(self.serve(sockets=sockets))
File "/home/omar/.pyenv/versions/3.8.13/lib/python3.8/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "uvloop/loop.pyx", line 1501, in uvloop.loop.Loop.run_until_complete
File "/home/omar/.local/share/virtualenvs/fastapi-example-tXminANK/lib/python3.8/site-packages/uvicorn/server.py", line 67, in serve
config.load()
File "/home/omar/.local/share/virtualenvs/fastapi-example-tXminANK/lib/python3.8/site-packages/uvicorn/config.py", line 458, in load
self.loaded_app = import_from_string(self.app)
File "/home/omar/.local/share/virtualenvs/fastapi-example-tXminANK/lib/python3.8/site-packages/uvicorn/importer.py", line 24, in import_from_string
raise exc from None
File "/home/omar/.local/share/virtualenvs/fastapi-example-tXminANK/lib/python3.8/site-packages/uvicorn/importer.py", line 21, in import_from_string
module = importlib.import_module(module_str)
File "/home/omar/.pyenv/versions/3.8.13/lib/python3.8/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 843, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/omar/Desktop/Learning/fastapi-example/./main.py", line 5, in <module>
from configs.Environment import get_environment_variables
ModuleNotFoundError: No module named 'configs.Environment'
I have gone through the steps and installed Pipenv. But it still crashes with same error.
Python 3.8.13
pipenv, version 2022.5.2

It looks like a typo in the repo, try changing from configs.Environment to from configs.environment
If it will help, please create PR to this repo, help opensource!

Related

No module named 'graphql.type' in Django

I am New in Django and GraphQL, following the the article,
I am using python 3.8 in virtual env and 3.10 in windows, but same error occurs on both side, also tried the this Question, i also heard that GraphQL generate queries, But dont know how to generate it, But this error occurs:
Traceback (most recent call last):
File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/usr/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/home/talha/ve/lib/python3.8/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/home/talha/ve/lib/python3.8/site-packages/django/core/management/commands/runserver.py", line 125, in inner_run autoreload.raise_last_exception()
File "/home/talha/ve/lib/python3.8/site-packages/django/utils/autoreload.py", line 87, in raise_last_exception
raise _exception[1]
File "/home/talha/ve/lib/python3.8/site-packages/django/core/management/__init__.py", line 398, in execute
autoreload.check_errors(django.setup)()
File "/home/talha/ve/lib/python3.8/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/home/talha/ve/lib/python3.8/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/talha/ve/lib/python3.8/site-packages/django/apps/registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "/home/talha/ve/lib/python3.8/site-packages/django/apps/config.py", line 193, in create
import_module(entry)
File "/usr/lib/python3.8/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 961, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
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 "/home/talha/ve/lib/python3.8/site-packages/ariadne/__init__.py", line 1, in <module>
from .enums import (
File "/home/talha/ve/lib/python3.8/site-packages/ariadne/enums.py", line 17, in <module>
from graphql.type import GraphQLEnumType, GraphQLNamedType, GraphQLSchema
ModuleNotFoundError: No module named 'graphql.type'```
You can try these following ways,
One, you can find graphql directory in the project, on python path. renaming it will fix the issue.
And also you can try these commands,
pip install pip --upgrade
pip install setuptools --upgrade
pip install gql[all]
Hope this helps, if not please let know. Thanks

I get an error when I install the SWITIFY package, does anyone know what it means?

when I install the package sweetify, I get the following error
Does anyone know what the reason is?
I went through all the steps that were in the main dock
Traceback (most recent call last):
File "C:\Program Files\Python38\lib\threading.py", line 932, in _bootstrap_inner
self.run()
File "C:\Program Files\Python38\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\nahid\PycharmProjects\fitshow\venv\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "C:\Users\nahid\PycharmProjects\fitshow\venv\lib\site-packages\django\core\management\commands\runserver.py", line 125, in inner_run
autoreload.raise_last_exception()
File "C:\Users\nahid\PycharmProjects\fitshow\venv\lib\site-packages\django\utils\autoreload.py", line 87, in raise_last_exception
raise _exception[1]
File "C:\Users\nahid\PycharmProjects\fitshow\venv\lib\site-packages\django\core\management\__init__.py", line 398, in execute
autoreload.check_errors(django.setup)()
File "C:\Users\nahid\PycharmProjects\fitshow\venv\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "C:\Users\nahid\PycharmProjects\fitshow\venv\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\nahid\PycharmProjects\fitshow\venv\lib\site-packages\django\apps\registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "C:\Users\nahid\PycharmProjects\fitshow\venv\lib\site-packages\django\apps\config.py", line 228, in create
import_module(entry)
File "C:\Program Files\Python38\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 848, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\nahid\PycharmProjects\fitshow\venv\lib\site-packages\sweetify\__init__.py", line 1, in <module>
from .sweetify import *
File "C:\Users\nahid\PycharmProjects\fitshow\venv\lib\site-packages\sweetify\sweetify.py", line 5, in <module>
from .encoder import LazyEncoder
File "C:\Users\nahid\PycharmProjects\fitshow\venv\lib\site-packages\sweetify\encoder.py", line 2, in <module>
from django.utils.encoding import force_text
ImportError: cannot import name 'force_text' from 'django.utils.encoding' (C:\Users\nahid\PycharmProjects\fitshow\venv\lib\site-packages\django\utils\encoding.py)
Looks like sweetify is not compatible with Django 4.0. See the changelog: https://docs.djangoproject.com/en/4.0/releases/4.0/#features-removed-in-4-0
django.utils.encoding.force_text() and smart_text() are removed.
Try with older version of django, I recommend 3.2.13 :)
this error is coming from django v4 . according to django documentation django.utils.encoding.force_text() and smart_text() are removed.
possible solution :
1 - using Django version 4> add in settings.py :
import django
from django.utils.encoding import force_str
django.utils.encoding.force_text = force_str
Downgrade your django version to django<=3

Getting error while running heroku run python manage.py migrate

I am a beginner in heroku and django and I am trying to create an application. While I was importing my database to heroku by running command -
heroku run python manage.py migrate
I get an error saying -
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/base.py", line 373, in run_from_argv
self.execute(*args, **cmd_options)
File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/base.py", line 417, in execute
output = self.handle(*args, **options)
File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/base.py", line 87, in wrapped
saved_locale = translation.get_language()
File "/app/.heroku/python/lib/python3.9/site-packages/django/utils/translation/__init__.py", line 182, in get_language
return _trans.get_language()
File "/app/.heroku/python/lib/python3.9/site-packages/django/utils/translation/__init__.py", line 50, in __getattr__
if settings.USE_I18N:
File "/app/.heroku/python/lib/python3.9/site-packages/django/conf/__init__.py", line 84, in __getattr__
self._setup(name)
File "/app/.heroku/python/lib/python3.9/site-packages/django/conf/__init__.py", line 71, in _setup
self._wrapped = Settings(settings_module)
File "/app/.heroku/python/lib/python3.9/site-packages/django/conf/__init__.py", line 179, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/app/.heroku/python/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 972, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'pp'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/app/manage.py", line 22, in <module>
main()
File "/app/manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/__init__.py", line 425, in execute_from_command_line
utility.execute()
File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/base.py", line 386, in run_from_argv
connections.close_all()
File "/app/.heroku/python/lib/python3.9/site-packages/django/db/utils.py", line 208, in close_all
for alias in self:
File "/app/.heroku/python/lib/python3.9/site-packages/django/utils/connection.py", line 73, in __iter__
return iter(self.settings)
File "/app/.heroku/python/lib/python3.9/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/app/.heroku/python/lib/python3.9/site-packages/django/utils/connection.py", line 45, in settings
self._settings = self.configure_settings(self._settings)
File "/app/.heroku/python/lib/python3.9/site-packages/django/db/utils.py", line 144, in configure_settings
databases = super().configure_settings(databases)
File "/app/.heroku/python/lib/python3.9/site-packages/django/utils/connection.py", line 50, in configure_settings
settings = getattr(django_settings, self.settings_name)
File "/app/.heroku/python/lib/python3.9/site-packages/django/conf/__init__.py", line 84, in __getattr__
self._setup(name)
File "/app/.heroku/python/lib/python3.9/site-packages/django/conf/__init__.py", line 71, in _setup
self._wrapped = Settings(settings_module)
File "/app/.heroku/python/lib/python3.9/site-packages/django/conf/__init__.py", line 179, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/app/.heroku/python/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 972, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'pp'
What should I do to successfully import my database to heroku and get it working? Please let me know if I need to add any of my files on here.
This is my directory layout in visual studio code -
Django directory

Django - After installing "Bootstrap4" with pip, got syntax error on settings.py

After installing "Bootstrap4" using pip, add tags in html files, and adding it in requirements.txt and settings.py, do migrate but it shows this:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
main()
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\Users\Mehrab\menv\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "C:\Users\Mehrab\menv\lib\site-packages\django\core\management\__init__.py", line 345, in execute
settings.INSTALLED_APPS
File "C:\Users\Mehrab\menv\lib\site-packages\django\conf\__init__.py", line 83, in __getattr__
self._setup(name)
File "C:\Users\Mehrab\menv\lib\site-packages\django\conf\__init__.py", line 70, in _setup
self._wrapped = Settings(settings_module)
File "C:\Users\Mehrab\menv\lib\site-packages\django\conf\__init__.py", line 177, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.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 779, in exec_module
File "<frozen importlib._bootstrap_external>", line 916, in get_code
File "<frozen importlib._bootstrap_external>", line 846, in source_to_code
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "D:\~\socialize\settings.py", line 72
WSGI_APPLICATION = 'socialize.wsgi.application'
^
SyntaxError: invalid syntax
I didn't find any broblem in settings.py

Getting error when Django startup with runserver command

I have an django app that include sklearn, pandas and numpy libraries. I can run it without virtualenv however when I run it inside virtualenv I get his error. I am using Python3.8 on Ubuntu. I just want to use virtualenv to manage my packages easily. I re-installed packages in the virtualenv with PyCharm. My error include references to the joblib library too.
I cannot find any solution:
Matching for file changes with StatReloader
Performing system checks...
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/usr/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/django/utils/autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/django/core/management/commands/runserver.py", line 118, in inner_run
self.check(display_num_errors=True)
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/django/core/management/base.py", line 392, in check
all_issues = checks.run_checks(
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/django/core/checks/registry.py", line 70, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/django/core/checks/urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/django/core/checks/urls.py", line 23, in check_resolver
return check_method()
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/django/urls/resolvers.py", line 408, in check
for pattern in self.url_patterns:
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/django/urls/resolvers.py", line 589, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/django/urls/resolvers.py", line 582, in urlconf_module
return import_module(self.urlconf_name)
File "/usr/lib/python3.8/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 "/home/suat/Belgeler/github/turnusol/turnusolwebproject/urls.py", line 31, in <module>
path('factomat', include('factomat.urls')),
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/django/urls/conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "/usr/lib/python3.8/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 "/home/suat/Belgeler/github/turnusol/factomat/urls.py", line 2, in <module>
from . import views
File "/home/suat/Belgeler/github/turnusol/factomat/views.py", line 13, in <module>
from sklearn.externals import joblib
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/sklearn/externals/joblib/__init__.py", line 119, in <module>
from .parallel import Parallel
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/sklearn/externals/joblib/parallel.py", line 28, in <module>
from ._parallel_backends import (FallbackToBackend, MultiprocessingBackend,
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/sklearn/externals/joblib/_parallel_backends.py", line 22, in <module>
from .executor import get_memmapping_executor
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/sklearn/externals/joblib/executor.py", line 14, in <module>
from .externals.loky.reusable_executor import get_reusable_executor
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/sklearn/externals/joblib/externals/loky/__init__.py", line 12, in <module>
from .backend.reduction import set_loky_pickler
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/sklearn/externals/joblib/externals/loky/backend/reduction.py", line 125, in <module>
from sklearn.externals.joblib.externals import cloudpickle # noqa: F401
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/sklearn/externals/joblib/externals/cloudpickle/__init__.py", line 3, in <module>
from .cloudpickle import *
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/sklearn/externals/joblib/externals/cloudpickle/cloudpickle.py", line 167, in <module>
_cell_set_template_code = _make_cell_set_template_code()
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/sklearn/externals/joblib/externals/cloudpickle/cloudpickle.py", line 148, in _make_cell_set_template_code
return types.CodeType(
TypeError: an integer is required (got type bytes)
That looks like you may have run into a known issue with Python 3.8 and cloudpickle following changes in PEP 570.
It's not clear from the cloudpickle Github repo whether it supports Python 3.8 yet, so a potential fix may be to use Python 3.7 in the virtualenv instead.

Categories

Resources