ImportError: No module named flask_mail - flask

from flask_mail import Mail,Message
from flask import Flask
I am trying to mail but import error is occurring

The are two packages by that name:
The project found on GitHub and in PyPI uses flask_mail as the package name; see their documentation and project source code.
Their layout indeed requires:
from flask_mail import Mail, Message
This is a fork of the other project, but is currently actively maintained.
There is a project on Bitbucket, and their Flask-Mail documentation and the project source code show that the correct import is:
from flaskext.mail import Mail, Message
This project appears to be outdated and has not seen an update for almost 3 years now. The Github project names the same original author, it appears to be an updated fork. I'd stick with the Github project.
If neither works, then there is no such module installed, not in the location that the Python version running your Flask server can find.

You have to install flask_mail in order to be able to import it.
if you are working with linux type this into your terminal and hit enter:
$ sudo pip install flask_mail

Here is a simple way to save time. Upgrade or update your pip before installing Flask-Mail. It worked on my Mac
pip install --user --upgrade pip
pip install Flask-Mail

Related

Conda dependent packages(rdkit) will not install properly for use in web servers(importError:DLL load failed). Is there an alternative install method?

UPDATE 1: PIL and RDKIT produced import errors because the .dll files were not placed in /venv//Lib/site-packages
I removed both packages from environment and commented out their code from my project.
Next I updated the base base environment:
conda update conda #from base env
Then I upgraded pip and setuptools and reinstalled pillow:
python -m pip install pip --upgrade
pip install setuptools --upgrade
pip install pillow
I can now add my PIL content back to the project and it will work just fine on the production server, without rdkit installed.
RDKIT is only available as a conda install, it still does not install properly and breaks PIL in the process(rdkit depends on pillow). I have reinstalled from both the rdkit and conda-forge channels. Neither work.
What is the proper way to fix this problem? I feel like the hack around of moving .dll files is risky and not a good solution.
UPDATE 0: RDKIT will not load into any server
I created a basic django project similar to what you would find in the tutorial with no static files. The project successfully published to the Apache server describe below in the original post and in Windows 10 IIS. Next modified the models.py to import rdkit and both servers gave the import error and the site would not display.
Original post:
RDKIT is the only package not loading into our production server.
We successfully set up a Wampserver to run Apache and host our Django project . . .but have to comment out all the code associated with rdkit for it to work. This inhibits many required features.
There were no issues using rdkit in Django's test server.
Primary wsgi error:
from .rdBase import rdkitVersion as __version__\r, referer: http://localhost/APP/
ImportError: DLL load failed: The specified module could not be found.\r, referer: http://localhost/APP/
Relevant packages and version details:
Windows 10
Django 2.2
Python 3.7
conda 4.8.2
rdkit 2019.09.3 conda-forge
Wampserver 3.2
Apache 2.4.41
mod-wsgi 4.7.1
postgresql 10
The methods in this blog describe how we setup the production server. With one minor change, we did not alter the httpd_vhosts.conf file and only setup the standard localhost.
The error is reproducible by trying to import rdkit(or one of its methods) into any file needed to host a web application in the described environment.
We found this 2016 thread on the rdkit sourceforge and it sounds like someone else was having a similar problem on a Linux system. This is our first time setting up a server and we have not been successful at translating the recommended fix from linux to windows. There was no follow up to know if the recommendation was attempted let alone successful.
These 2012 slides lend us to believe someone was trying to overcome a similar issue in linux (slide 9)
How would a package need to be altered to allow it to load into a webserver?
Thank you, we greatly appreciate your time and assistance.

cant import flask-wtf after install

I have been looking around for an answer to this question, but everywhere I see the advice of running a pip install flask-wtf in the virtual environment. The requirements have already been satisfied in mine, but for some reason I am getting a missing module error. I am working on a school project building a website using flask and would really appreciate the help. My import is:
from flask_wtf import Form`
When I try to run the install command I get a message that says the requirement is already satisfied, as shown in this image.
Based on the screenshot, your flask-wtf and friends are installed outside virtualenvs, in the system site-packages directory.
It'd be a good idea to uninstall those from the global site-packages directory (python3 -m pip uninstall flask-wtf wtforms flask jinja2 click werkzeug markupsafe itsdangerous), create and activate a virtualenv (python3 -m venv my_venv and ./my_venv/bin/activate), then reinstall the dependencies within the virtualenv.

ImportError: No module named 'django' despite having it installed running apache2 server

I know that many have posted similar question however I tried most solution without success.
I'm trying to host a webpage with apache2 and django in python3.
In the error log I found ImportError: No module named 'django' when accessing the wsgi.pyfile, where I also added import sys, sys.version to confirm which python version is used and from the error log I can see that I'm running following python version 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609].
When I run python3.5 I see that I uses the same python version and here I can run import django without any error!
EDIT: I checked django.__file__and saw that it was located in /home/USERNAME/.local/lib/python3.5/site-packages/django/init.py and that path /home/USERNAME/.local/lib/python3.5/site-packages wasn't in the sys.path that tried to run django. But adding it with sys.path.append(path) didn't help :(
Any thoughts what I might have messed up?
If you have Setup the whole configuration in VirtualEnv then , i suggest you to activate it by,
source /location to /env/bin activate
pip3 install django=version_id
or pip install django=version id
if you want to pass version id then its good or it will install the latest django from your repo.
Now test Django Version there.
Hope you will no get the error.
Location - means the path where env will be located in project directory, if you have followed the standard installation process of django or else you don't need, and version id- vesion of django framework.
I finally understood how to solve it! first I had to run pip3 uninstall django then run sudo pip3 install django.

ImportError: cannot import name OrderedDict; downgrade kombu

I am trying to install and import pytplot, which is a package that can plot IDL save files using python. I have Python 2.7 on Windows 10. If I try importing pytplot, I get an import error saying: ImportError: cannot import name OrderedDict. This question has already been answered here: Getting ImportError: cannot import name OrderedDict.
However, I can't figure out how to complete the first step: downgrade kombu to the 2.5.16 version. I have uninstalled my current version of kombu and I'm trying to use:
"pip install kombu-2.5.16"
This fails and my prompt says that it could not find a version that satisfies this requirement.
Try:
pip install -U kombu==2.5.16
otherwise pip -U kombu==3.5.x
will show you all available versions

ImportError: No module named rest_framework_jwt.views

I am using Ubuntu and Django (Python 2.7.12)
I am trying to run python manage.py migrate but an error shows up:
from rest_framework_jwt.views import obtain_jwt_token
ImportError: No module named rest_framework_jwt.views
I have already installed rest like this:
pip install djangorestframework
Any idea about the error?
JWT is a separate package, so you need to install it via pip install djangorestframework-jwt.
Note, depending on the version(s) of Python you have installed, you might need to use pip3 instead of pip if you are trying to use this/install it for Python 3.
See the other answer regarding Simple JWT, which replaced JWT in 2019.
Be aware that JWT has not been maintained since ~2019. There is a newer project, Simple JWT, that you may use instead, if you need newer features. You can install it with this command:
pip install djangorestframework-simplejwt