Build success but application error in Heroku - python

i'm trying to deploy my python app on heroku with the help of flask. I checked on the local machine it worked fine. When i deploy to the heroku build was success but when i open app it says application error
when I log the error with heroku logs --tail --app below is the error code.
2020-06-02T07:06:41.820850+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/mysql/connector/__init__.py", line 34, in <module>
2020-06-02T07:06:41.820850+00:00 app[web.1]: import _version
2020-06-02T07:06:41.820858+00:00 app[web.1]: ModuleNotFoundError: No module named '_version'
my requirements.txt
mysql-connector==2.2.9
mysql-connector-python==8.0.20
mysql_connector_repackaged==0.3.1
mysqlclient==1.4.6
can anyone help me?

https://pypi.org/project/mysql-connector/
Support goes until Python 3.3. It also says in the description:
Deprecated, go for official version
https://pypi.org/project/mysql-connector-python.
Remove the mysql-connector dependency.

Since mysql-connector is virtual package you don't need to specify in your requirements.txt instead of that put mysql.connector in your requirements.txt
and post if it throws any errors
P.S you don't need to specify any version for mysql.connector
HAPPY_CODING

Related

Why Streamlit sharing pyodbc error when deploy?

I have a simple streamlit app that connects to an SQL server with pyodbc.
it's working fine locally but when I try to deploy on streamlit Cloud I have this error:
import pyodbc
ModuleNotFoundError: No module named 'pyodbc'
in my Git I have the requirement.txt that contains:
networkx==3.0
streamlit==1.11.1
pyodbc==4.0.30
pandas==1.0.5
numpy==1.22.0
matplotlib==3.2.2
And I have also the packages.txt that contains:
unixodbc-dev
Someone Knows what's wrong in the deployment process?
Thanks!

Heroku release fail : libSM.so.6: cannot open shared object file: No such file or directory

I've got a problem when I'm trying to deploy a django rest framework app on Heroku.
When it comes to the release, I've got the following error:
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.7/site-packages/vtk/vtkOpenGLKit.py", line 5, in <module>
from .vtkOpenGLKitPython import *
ImportError: libSM.so.6: cannot open shared object file: No such file or directory
[ ... ]
ModuleNotFoundError: No module named 'vtkOpenGLKitPython'
Here is my Procfile
release: python manage.py migrate
web: gunicorn orthoinback.wsgi
My heroku-env
PYTHONPATH=/app/.heroku/python/lib/python3.7/site-packages
and my requirements.txt (pastebin link)
I'd like to know if I missed something or did something wrong.
Thanks for help !!
Use opencv-python-headless as it is out of libSM6 dependency. so use this it will solve your problem.
opencv-python-headless==4.2.0.32

ImportError: No module named tablib

I am using "flask+nginx+uwsgi" for my website. Everything works fine at first.Then in order to transform my *.txt file to excel format, I install tablib in my environment and add just "import tablib" into my init.py , then I cannot access my website any more. Once I comment out "import tablib", it works again. And I notice the uwsgi.log, it tells me that:
> *** Operational MODE: preforking *** Traceback (most recent call last): File "./__init__.py", line 14, in <module>
> import tablib ImportError: No module named tablib unable to load app 0 (mountpoint='') (callable not found or import error)
> *** no app loaded. going in full dynamic mode ***
I check uwsgi setting carefully and i don't think it's uwsgi that create this error(because whenever I remove "import tablib", everything works perfectly). I also checked the installation of tablib, it was installed successfully. Can anyone give me a suggestion on how to fix this error? thanks a lot!
Are you running uwsgi as root? If so, running sudo -H pip install tablib in terminal should fix the issue for you. It is possible that you have installed tablib in your own profile, but not in the root profile.

Flask - ImportError: No module named migrate.versioning

