ModuleNotFoundError: No module named '_sqlite3' python django - django

I am running simple python manage.py runserver and getting this error :
File "/usr/local/lib/python3.6/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ModuleNotFoundError: No module named '_sqlite3'
I had tried everything like installing sqlite3,sqlite-devel but nothing works.

Try to make a new virtual environment with virtualenv, conda or any other way you know and then activate your virtualenv, install any package you need inside that to avoid versions conflict problems. Now you can run the app.
Hope this works

Related

ModuleNotFoundError: No module named 'import-export' , but I have installed import-export

I'm using Django2.2.6, xadmin2.
I want to use import-export, however, the error goes:
ModuleNotFoundError: No module named 'import-export'
but I have run this code successfully
pip install django-import-export==2.7.0
Is there any way for me to fix it?

Django: ModuleNotFoundError: No module named 'psycopg2' on Mac

I have installed psycopg2-binary 2.9.1(pip install psycopg2-binary) in virtualenv, but when I execute python manage.py migrate, that appears "django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: No module named 'psycopg2'", and python console also can't import psycopg2. how to fix the problem?
I have fixed my problem by use python3 manage.py migrate.

ModuleNotFoundError: No module named 'django' while running manage.py

I have installed virtualenv and then installed django in my Windows 10. After activating virtualenv and running: python manage.py runserver, I am getting:
File "manage.py", line 10, in main
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'
The above exception was the direct cause of the following exception:
ImportError: Couldn't import Django. Are you sure it's installed and available
on your PYTHONPATH environment variable? Did you forget to activate a virtual
environment?
Also just found while running django-admin.exe I am getting:
Note that only Django core commands are listed as settings are not properly
configured (error: Requested setting INSTALLED_APPS, but settings are not
configured. You must either define the environment variable
DJANGO_SETTINGS_MODULE or call settings.configure() before accessing
settings.).
Manage.py:
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'wordcount.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()
You can verify whether you have installed django by creating a python program and importing django
import django
print (django.VERSION)
Above code will print the django version installed , confirm whether you have installed django
You have 2 Python versions : The main one which is installed by default and the one used by virtualenv.
When you run pip install django Django is installed in the main version of Python and thats because the PYTHONPATH environment variable refers to path of the main version and not virtualenv.
The same thing happens when you run python manage.py runserver. It doesn't run python from the virtualenv.
To solve this you need to access pip from the virtualenv and then you can insall Django with it
C:\the\path\to\virtualenv\path\to\pip.exe install django
And just like pip, run python.exe from virtualenv
C:\the\path\to\virtualenv\path\to\python.exe manage.py runserver
If you are using PyCharm for development then you can easily set your venv as interpreter.
Now to run django and just like pip you will access python from virtualenv
1 - File > Settings > Your Project > Python Interpreter
2 - Click the settings icon at the right and then click on Add
3 - Click on Virtualenv Environment and choose the location
Once the virtualenv has been setup you can easily use PyCharm to manage packages

local settings can not find the app

Everytime I try to run the app, or migrate my database, it throws this error. My IDE, although, helps me run the app because the configurations seem to be correct but bash fails to run any of the Django commands.
This is the error that I get:
File "/Users/angy/settings/projname_conf/settings.py", line 1, in <module>
from pyup.generic_settings import *
ModuleNotFoundError: No module named 'pyup'
I don't know pyup, but that's what i found:
To install pyup, run:
$ pip install pyupio
https://github.com/pyupio/pyup

django wont work with python3.3.3

Hello I recently installed the django on my Mac OS X 10.9 using the pip install Django.
The installation was successful, now my python3.3.3 is installed in the following directory:
/usr/local/lib/python3.3/site-packages
Inside this directory there is a directory for django so I am assuming that the installation was success on python 3.
The problem arise when I am trying the following procedure:
django-admin.py startproject mysite
The above command creates with success the directory with the files
Then on this command:
python manage.py runserver
or
python3 manage.py runserver
The error is:
File "manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
ImportError: No module named 'django'
Moreover, I do find a solution but wont work. Was to change the first comment of the file django-admin.py to link the compiler to the correct version of python, which was fine, but the problem is the same.
Any help?
Check out this tutorial on python development on OSX: http://hackercodex.com/guide/python-development-environment-on-mac-osx/
Virtualenv allows you to create sandboxes where you can install different python versions and python libraries without interfering with other virtual environments or with your system python version/libraries.
Your specific problem though, seems to be that Django was not added to your system path, so python doesn't know where to find the django files. It can be risky to add new things to your system path because it could end up conflicting with existing libraries.
If you use virtualenv, each environment will have its own "system" path and the python executable in that environment will know where to find the django files.