I've been trying to run a code from the internet but I get this error that says:
in
from flask import Flask
ModuleNotFoundError: No module named 'flask'
This is supposed to be a referrence to something i need to work with and i don't know how to fix this as it's not my code.
Here's the link to the code where i got it from:
https://www.geeksforgeeks.org/create-simple-blockchain-using-python/
I just need to run it once so that i could get working on my stuff too.
Edit: i use the basic idle from python btw...
Maybe you dont have flask installed in your dev environment. Do
pip install Flask
or
pip3 install Flask
to install flask
Related
Despite installing all the needed libraries(pandas, flask, sklearn, geopy), I received this error saying all of the libraries cannot be found . I am trying to run a simple flask app.
I'm getting "ModuleNotFoundError: No module named 'icalendar' " after running google app deploy on Gcloud, I have installed the icalendar module using pip but to my surprise i'm getting an error when I try to deploy the app. I have spent hours on this your help will be much appreciated.
According to the official documentation :
Specifying Dependencies
Dependencies for Python applications are declared in a standard
requirements.txt
For example:
Flask==0.10.1
icalendar
Therefore I created a requirements.txt and included icalendar module. Then I deploy to App Engine gcloud app deploy and everything worked as expected.
You can follow this tutorial for better understanding the concept:
Quickstart for Python 3 in the App Engine Standard Environment
Pls. check pip list to see if that has been installed properly. If yes, pls. check that import statement in the python terminal.
If that works, then use which python and ensure that it is the same virtual environment where you are installing and running from.
I have come with python flask code which uses python libraries pywin32 and pYAD. I need to run these in production enviornment.
I tried to enable it over IIS through wfastcgi but its not working as expected.
Is there a way I can leverage the script to use in production set up, I have tried using Always Up converting script as a service but its not allowed in my organization similar with NSSM.
Is there any other way to explore this. Kindly help
Thanks
You can try waitress. You'll find the documentation Here.
Install Waitress
pip install waitress
setup.py file
from waitress import serve
import main
serve(main.app, host='0.0.0.0', port=8080) #'main.app' being your entry point
run setup.py and access your app through http://host_ip_address:8080
I'm trying to use boto3 within a pipenv with Python 3.6.5.
So I installed it with
pipenv install boto3
So for testing purposes I'm using a single Flask app, and add at the beginning of the file:
import boto3
However without even running the program, PyLint warns me that E0401:Unable to import 'boto3', and the auto-completion only proposes botocore.
If I try to run the flask app or to deploy it to Lambda (cause it's the purpose of this app), I get an error 500.
However, the strange is that if I use the REPL within the pipenv and in the same directory and type
>> import boto3
Well it's successful, and I can use all the other commands of boto3. So in my opinion it is installed but for I reason I can't think of, my Python file can't load it.
I heard of file naming conflicts, but honestly I doubt that this is the reason since even if I rename the file and the Flask app with a weird name it still can't load.
Any thoughts about it? Thanks a lot
I have a python module, it works fine, it uses pandas as one of its dependencies.
I added a Flask application in the middle with a rest service which has a service that imports and runs the very same module.
module = importlib.import_module('modules.' + script.module, package=__package__)
Both the python module and the flask app run with the same virtualenv activated, in which pandas is installed.
-BUT- when running this through the flask app, it throws an exception:
ImportError: No module named pandas
Tried to run the module without calling it from Flask and it works just fine...
=== UPDATE ===
I don't know why Flask is running on python 2 even though I'm running it with a virtualenv of python 3 activated.
This is the script I'm using to start my Flask app:
#!/bin/bash
export FLASK_APP=run.py
export FLASK_DEBUG=1
flask run
I'd appreciate any help
Thanks a lot
I've fixed it.
I haven't installed Flask within the virtualenv I was running, so I think that's why Flask was running on a different python version.
So I installed flask on my virtualenv and now it works.