Streamlit deploy error with cv2 and with streamlit lib - streamlit

ModuleNotFoundError: No module named 'cv2'
Traceback:
File "/usr/local/lib/python3.7/site-packages/streamlit/script_runner.py", line 332, in _run_script
exec(code, module.dict)
File "/app/pencilsketch_webapp/webapp.py", line 4, in
import cv2

Although I need to see your scripts and Procfile/Dockerfile for solving this properly but analyzing your error code I can see there is an issue with opencv.
A possible fix if it is purely related to deployment:
In the requirements.txt file put opencv-python instead of cv2

Related

import issue when transferred from py2 to py3

I have following directory structure:
content\ip_low_level\unit_tests\dd\dd.py
each directory has __init__.py
when I'm trying to run dd.py, it is giving following error:
Traceback (most recent call last):
File "content\ip_low_level\unit_tests\dd\dd.py", line 4, in <module>
from content.ip_low_level.unit_tests.dd.dd import dd
ModuleNotFoundError: No module named 'content'
It worked perfectly using python2. But getting issue when trying using
Python3. Why py3 can't find this module which is there? init is
suppose help find the module?
I went inside the directory where content statys and tried following.It seems has fixed the issue:
py3 -m pip install -e .

Apache Airflow initdb command fails, due to syntax error

I have created virtualenv for python3 using:
virtualenv -p $(which python3) ENV
Then activate the source
source /Users/myusername/ENV/bin/activate
Install the apache-airflow:
pip install apache-airflow
then which airflow yields /Users/myusername/ENV/bin/airflow
But when I try to initdb using:
airflow initdb
I get below error:
{db.py:350} INFO - Creating tables
INFO [alembic.runtime.migration] Context impl SQLiteImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
WARNI [airflow.utils.log.logging_mixin.LoggingMixin] cryptography not found - values will not be stored encrypted.
ERROR [airflow.models.DagBag] Failed to import: /Library/Python/2.7/site-packages/airflow/example_dags/example_http_operator.py
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/airflow/models/__init__.py", line 413, in process_file
m = imp.load_source(mod_name, filepath)
File "/Library/Python/2.7/site-packages/airflow/example_dags/example_http_operator.py", line 27, in <module>
from airflow.operators.http_operator import SimpleHttpOperator
File "/Library/Python/2.7/site-packages/airflow/operators/http_operator.py", line 21, in <module>
from airflow.hooks.http_hook import HttpHook
File "/Library/Python/2.7/site-packages/airflow/hooks/http_hook.py", line 23, in <module>
import tenacity
File "/Library/Python/2.7/site-packages/tenacity/__init__.py", line 375, in <module>
from tenacity.tornadoweb import TornadoRetrying
File "/Library/Python/2.7/site-packages/tenacity/tornadoweb.py", line 24, in <module>
from tornado import gen
File "/Library/Python/2.7/site-packages/tornado-6.0.3-py2.7-macosx-10.14-intel.egg/tornado/gen.py", line 126
def _value_from_stopiteration(e: Union[StopIteration, "Return"]) -> Any:
^
SyntaxError: invalid syntax
Done.
(ENV) ---------------------------------------------------------
Seems like example scripts use python 2.7 and it can't recognize the function definition syntax.
Does apache-airflow package need to be fixed by the next release or I can do something to fix this?
I tried fixing this:
Use python2.7 instead of python3
then install airflow on default python 2.7 enabled on mac but this throws other errors like package "six" is not compatible.
You need to turn off the example DAGs to be loaded in config file to solve this problem.
Anyway, it seems weird that airflow uses 2.7 Python when you told that it is installed into Python 3 virtual environment.

I get error "No module named 'pyproj._datadir'" after I made .py to .exe with pyinstaller [duplicate]

