ModuleNotFoundError: No module named 'cryptography.hazmat.bindings._padding' - cryptography

I have installed the package cryptography using pip in order to use the UserManager class from Flask-User. However, when running my code I get the following error:
File "c:\Users\env\lib\site-packages\cryptography\hazmat\primitives\padding.py", line 13, in <module>
from cryptography.hazmat.bindings._padding import lib
ModuleNotFoundError: No module named 'cryptography.hazmat.bindings._padding
How can I solve this error? When looking in the 'site-packages' folder of my virtual environment, I see that the file it wants to import is called _padding-cp38-win32.pyd instead of just _padding. Does this matter? Can someone please help me?
I am using Python v3.8.6, Flask-User v1.0.2.2, and Cryptography v3.2.1.

Related

Cannot import sentinelsat python module

I am a python newbie and am trying to get the sentinelhub module to work but have been receving this error message on my code:
import sentinelhub
Traceback (most recent call last):
File "<pyshell#0>", line 1, in
import sentinelhub
ImportError: No module named sentinelhub
After I've downloaded the module using "pip install sentinelhub" on the windows command. I am currently using Python version 2.7.18. Any suggestions would be helpful. Thanks.
It looks like sentinelhub requires a different version of Python.
From their own website they specify that it "requires Python >=3.7"
https://sentinelhub-py.readthedocs.io/en/latest/install.html

Tensorflow 2x - ModuleNotFoundError: No module named 'tensorflow.contrib'

I'm working on a Tensorflow project that needs to be upgraded to use tensorflow==2.2.0, and can no longer work with Tensorflow 1.x, due to comparability with other packages.
However, after upgrading, I'm getting the below error:
File "/opt/app-root/lib/python3.6/site-packages/tflearn/__init__.py", line 4, in <module>
from . import config
File "/opt/app-root/lib/python3.6/site-packages/tflearn/config.py", line 5, in <module>
from .variables import variable
File "/opt/app-root/lib/python3.6/site-packages/tflearn/variables.py", line 7, in <module>
from tensorflow.contrib.framework.python.ops import add_arg_scope as contrib_add_arg_scope
ModuleNotFoundError: No module named 'tensorflow.contrib'
The only help I can find regarding this error is to downgrade.
What, if any, is the recommend approach to migrate up to Tensorflow 2.x when using tflearn?
It is not directly possible. You have to rebuild different routines and several functions need to be altered accordingly. There are not 100% differences between 1.X and 2.X version, but at-least some functions are new and some old options are deprecated. If you upgrade step by step, you can see there are deprecation warnings for next level upgradations.

Run Python, Anaconda, Pandas, Numpy offline on a Server getting dependency error

