Flask running on a different console? - flask

I am using Flask using pythonanywhere (https://www.pythonanywhere.com) and I noticed that everytime I launch a Flask application, it runs on Python3.4 console.
Is it possible to switch the console such that the Flask application I'm building would run on different python consoles such as python 2.7?
The reason is that one of the libraries I need to import is cv2 (opencv) and python3.4 console does not seem to have it installed while python 2.7 does.
Does anyone have any idea of how to do this?
Thank you in advance!

Related

No module named 'sklearn' while running django server

I saved a model using joblib and was trying to run server using but it shows no module as sklearn even though it is downloaded in the environment, can anyone please help?

Pyinstaller Flask Application Running multiple instances

I crated a desktop application of my Flask web app using pyinstaller. Functionality is working fine. But once I start the app, multiple instances of the same app is getting started automatically to the extent of fully occupying the CPU.Below is the command I used to create the desktop app.
pyinstaller --add-data "templates;templates" --add-data "static;static" app.py
There are multiple instances of app, like my screenshot shows:
How can i fix this issue?
I was able to fix this by giving the --onefile option. Couldn't figure out why the default version had this issue though.

compiled django application fails to run ASGI channels

I'm building a django application using Pyinstaller.
When I run the application i get an error from dapne server.
"daphne\server.py:13: UserWarning: Something has already installed a non-asyncio Twisted reactor. Attempting to uninstall it; you can fix this warning by importing daphne.server early in your codebase or finding the package that imports Twisted and importing it later on."
In addition, when I compare the console log of the EXE application and a regular run of the django application I notice the following difference.
In the regular run which works as expected I see the following print:
"Django version 2.1.5, using settings 'cfehome.settings'
Starting ASGI/Channels version 2.1.5 development server at http://0.0.0.0:8000/"
however, when I run the application from the EXE I see:
"Django version 2.1.5, using settings 'cfehome.settings'
Starting development server at http://0.0.0.0:8000/"
Appreciate any lead to understand this behavior and ways to fix it.
I know this is old but for others seeking answer. There's a simple fix:
Before importing raven in settings.py, import daphne.server So, your settings.py will look like this:
import daphne.server
import raven
For further information you can read: https://github.com/django/channels/issues/793
I hope it will help.

flask development single terminal: continue editing Code without quitting flask

Background: I am new to Flask (and fairly new to python, linux terminal, servers). I have gone through the tutorial http://flask.pocoo.org/docs/1.0/tutorial/.
I am developing on raspberry pi 3, via putty from my PC.
I run flask, according to the tutorial:
export FLASK_APP=flaskr
export FLASK_ENV=development
flask run
According to the tutorial I can make changes to the code and the server will automatically reload.
My issue: I don't know how to make changes to my code without stopping Flask (ctrl+c).
How can I leave Flask, return to the Linux Terminal, edit my code, and then return to the Flask Debugger without stopping Flask each time?
I have reviewed the Flask Docs http://flask.pocoo.org/docs/1.0/ to no avail.
Thanks,
You has to enable the debug mode. Default debug is True in flask
app.run(debug=True) or export DEBUG=True
you can go through this link for Flask configuration
http://flask.pocoo.org/docs/1.0/config/#configuring-from-environment-variables
If you are using Flask >=1.0v you need to set environment in development mode.
export FLASK_ENV='development'

webfaction hosted django app, shopify module will not import

I've recently created a site with a django app hosted by webfaction. In general, things are running as expected, but I am also trying to use the ShopifyAPI, and get "Import error, no module named shopify" traced to one of my views.py. Everything worked when developing on localhost.
I SSHed into the host server and tried to install the ShopifyAPI with easy_install. It seemed to have reported being successfully installed, but I'm not sure if this actually does anything real on an external server?
Does anybody have suggestions? Any limitations on ShopifyAPI that I may not have considered?
Thanks!
The easy_install command will install the module for Python2.4. You are likely using Python2.6 or Python2.7. If you are using Python2.6, enter:
easy_install-2.6 ShopifyAPI instead of easy_install ShopifyAPI.
If you are using Python2.7, enter:
easy_install-2.7 ShopifyAPI insead of easy_install ShopifyAPI.
You can read more about using easy_install on Webfaction here
After installing the API, restart your Apache instance and it should see the module as expected.