This question already has answers here:
Issues with pyinstaller and pyproj
(3 answers)
Closed 2 years ago.
My code works well when it's .py
but when I make .exe file with pyinstaller, it shows ModuleNotFoundError.
I write this when I made .exe
pyinstaller -F MyCode.py
How can I solve this problem?
I've read
Issues with pyinstaller and pyproj
and I was going to try to make and located hook-pyproj.py at "hooks" folder in Pyinstaller. but hook-pyproj.py was already there with the same code.
After that, I installed "basemap" and tried to use pyproj from it. However it shows me the same error.
This is the error it showed me when I execute the .exe file.
(I covered some information with *****)
Traceback (most recent call last):
File "collect\MyCode.py", line 8, in <module>
File "c:\users\*****\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\mpl_toolkits\basemap\__init__.py", line 41, in <module>
File "c:\users\*****\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\pyproj\__init__.py", line 62, in <module>
File "c:\users\*****\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\pyproj\crs.py", line 26, in <module>
File "pyproj\_crs.pyx", line 1, in init pyproj._crs
ModuleNotFoundError: No module named 'pyproj._datadir'
[25936] Failed to execute script MyCode
This is my code.
from mpl_toolkits.basemap import pyproj as pyproj
I tried this at first.
import pyproj
but I get same " ModuleNotFoundError: No module named 'pyproj._datadir' " error.
It's a bit odd and I don't exactly understand why but I found a quick dirty fix.
You can add this import
from pyproj import _datadir, datadir
to your existing one.
I noticed this pyproj import dll error error occurred on some Windows machines and not others.
Turned out to be a dependency on Visual C Runtime 2015+
https://support.microsoft.com/en-au/help/2977003/the-latest-supported-visual-c-downloads

How to install MongoDBLibrary for Robot Framework

I want to connect to Mongo DB using Robot Framework.
I have read in the following link that we have to pull the source code and install the library. Robot FrameWork - MongoDB-Library
I installed the Library and it is installed in the location
D:\Python27\Lib\site-packages\MongoDBLibrary
When I add 'MongoDBLibrary' library in the RIDE it showing in red (means library is not installed properly),
when i ran the same using eclipse + Maven project i got the following error
[ ERROR ] Error in file 'D:\Robot_WorkSpace\robotFrameWork\src\test\robotframework\acceptance\MongoQuery.txt': Importing test library 'D:\Python27\Lib\site-packages\MongoDBLibrary' failed: ImportError: No module named bson
Traceback (most recent call last):
File "D:\Python27\Lib\site-packages\MongoDBLibrary\__init__.py", line 2, in <module>
from mongoquery import MongoQuery
File "D:\Python27\Lib\site-packages\MongoDBLibrary\mongoquery.py", line 2, in <module>
from bson.objectid import ObjectId
PYTHONPATH:
C:\Users\akurasa\.m2\repository\org\robotframework\robotframework\3.0\Lib
C:\Users\akurasa\.m2\repository\org\robotframework\robotframework\3.0\robotframework-3.0.jar\Lib
__classpath__
__pyclasspath__/
CLASSPATH:
/D:/Sarada/eclipse/configuration/org.eclipse.osgi/bundles/789/1/.cp/jars/plexus-classworlds-2.4.jar
Please any one help me where i did wrong
Make sure you have installed PyMongo (or bson):
pip install pymongo
pip install bson (don't know if still required then)

plone Assertion error in themes

Iam new to Plone. I installed Plone 4 and i have gone through http://noenieto.com/blog/theming-plone-4 and created theme product.
When i run ./bin/buildout,
iam getting the error as
Develop: '/usr/local/Plone/zinstance/src/plonetheme.hanging'
error in plonetheme.hanging setup command: Distribution contains no modules or packages for namespace package 'plonetheme'
While:
Installing.
Processing develop directory '/usr/local/Plone/zinstance/src/plonetheme.hanging'.
An internal error occured due to a bug in either zc.buildout or in a
recipe being used:
Traceback (most recent call last):
File "/usr/local/Plone/buildout-cache/eggs/zc.buildout-1.4.4-py2.7.egg/zc/buildout/buildout.py", line 1683, in main
getattr(buildout, command)(args)
File "/usr/local/Plone/buildout-cache/eggs/zc.buildout-1.4.4-py2.7.egg/zc/buildout/buildout.py", line 417, in install
installed_develop_eggs = self._develop()
File "/usr/local/Plone/buildout-cache/eggs/zc.buildout-1.4.4-py2.7.egg/zc/buildout/buildout.py", line 657, in _develop
zc.buildout.easy_install.develop(setup, dest)
File "/usr/local/Plone/buildout-cache/eggs/zc.buildout-1.4.4-py2.7.egg/zc/buildout/easy_install.py", line 895, in develop
*args) == 0
AssertionError
Can anyone help me to rectify this error?
Create a module or package for namespace package 'plonetheme', e.g.:
mkdir -p src/plonetheme.hanging/plonetheme/hanging
touch src/plonetheme.hanging/plonetheme/__init__.py
touch src/plonetheme.hanging/plonetheme/hanging/__init__.py
src/plonetheme.hanging/plonetheme/__init__.py should contain something like:
from pkg_resources import declare_namespace
declare_namespace(__name__)

Resources