After installing Anaconda on a Virtual Machine I run a script which is working on my local machine but not on my Virtual Machine.
I'm getting the error Message:
C:\Users\...\python>"C:\ProgramData\Anaconda3\python.exe" "C:\Users\...\reporting.py"
C:\ProgramData\Anaconda3\lib\site-packages\numpy\__init__.py:140: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-service
from . import _distributor_init
Traceback (most recent call last):
File "C:\Users\...\reporting.py", line 1, in <module>
import pandas as pd
File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\__init__.py", line 16, in <module>
raise ImportError(
ImportError: Unable to import required dependencies:
numpy:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.8 from "C:\ProgramData\Anaconda3\python.exe"
* The NumPy version is: "1.18.5"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: DLL load failed while importing _multiarray_umath: The specified module could not be found.
The VM has no Internet. Is there any way to install all the required libs and frameworks?
You can package your script and used libraries using something like Pyinstaller. When you use an virtualenv keep in mind that all the packages that you use during pyinstaller execution are stored and may lead to an huge .exe

No module named lstm_predictor

When I am trying to import the following module,
>>> from lstm_predictor import lstm_model
The error says no module named lstm_predictor.
How can I solve the problem?
It seems like you are utilizing the lstm_predictor package present in https://github.com/tgjeon/TensorFlow-Tutorials-for-Time-Series.
Since this is not a standard module, make sure you have cloned this project and you have the lstm_predictor.py file in the same folder as your python terminal.

Cannot import "logging" module using Jython in embedded Jetty -> ImportError: no os specific module found

I'm trying to use Jython (embedded) in a Jetty server (all through Maven) to invoke a simple Python script.
My script works fine as long as I don't try to use any of the standard library's such as 'logging.' Whenever I try to import one of the standard library's it fails with the exception "ImportError."
The exception I get is:
File "<string>", line 1, in <module>
File "c:\home\work\sample\content\helloworld\helloworld.py", line 10, in <module>
import logging
File "c:\home\work\sample\content\Lib\logging\__init__.py", line 29, in <module>
import sys, os, types, time, string, cStringIO, traceback
File "c:\home\work\sample\content\Lib\os.py", line 119, in <module>
raise ImportError, 'no os specific module found'
ImportError: no os specific module found
at org.python.core.PyException.fillInStackTrace(PyException.java:70)
at java.lang.Throwable.<init>(Throwable.java:181)
at java.lang.Exception.<init>(Exception.java:29)
at java.lang.RuntimeException.<init>(RuntimeException.java:32)
at org.python.core.PyException.<init>(PyException.java:46)
at org.python.core.PyException.doRaise(PyException.java:200)
at org.python.core.Py.makeException(Py.java:1159)
at org.python.core.Py.makeException(Py.java:1163)
at os$py.f$0(c:\home\work\sample\content\Lib\os.py:692)
at os$py.call_function(c:\home\work\sample\content\Lib\os.py)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.imp.createFromCode(imp.java:325)
at org.python.core.imp.createFromPyClass(imp.java:144)
at org.python.core.imp.loadFromSource(imp.java:504)
at org.python.core.imp.find_module(imp.java:410)
at org.python.core.imp.import_next(imp.java:620)
at org.python.core.imp.import_first(imp.java:650)
at org.python.core.imp.import_name(imp.java:741)
at org.python.core.imp.importName(imp.java:791)
at org.python.core.ImportFunction.__call__(__builtin__.java:1236)
at org.python.core.PyObject.__call__(PyObject.java:367)
at org.python.core.__builtin__.__import__(__builtin__.java:1207)
at org.python.core.__builtin__.__import__(__builtin__.java:1190)
at org.python.core.imp.importOne(imp.java:802)
at logging$py.f$0(c:\home\work\sample\content\Lib\logging\__init__.py:1372)
at logging$py.call_function(c:\home\work\sample\content\Lib\logging\__init__.py)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.imp.createFromCode(imp.java:325)
at org.python.core.imp.createFromPyClass(imp.java:144)
at org.python.core.imp.loadFromSource(imp.java:504)
at org.python.core.imp.find_module(imp.java:410)
at org.python.core.imp.import_next(imp.java:620)
at org.python.core.imp.import_first(imp.java:650)
at org.python.core.imp.import_name(imp.java:741)
at org.python.core.imp.importName(imp.java:791)
at org.python.core.ImportFunction.__call__(__builtin__.java:1236)
at org.python.core.PyObject.__call__(PyObject.java:367)
at org.python.core.__builtin__.__import__(__builtin__.java:1207)
at org.python.core.__builtin__.__import__(__builtin__.java:1190)
at org.python.core.imp.importOne(imp.java:802)
at helloworld.helloworld$py.f$0(c:\home\work\sample\content\helloworld\helloworld.py:19)
at helloworld.helloworld$py.call_function(c:\home\work\sample\content\helloworld\helloworld.py)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.imp.createFromCode(imp.java:325)
at org.python.core.imp.createFromPyClass(imp.java:144)
at org.python.core.imp.loadFromSource(imp.java:504)
at org.python.core.imp.find_module(imp.java:410)
at org.python.core.PyModule.impAttr(PyModule.java:109)
at org.python.core.imp.import_next(imp.java:622)
at org.python.core.imp.import_name(imp.java:761)
at org.python.core.imp.importName(imp.java:791)
at org.python.core.ImportFunction.__call__(__builtin__.java:1236)
at org.python.core.PyObject.__call__(PyObject.java:367)
at org.python.core.__builtin__.__import__(__builtin__.java:1207)
at org.python.core.imp.importFromAs(imp.java:869)
at org.python.core.imp.importFrom(imp.java:845)
at org.python.pycode._pyx1.f$0(<string>:1)
at org.python.pycode._pyx1.call_function(<string>)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1197)
at org.python.core.Py.exec(Py.java:1241)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:138)
My scripts looks like:
from java.util import Random
from java.util import Date
import sys
print(sys.path)
print(sys.builtin_module_names)
import logging
logging.basicConfig(level=logging.WARNING)
logger1 = logging.getLogger('aaa')
logger1.warning('************* This message comes from one module')
def say_hello():
return 'hello world1'
I've tried the following so far but nothing has worked:
Include the zip of the 'Lib' directory in my classpath
Hard-coding the 'Lib' path when i setup the interpreter.
If I do it directly from the interactive Jython shell the script works fine (and a logging message appears).
Thanks.
KJQ
I think for now i've found an answer to my own question...
Basically, i knew it had something to do with my paths but could not figure out how to do them.
I ended up creating a "standalone" version of the Jython jar through the installer (and it includes the /Libs directory) and using that.