Django 2.1.1 don't find Module pytz - python-3.x

I am trying to deploy a new Django application on an apache web server. The wsgi configuration works fine. However, when ever I try to open the application I run into an internal server error. The log says:
django/utils/timezone.py
import pytz
ModuleNotFoundError: No module named 'pytz'
However, when I do:
python
import pytz
print(pytz.__version__)
everything works fine.
Any ideas ?
///Edit:
Forgot to mention that I am using python3.6 and Django2.1.1

Try to add pytz in your INSTALLED_APPS in settings.py and in your requirements.txt.

Related

how to fix flask import eror (there is no Flask in flask)

i installed flask in the cmd using the pip install flask command and i also tested it in the cmd and it works.
But when i go to pycharm all the modules i download using pip are for some reason in lib/site_packages
instead of just being in site_packages.the lib folder
and then i do "from flask import Flask"
and it says that " cannot import name 'Flask' from 'flask' (C:\Users\User\PycharmProjects\pythonProject1\flask.py)"
the error
there is no Flask in flask
Change the py file name to anything else. naming your flask file as flask.py will create a namespace conflict.

ModuleNotFoundError no module named onetimepad?

i have deployed my web app on pythonanywhere website and the website is working properly but i also created the virtualenv where i installed my app packages everything is working fine
but when i import the new packages in the file in my pyton file like import onetimepad as onetimepad
it gives me error given below
ModuleNotFoundError: no module name 'onetimepad'
How to get rid of from this error Any help would be appreciated thanks in Advance
finally i found out the solution my python version is 3.8
pip3.8 install onetimepad

flask_sqlalchemy module cant be found error

So I want to use the flask_sqlalchemy module in my web app. But when I run "flask run" it gives me the following error:
from flask_sqlalchemy import
SQLAlchemy
ModuleNotFoundError: No module
named 'flask_sqlalchemy'
I am running this in a virtual env with python3.7 and pip3. It says that all packages have been installed. Ive tried a whole bunch of things with no luck.
So after trying a whole bunch of stuff. Setting the environment variable FLASK_ENV=development and then to production somehow fixed.

ModuleNotFoundError: No module named 'flask_wtf' in python

I'm new to python so please be patient if i ask a silly question.
I am trying to use flask wtf class as seen in a tutorial.
My first line of the program is
from flask_wtf import FlaskForm
It gives me the error ModuleNotFoundError: No module named 'flask_wtf'
I have followed the following steps to make sure i have activated the virtual environment and flask wtf was installed in the virtual environment and not global.
Step 1: Went to the virtual environment and activated the environment C:\Users\Shraddha\PycharmProjects\FlaskProject\venv\scripts activate
Step 2: Installed flask wtf
C:\Users\Shraddha\PycharmProjects\FlaskProject\venv\scripts pip install flask-wtf
I see that flask-wtf is installed correctly in the folder C:\Users\Shraddha\PycharmProjects\FlaskProject\venv\Lib\site-packages
However when i try to run it using command prompt it does not give me anything and when i try to run it using sublime text it gives me ModuleNotFoundError: No module named 'flask_wtf' error.
I know this is a flask_wtf import error because other programs are executing as expected. Any help ?
If you start your virtual environment in the same dir as the file you are running doesn't that give access to the libraries in the install (ie everything shown in 'pip freeze' for the env)?
I faced same issue and tried all the approaches given on stackoverflow ImportError: No module named flask_wtf but didn't work for me.
I am using ubuntu 20.04 LTS operating system.
Note: To follow the given step you must activate your virtual environment.
I used:
pip3 freeze
which listed following directories
libries in my virtual environment
Then i tried the below command in the same directory
git clone git://github.com/lepture/flask-wtf.git
cd flask-wtf/
python3 setup.py install
Through the above commands i successfully installed flask_wtf as show below
installed flask_wtf
but then i faced the below error as i used email_validator in my forms.py file:
Exception: Install 'email_validator' for email validation support
Then I installed email_validator using following command
pip3 install email_validator
Then i successfully run my flask application. I am sure it will work for you too.

install flask-pymongo with pip- python 3.6

hellow everyone,
i tried to install PyMongo package with pip( i hope that is the way to do it). [its a part of a login system]
my command line was:
C:/Python36/Scripts/pip install PyMongo
But, when i put it in the command line i got
the system cannot find the file specificied.
And the import line in the code was:
from flask_pymongo import PyMongo
Do someone knows what should i do?
Thanks!!
Flask-PyMongo is a different package than PyMongo. It looks like you've only installed PyMongo, but are trying to use Flask-PyMongo in your application. You should run C:/Python36/Scripts/pip install Flask-PyMongo to install Flask-PyMongo.
You installed PyMongo and tried to import PyMongo from flask_pymongo.
PyMongo is a package to work with MongoDB. To make this work more efficient, Flask just made an extension named "Flask-PyMongo". So, we can directly import "Flask-PyMongo" and start working with MongoDB in a very efficient way.
You can think "Flask-PyMongo" as a wrapper of "PyMongo".

Resources