Using python-zxcvbn in Python 3.4 - python

I have been using the zxcvbn, which is a great piece of programming.
Especially, the port python-zxcvbn has been perfect for a small project I am doing.
Despite this, I am trying to invoke python-zxcvbn from Python 3.4 and I get errors like this:
Traceback (most recent call last):
File "entropy.py", line 7, in <module>
from zxcvbn import password_strength
File "/usr/lib/python3.4/site-packages/zxcvbn/__init__.py", line 1, in <module>
from zxcvbn import main
File "/usr/lib/python3.4/site-packages/zxcvbn/main.py", line 3, in <module>
from zxcvbn.matching import omnimatch
File "/usr/lib/python3.4/site-packages/zxcvbn/matching.py", line 89, in <module>
_load_frequency_lists()
File "/usr/lib/python3.4/site-packages/zxcvbn/matching.py", line 67, in _load_frequency_lists
dicts = json.loads(data)
File "/usr/lib/python3.4/json/__init__.py", line 312, in loads
s.__class__.__name__))
TypeError: the JSON object must be str, not 'bytes'
I have tried both installing the library from github, and with pip, with the same result.
To avoid that, I am currently running python2 in the module that uses zxcvbn, but I'd like to have a cleaner version of my project which runs fully with Python 3.4.
Is anyone successfully using python-zxcvbn with Python 3.4?

As answered by unutbu, there is a fork on github by moreati that is compatible with Python 3.4. It worked flawlessly for me.
https://github.com/moreati/python-zxcvbn

Related

Error while attempting to import openai's universe

While importing openai's universe, i get these errors:
Traceback (most recent call last):
File "/Users/calvin/Desktop/universe-test/main.py", line 2, in <module>
import universe
File "/Users/calvin/universe/universe/__init__.py", line 22, in <module>
from universe import error, envs
File "/Users/calvin/universe/universe/envs/__init__.py", line 1, in <module>
import universe.envs.vnc_env
File "/Users/calvin/universe/universe/envs/vnc_env.py", line 11, in <module>
from universe.envs import diagnostics
File "/Users/calvin/universe/universe/envs/diagnostics.py", line 94
async = self.qr_pool.apply_async(self.method, (self._last_img, time.time(), available_at))
^
SyntaxError: invalid syntax
I've tried downloading a different version of gym, reinstalling universe, and nothing works. I have python 3.8.5 64-bit. My operating system is macOS Catalina 10.15.6. Any ideas?
async is now a special keyword, and as such, can't be used as a variable name.
That library appears to be made for Python pre-3.5. I believe your only options are:
Use a older version of Python 3 (async was intrduced in 3.5).
Edit the local copy of the library file to change the name to something else.
Check to see if there are any updates/forks to the library that fix that issue.

Python 2.7 won't load any modules I installed. Will only load native modules that come with Python 2.7

