ModuleNotFoundError: No module named 'django' in django project - python-3.x

I have anaconda python 3.7 installed on my system. I am creating a Django project called learning log in a virtual environment(active at the time when the problem appeared) in G drive on my computer. I have defined and migrated the entry model but when I try to register entry with the admin site through file admin.py in the project folder with the following code ...
from django.contrib import admin
from models import Topic
# Register your models here
admin.site.register(Topic)
... and try to run it in my spyder editor it shows:
ModuleNotFoundError: No module named 'django'

Have you tried re-installing it with
pip install django
in your virtualenv?

Instead of pip installing, you might have to conda install it.
conda install -c anaconda django

Related

Azure AutoML Python SDK, Issues importing into VS Code Jupyter Notebook

I have a .yml that installs all the necessary Azure ML packages.
Upon creating the environment with the YML, I test to make sure I can import the packages, and I can.
But when I open the Jupyter notebook I will be using and import the necessary packages, one is not found.
from azureml.train.automl import AutoMLConfig
ModuleNotFoundError: No module named 'azureml.train.automl.automlconfig'
But When I import it in the command prompt, it successfully imports
It seems like this is an issue with VS code, has anyone else encountered this?
I tried reproducing the issue while importing AutoMLConfig in VSCode as below:
Followed the below steps to fix it by installing its related Python packages.
Activate the virtual environment from below command
python -m venv .venv
.venv\Scripts\activate
Then install pip install azureml and “pip install azureml-core”
Pip install azureml-train
Pip install azureml-train-automl
Also, we have a Microsoft documentation where we have all the sub packages of azureml.

I have installed cvlib in python but still can't import it

I installed miniconda and just created a conda environment:
conda create -n my_env python=3.5 anaconda
I am trying to:
import cvlib
But I am getting the error:
ImportError: No module named cvlib
So I have tried to install using:
pip3 install cvlib
This seemed to work successfully, but then when I try to import cvlib I am still getting the ImportError: No module named cvlib error (I have retarted my terminal after the installation).
Is this a problem with my PYTHONPATH not containing the path to the directory that now contains cvlib? If so, how do I find where cvlib is saved so that I can add the path?
Check if the library is in your python directory. Otherwise, make a repl.it account, and install cvlib, and check the functions or the lib name. Maybe try searching a more advanced installation of cvlib.
it might have occurred due to the version of python you installed or due to the directory, you installed.
try uninstalling the current version of python and try installing an older version of python and install it in the directory as shown below:
C:\Users\Rajish\AppData\Local\Programs\Python\Python39
also, select add the path to environment variables while installing
and after that install cvlib and all other required modules and packages
it worked for me.

ModuleNotFoundError: No module named 'django' when installing django in venv

I am trying to do this:
from django.contrib import admin
from .models import Topic
admin.site.register(Topic)
however, I get the following error:
ModuleNotFoundError: No module named 'django'
I have also tried installing django in my system but still nothing and when i check installed packages it shows django is already installed
My venv is also active so i dont know why the error is being raised?
First create virtualenv, virtualenv env
then activate it, env/scripts/activate
later install Django, pip install Django
Create Django project, install your app name in settings.py file the run it.
If you create Djangoproject and activate virualenv later, it may fail

Socketio installing problems

I'm facing a problem with socketio. I imported it into my programme by command:
import socketio
Wen I typped pip freeze I got:
python-socketio==4.5.1
Then I ran programme by typing into console:
myfile.py --mode "mode"
But it says:
ModuleNotFoundError: No module named 'socketio'
Any ideas how to fix it?
It happens when you have multiple version of pip install on your system.
you can deal with this problem by creating a virtual environment and again loading the socket-io library.
Install pipenv.
pip install pipenv
Then change directory to the folder containing your Python project and initiate Pipenv,
cd your_project
pipenv install
This will build two new files in your project directory, Pipfile and Pipfile.lock, and a new virtual environment for your project, if it doesn't already exist. If you add the —two or —three flags to the last command above, your project will be initialized with the use of Python 2 or 3. Otherwise, Python's default version will be included.
To install a Python package for your project use the install keyword. For example,
pipenv install beautifulsoup4
and for uninstalling
pipenv uninstall beautifulsoup4

Imported package not available in Jupyter-Python

Importing pysftp into Jupyter Notebook
While importing pysftp into Jupyter Notebook, ModuleNotFoundError is shown.
Checking import of pysftp on device?
I have verified the package installation with
pip list and pip show pysftp
Had imported pysftp package(v0.2.9) and installed it in the below location
C:\users\xxxxxx\appdata\roaming\python\python37\site-packages
Check : Package installed OKAY
Check about package correct path linking from cmd prompt?
I'm using Python 3.7.0 on a WIN machine, verifyed the site package location using
import sys and sys.path
image confirms linking of PATH to correct location and the package is successfully executed when python is run through cmd prompt
Check : Path link and cmd run OKAY
Now could anyone help me solve why the package import in Jupyter Notebook is throwing an error?
Thank you
Edit 1: Check for different environment installed? added based on one of the answer
Only one environment is present in the machine
I got the same. I solved by installing directly within Jupyter using the following command:
import sys
!{sys.executable} -m pip install dice-ml
Are you running the notebook through a virtual environment?
You can try running the same commands as you did on CMD by preceding it with ! as follows:
!pip list
Ideally this should list the same contents as shown in CMD. However the results may be different if you are running Jupyter notebook in a virtual environment. If you are unable to see pysftp, you need to install it within the virtual environment. This can be done from within your notebook as:
!pip install pysftp

Resources