I'm working through a flask tutorial and am trying to run a script that creates a database instead of doing it through the command line. It uses the SQLAlchemy-migrate package, but when I try to run the script, it gives an ImportError.
This is the terminal output:
Sean:app seanpatterson$ python ./db_create.py
Traceback (most recent call last):
File "./db_create.py", line 2, in <module>
from migrate.versioning import api
ImportError: No module named migrate.versioning
This is the db_create.py script:
#!flask/bin/python
from migrate.versioning import api
from config import SQLALCHEMY_DATABASE_URI
from config import SQLALCHEMY_MIGRATE_REPO
from app import db
import os.path
db.create_all()
if not os.path.exists(SQLALCHEMY_MIGRATE_REPO):
api.create(SQLALCHEMY_MIGRATE_REPO, 'database repository')
api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
else:
api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO, api.version(SQLALCHEMY_MIGRATE_REPO))
This is the config file it references:
#!/usr/bin/env python
import os
basedir = os.path.abspath(os.path.dirname(__file__))
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir, 'app.db')
SQLALCHEMY_MIGRATE_REPO = os.path.join(basedir, 'db_repository')
This application is being run with a virtual environment. This are the module that relates to it that I have installed in the environment:
sqlalchemy_migrate-0.7.2-py2.7.egg-info
Any help appreciated
pip install sqlalchemy==0.7.9
and
pip install sqlalchemy-migrate==0.7.2
and
optionally this flask-whooshalchemy==0.55a should solve the problem
ImportError: No module named migrate.versioning probably means the module is not installed. Make sure it has been installed in the correct virtual environment, it is activated (you ran the activate script in that environment) and the selected Python binary is actually making use of that environment (i.e. you are using Python2 and not Python3).
As said by #BoppreH earlier
ImportError: No module named migrate.versioning
means that the module named 'migrate' is not installed in your virtual environment or your system. First make sure that you are using the proper environment and that it is activated using the activate script.
I had the same problem and had the correct environment set up. But still the error was not solved.
What worked for me was installing the sqlalchemy-migrate package from pip. After activating my environment, I ran the following code to install it :
pip install sqlalchemy-migrate
flask/bin/pip install flask-sqlalchemy without defining the version worked fine for me.
run :
easy_install Flask-SQLAlchemy
to install Flask-SQLAlchemy
sudo pip install flask-migrate
to install flask-migrate
I think this error might pop up for several obscure reasons, I would like to add another which I experienced:
I had the same exact error while having sqlalchemy-migrate correctly installed, and guess what, it didn't work just because I had named the migration script file as migrate.py, this created some conflict with the migrate package.
In fact PyCharm warned me with this message:
"Import resolves to its containing file... This inspection detects names that should resolve but don't."
I renamed the migration script as db_migrate.py and everything started working fine.
I could understand what was the issue cause I had another project with an identical set-up but with migrate-sqlalchemy working perfectly and the only difference was indeed that file name...
Hope this might help someone one day...
I had the same problem - "No module named migrate.versioning", and everything is much easier than we are talking about, you need to perform the commands "run"
file: db_create.py or file: db_migrate.py if you using PyCharm (not from the terminal). And you will have the expected output: "New migration saved as D:...there is my path...\microblog\db_repositort/versions/001_migration.py
Current database version: 1"

Django installation has no __init__.py in django.core

I have a ubuntu lucid VPS server where I try to run my django development server.
Running python manage.py runserver gives me the following error:
Traceback (most recent call last):
File "manage.py", line 2, in <module>
from django.core.management import execute_manager
ImportError: No module named core.management
I can import django without any problem in a python shell. I looked in the django install directory and noticed there is no \__init__.py in the django/core folder. Which I beleive is the source of the problem for python to register django.core as a module.
It then looks like an installation issue. I installed django using apt-get.
FYI the django install worked perfectly on my home computer with same OS.
Any ideas?
solved.
Thank you for all the suggestions. I installed django using the tar ball as instructed in the django website.
apt-get is not a good idea to install django. I also had to manually remove the left over django folder in /usr/lib/pymodules/python2.6 after using apt-get remove.

Categories

Resources