Note: Please don't comment here that Python 2.7 is depreciated. I already know this. I need to get this working first before migrating to 3.x.
On Windows 10, I had installed (and running correctly) both Python 2.7 and Python 3.7. Since I only needed Python 2.7, I uninstalled Python 3.7 (and manually deleted respective packages installed under .\Python37*) as well as the virtual environment directory below. I have no idea if that virtual environment was associated with Python 2.7 or Python 3.7:
C:\Users\MKANET\Envs\MKA.NETT
After I rebooted, to my horror, every time I run a Python 2.7 script, I get a whole bunch of ambiguous traceback errors when trying to import modules I had installed with PIP (for Python 2.7). However, I don't have issues importing the modules like sys, json (packages that come preinstalled with Python 2.7).
When executing script below from Windows command-line:
& C:/Users/MKANET/AppData/Local/Programs/Python/python27/python.exe c:/Users/MKANET/OneDrive/Dev/Projects/Python/test2.py
...I get a bunch of ambiguous traceback errors:.
Traceback (most recent call last):
File "c:/Users/MKANET/OneDrive/Dev/Projects/Python/test2.py", line 3, in <module>
from pypsexec.client import Client
File "C:\Users\MKANET\AppData\Local\Programs\Python\python27\lib\site-packages\pypsexec\client.py", line 8, in <module>
from smbprotocol.connection import Connection, NtStatus
File "C:\Users\MKANET\AppData\Local\Programs\Python\python27\lib\site-packages\smbprotocol\connection.py", line 33, in <module>
from cryptography.hazmat.primitives.ciphers import (
File "C:\Users\MKANET\AppData\Local\Programs\Python\python27\lib\site-packages\cryptography\hazmat\primitives\ciphers\aead.py", line 10, in <module>
from cryptography.hazmat.backends.openssl import aead
File "C:\Users\MKANET\AppData\Local\Programs\Python\python27\lib\site-packages\cryptography\hazmat\backends\openssl\__init__.py", line 7, in <module>
from cryptography.hazmat.backends.openssl.backend import backend
File "C:\Users\MKANET\AppData\Local\Programs\Python\python27\lib\site-packages\cryptography\hazmat\backends\openssl\backend.py", line 16, in <module>
from cryptography import utils, x509
File "C:\Users\MKANET\AppData\Local\Programs\Python\python27\lib\site-packages\cryptography\x509\__init__.py", line 8, in <module>
from cryptography.x509.base import (
File "C:\Users\MKANET\AppData\Local\Programs\Python\python27\lib\site-packages\cryptography\x509\base.py", line 18, in <module>
from cryptography.x509.extensions import Extension, ExtensionType
File "C:\Users\MKANET\AppData\Local\Programs\Python\python27\lib\site-packages\cryptography\x509\extensions.py", line 26, in <module>
from cryptography.x509.general_name import GeneralName, IPAddress, OtherName
File "C:\Users\MKANET\AppData\Local\Programs\Python\python27\lib\site-packages\cryptography\x509\general_name.py", line 10, in <module>
from email.utils import parseaddr
File "c:\Users\MKANET\OneDrive\Dev\Projects\Python\email.py", line 11, in <module>
obj = win32com.client.Dispatch("Outlook.Application")
File "C:\Users\MKANET\AppData\Local\Programs\Python\python27\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch
dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
File "C:\Users\MKANET\AppData\Local\Programs\Python\python27\lib\site-packages\win32com\client\dynamic.py", line 114, in _GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "C:\Users\MKANET\AppData\Local\Programs\Python\python27\lib\site-packages\win32com\client\dynamic.py", line 91, in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
pywintypes.com_error: (-2147221005, 'Invalid class string', None, None)
UPDATE HUGE CLUE:
This is ONLY happens when executing scripts in the below folder:
C:\Users\Michael\OneDrive\Dev\Projects\Python
If I execute a script in any other folder on my C: Drive, modules load perfectly without errors. I don't know what's different about this folder that causes my modules not load. Maybe, there's a file in this folder that causing this?
Since this issue was limited only to scripts inside the below directory:
C:\Users\Michael\OneDrive\Dev\Projects\Python
I was able to narrow the issue down to a file called, email.py. If I tried to import a module for example, requests; for some odd reason an email.pyc would get created; followed by the import module errors. All I did was rename email.py to mail.py.. and, this whole issue finally stopped.
I have no idea why Python 2.7 is sensitive to that file name, but changing it to something else resolved the issue for me. Maybe, someone could comment on why the file name breaks things; especially when I had a __init__.py in the same directory to import another module.

Why python software package does not run under WSL2?

I wanted to use WSL2 Ubuntu to run some scientific programs on my PC (Phenix package). It used to work previously on wsl but after recent update to wsl2 one of the programs written in Python has some problems:
Traceback (most recent call last):
File "/mnt/f/cryoEM/phenix-1.18rc4-3812/build/../modules/phenix/wxGUI2/command_line/main.py", line 23, in <module>
run(sys.argv[1:])
File "/mnt/f/cryoEM/phenix-1.18rc4-3812/build/../modules/phenix/wxGUI2/command_line/main.py", line 16, in run
from wxGUI2 import App
File "/mnt/f/cryoEM/phenix-1.18rc4-3812/modules/phenix/wxGUI2/App.py", line 7, in <module>
from SimpleXMLRPCServer import SimpleXMLRPCServer
File "/mnt/f/cryoEM/phenix-1.18rc4-3812/conda_base/lib/python2.7/SimpleXMLRPCServer.py", line 105, in <module>
import BaseHTTPServer
File "/mnt/f/cryoEM/phenix-1.18rc4-3812/conda_base/lib/python2.7/BaseHTTPServer.py", line 102, in <module>
class HTTPServer(SocketServer.TCPServer):
AttributeError: 'module' object has no attribute 'TCPServer'
I have checked all the packages (BaseHTTPServer, SocketServer) and everything seems to be fine. Using python provided with the package and importing modules separately also works without errors. My previous computer also with WSL2 was running this software package without any issues. I believe that there is something missing on the wsl2 Ubuntu level but cannot guess what it is. Do you have any suggestions what I could try to do? Thanks!

'GLXPlatform' object has no attribute 'WGL'

I'm a beginner in OpenGL/OpenCL.
I'm trying to execute code from this
example, but there is an error:
Traceback (most recent call last):
File "/home/anka-rybalko/workspace/bla/openGL.py", line 99, in initializeGL
self.initialize_buffers()
File "/home/anka-rybalko/workspace/bla/openGL.py", line 61, in initialize_buffers
self.ctx, self.queue = clinit()
File "/home/anka-rybalko/workspace/bla/openGL.py", line 37, in clinit
+ get_gl_sharing_context_properties())
File "/usr/lib64/python2.7/site-packages/pyopencl-2014.1-py2.7-linux-x86_64.egg/pyopencl/tools.py", line 422, in get_gl_sharing_context_properties
from OpenGL import platform as gl_platform, GLX, WGL
File "/usr/lib/python2.7/site-packages/OpenGL/WGL/__init__.py", line 1, in <module>
from OpenGL.raw.WGL.VERSION.WGL_1_0 import *
File "/usr/lib/python2.7/site-packages/OpenGL/raw/WGL/VERSION/WGL_1_0.py", line 48, in <module>
#_p.types(_cs.c_int,_cs.HDC,ctypes.POINTER(_cs.PIXELFORMATDESCRIPTOR))
File "/usr/lib/python2.7/site-packages/OpenGL/raw/WGL/VERSION/WGL_1_0.py", line 13, in _f
return _p.createFunction( function,_p.PLATFORM.WGL,'WGL_VERSION_WGL_1_0',error_checker=_errors._error_checker)
AttributeError: 'GLXPlatform' object has no attribute 'WGL'
As I understand, WGL is an API for Windows OS and not for Linux. Should I somehow specify my platform before? Or how can I fix this?
Thanks in advance!
The code you are using (PyOpenGL 2014.1) is importing two platform-specific modules (WGL and GLX). PyOpenGL should have raised that error as an ImportError (rather than the AttributeError), but it still would have failed.
PyOpenCL has, in the meantime, worked around the issue in their github repository. If you have git installed (and pip) then this should get you a new version (note: not set up for OpenCL development here, so can't actually test this):
pip install git+https://github.com/pyopencl/pyopencl#egg=pyopencl

Running Panda3D on Python 2.6

I just got Panda3D for the first time. I deleted the included Python version. In my Python dir, I put a file panda.pth that looks like this:
C:\Panda3D-1.6.2
C:\Panda3D-1.6.2\bin
But when I run import direct.directbase.DirectStart, I get:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import direct.directbase.DirectStart
File "C:\Panda3D-1.6.2\direct\directbase\DirectStart.py", line 3, in <module>
from direct.showbase import ShowBase
File "C:\Panda3D-1.6.2\direct\showbase\ShowBase.py", line 10, in <module>
from pandac.PandaModules import *
File "C:\Panda3D-1.6.2\pandac\PandaModules.py", line 1, in <module>
from libpandaexpressModules import *
File "C:\Panda3D-1.6.2\pandac\libpandaexpressModules.py", line 1, in <module>
from extension_native_helpers import *
File "C:\Panda3D-1.6.2\pandac\extension_native_helpers.py", line 75, in <module>
Dtool_PreloadDLL("libpandaexpress")
File "C:\Panda3D-1.6.2\pandac\extension_native_helpers.py", line 73, in Dtool_PreloadDLL
imp.load_dynamic(module, pathname)
ImportError: Module use of python25.dll conflicts with this version of Python.
I'm assuming this has something to do with me using Python 2.6. Any solutions?
Python extensions aren't binary compatible across major releases. Your options are:
A. Recompile panda3d for python 2.6.
B. Use python 2.5.
No way around it.
If you can wait for the upcoming 1.7.0 release, it will be compiled against Python 2.6 - see this thread.

Categories

Resources