mysql for python 2. 7 says Python v2.7 not found - python

I have downloaded mysql-connector-python-1.0.7-py2.7.msi from MySQL site
and try to install but it gives error that
Python v2.7 not found. We only support Microsoft Windows Installer(MSI) from python.org.
I am using Official Python v 2.7.3 on windows XP SP3 with MySQL esssential5.1.66
Need Help ???

I met the similar problem under Windows 7 when installing mysql-connector-python-1.0.7-py2.7.msi and mysql-connector-python-1.0.7-py3.2.msi.
After changing from "Install only for yourself" to "Install for all users" when installing Python for windows, the "python 3.2 not found" problem disappear and mysql-connector-python-1.0.7-py3.2.msi was successfully installed.
I guess the problem is that mysql connector installer only looks for HKEY_LOCAL_MACHINE entries, and the things it looks for might be under HKEY_CURRENT_USER etc. So the solution that change the reg table directly also works.

The Solution I get for this problem is
I have found Adding Python to Registry, the script as follows applicable for python v 2.0 and above:
Register a Python Interpreter
#
# script to register Python 2.0 or later for use with win32all
# and other extensions that require Python registry settings
#
# written by Joakim Low for Secret Labs AB / PythonWare
#
# source:
# http://www.pythonware.com/products/works/articles/regpy20.htm
import sys
from _winreg import *
# tweak as necessary
version = sys.version[:3]
installpath = sys.prefix
regpath = "SOFTWARE\\Python\\Pythoncore\\%s\\" % (version)
installkey = "InstallPath"
pythonkey = "PythonPath"
pythonpath = "%s;%s\\Lib\\;%s\\DLLs\\" % (
installpath, installpath, installpath)
def RegisterPy():
try:
reg = OpenKey(HKEY_LOCAL_MACHINE, regpath)
except EnvironmentError:
try:
reg = CreateKey(HKEY_LOCAL_MACHINE, regpath)
SetValue(reg, installkey, REG_SZ, installpath)
SetValue(reg, pythonkey, REG_SZ, pythonpath)
CloseKey(reg)
except:
print "*** Unable to register!"
return
print "--- Python", version, "is now registered!"
return
if (QueryValue(reg, installkey) == installpath and
QueryValue(reg, pythonkey) == pythonpath):
CloseKey(reg)
print "=== Python", version, "is already registered!"
return
CloseKey(reg)
print "*** Unable to register!"
print "*** You probably have another Python installation!"
if __name__ == "__main__":
RegisterPy()
Save it with any name.
Run it from python interpreter and Thats ALL!!

This problem mainly comes with 64 bit windows. download MySQL for python 64 bit on this link http://www.codegood.com/archives/129 and download MySQL-python-1.2.3.win-amd64-py2.7.exe (1.0 MiB)
This will install MySQL for python.
Windows 10 (64bit):
Indeed, I've had a similar issue and couldn't install the python 2.7 connector for MySQL.
Prior to this I've installed Python 2.7.15 with the Windows x86-64 MSI installer,
this was while I had Python 3 installed on my machine.
The Windows x86 MSI installer did the trick, I've installed it to override the previous version of Python 2.7.15, then installed the connector (this time it gave no error messages).
Then rechecked the status in the MySQL installer and voilà:

If you're still experiencing this with x64 or other python modules, I'd recommend this website Python Extensions for x64/x32

I had this problem because I use Python only from within SPSS. I resolved this problem by manually adding two registry keys:
HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.7\InstallPath
set to
C:\Program Files\IBM\SPSS\Statistics\24\Python
and
HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.7\PythonPath
set to
C:\Program Files\IBM\SPSS\Statistics\24\Python\Lib
This easily fixed the issue on my previous as well as current laptops.

You need to make sure that you download the version with the correct "bitness" (32/64 bit), matching the "bitness" of your Python installation!
I ran into the same problem (with Python 3.7.2, though).
I had Python 3.7.2 32 bit already installed, but accidentally downloaded the 64 bit version of the MySQL Connector for Python 3.7.
When I tried to install the connector, I got the same error message:
Solution: I just downloaded the 32 bit version instead, and everything worked (installing the connector and actually connecting to the database)

In my case, I installed python 2.7.14 x64 only for my user. I have to look for this in my registry:
HKEY_CURRENT_USER\Software\Python
, export them, open the exported .reg file with a text editor, replace all occurrence of HKEY_CURRENT_USER with HKEY_LOCAL_MACHINE, and import it.
The result is: (remember to change the install dir to yours)
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\Software\Python]
[HKEY_LOCAL_MACHINE\Software\Python\PythonCore]
[HKEY_LOCAL_MACHINE\Software\Python\PythonCore\2.7]
[HKEY_LOCAL_MACHINE\Software\Python\PythonCore\2.7\Help]
[HKEY_LOCAL_MACHINE\Software\Python\PythonCore\2.7\Help\Main Python Documentation]
#="D:\\Desarrollo\\entornos\\python27_x64\\Doc\\python2714.chm"
[HKEY_LOCAL_MACHINE\Software\Python\PythonCore\2.7\InstallPath]
#="D:\\Desarrollo\\entornos\\python27_x64\\"
[HKEY_LOCAL_MACHINE\Software\Python\PythonCore\2.7\InstallPath\InstallGroup]
#="Python 2.7"
[HKEY_LOCAL_MACHINE\Software\Python\PythonCore\2.7\Modules]
[HKEY_LOCAL_MACHINE\Software\Python\PythonCore\2.7\PythonPath]
#="D:\\Desarrollo\\entornos\\python27_x64\\Lib;D:\\Desarrollo\\entornos\\python27_x64\\DLLs;D:\\Desarrollo\\entornos\\python27_x64\\Lib\\lib-tk"
And the installation afterwards is smooth as a breeze. Viola!

I solved this problem by using 32bit python

Related

How do I get libpq to be found by ctypes find_library?

I am building a simple DB interface in Python (3.9.9) and I am using psycopg (3.0.7) to connect to my Postgres (14.1) database. Until recently, the development of this app took place on Linux, but now I am using macOS Monterey on an M1 Mac mini. This seems to be causing some troubles with ctypes, which psycopg uses extensively. The error I am getting is the following:
ImportError: no pq wrapper available.
Attempts made:
- couldn't import psycopg 'c' implementation: No module named 'psycopg_c'
- couldn't import psycopg 'binary' implementation: No module named 'psycopg_binary'
- couldn't import psycopg 'python' implementation: libpq library not found
Based on the source code of psycopg, this is an error of ctypes not being able to util.find_library libpq.dylib. Postgres is installed as Postgres.app, meaning that libpq.dylib's path is
/Applications/Postgres.app/Contents/Versions/14/bin/lib
I have tried adding this to PATH, but it did not work. I then created a symlink to the path in /usr/local/lib, but (unsurprisingly) it also did not work. I then did some digging and found this issue describing the same problem. I am not a big macOS expert, so I am unsure on how to interpret some of the points raised. Do I need to add the path to the shared cache? Also, I do not want to fork the Python repo and implement the dlopen() method as suggested, as it seems to lead to other problems.
Anyhow, is there a solution to quickly bypass this problem? As an additional reference, the code producing the above error is just:
import psycopg
print(psycopg.__version__)
I had this problem but the solution was suggested to me by this answer to a related question: try setting envar DYLD_LIBRARY_PATH to the path you identified.
NB, to get it working myself, I:
used the path /Applications/Postgres.app/Contents/Versions/latest/lib and
had to install Python 3.9
The problem has solved itself by using psycopg2 instead of psycopg3, so it seems to be a problem of the latter. It would be still good to know why so as to solve it.
I got it to work by running:
pip uninstall psycopg
pip install "psycopg[c]"
This provides a local installation of psycopg3 which is needed since there are no binaries available for M1 macs. I installed postgresql (and libpg) via homebrew, running pg_config gives me a proper output.
Using the pure python package and setting the DYLD_LIBRARY_PATH didn't work for me.
A new way
This issue came up on my Windows laptop using Jupyter, although with WSL and Ubuntu it was fine...it was even fine using IntelliJ that was using python from Windows. I have a Mac Mini so I thought I'd test what I used instead pg8000
Now, pg8000 is a pure python implementation to connect to Postgresql. After a brew install of Postgres (and a few shenanigans with PSQL to get it working), this worked fine pip3 install pg8000
Basic Recipie
#!/usr/bin/env python3
import pg8000 as pg
def db_conn():
conn = pg.Connection(host='localhost',
database='dev_database',
user='postgres',
password='yourPassword!')
return conn
# Now you have a connection, query your data with a cursor
conn = db_conn()
cur = conn.cursor()
cur.execute('SELECT * FROM tab1')
data = cur.fetchall()
# Now 'data' contains your data, or use the new way with conn.run
if __name__ == '__main__':
print('Grabbing data from tab1...')
for row in conn.run('SELECT * FROM tab1'):
print(row)
conn.close()
It all seems pretty much the same as using psycopg, but the new method connection.run is pretty good too!

Can't "install" plpython3u - postgresql

I'm trying to use python language in postgresql. Something like this:
create or replace function test(_a integer) returns integer as $$
if _a%2==0:
return 'even'
elif _a%3==0:
return 'mult of 3'
else:
return _a
$$ language plpython3u
But when I run this, I get this error:
ERROR: language "plpython3u" does not exist
HINT: Use CREATE EXTENSION to load the language into the database.
SQL state: 42704
Then, I tried to create the extension of the python language by executing:
create extension plpython3u
Which tells me the following error:
ERROR: could not load library "C:/Program Files/PostgreSQL/12/lib/plpython3.dll": The specified module could not be found.
SQL state: 58P01
I checked if the plpython3.dll file is there. Then I read something about modifying the postgresql configure file by compiling postgres from the source code and adding --with python (I found some of this here).
My problem is that I don't know how to actually do this. My OS is windows server 2019 64 bits, python version is 3.7.4 and postgresql version is 12.2-1 (pgadmin 4.18).
How can I solve this?
Getting python to work with postgres seems to be version or versions dependent. I currently have postgres 9.6. and I had installed python 3.9. I had previously installed the extension plpython3u in postgres but time had gone by and I moved to another computer. When I tried to run a procedure based on Python, I got an error. I downloaded dependency walker, from here: https://www.opcsupport.com/s/article/How-do-I-figure-out-why-my-DLL-is-failing-Microsoft-Dependency-Walker or here: https://www.dependencywalker.com/. When I opened up the dependency walker, I dragged the plpython3.dll into the dependency walker, the .dll is located here: F:\pg96\lib. I then got the following screen -- below -- that seemed to indicate I needed to install a Python 3.7. I downloaded Python 3.7 from here: https://www.python.org/downloads/windows/. And my python procedures now worked.
No need to build from source, which would require that you install a C compiler, which is non-trivial on Windows.
You never told us if python3.dll was present in the directory or not, so I'll assume it was there. Then the error would indicate that a shared library that python3.dll links with is missing, most likely from Python 3. Installing Python 3 will probably solve the problem.

How to use the combrowser.py within the pywin32 package?

I'm using the package pywin32 to control some executables. To check the list of applications I would like to use the "combrowser.py". I'm trying to start the file, but I'm getting the message:
File "combrowse.py", line 540
print "Warning - exiting with %d/%d objects alive" % (ni,ng)
^
SyntaxError: invalid syntax
My system:
Windows 7 / 64 bits
Python 3.7.1
Any idea?
I was using a wrong version of python (3.7 intead 2.7) to try to run this program. After, I installed the pywin32 package and searched at the site-package folder. It's a little bit of mess, but I found the candidates folders for search:
pywin32_system32
pywin32-224.dist-info
win32com
win32comnext
I noted that the folder starting with "pywin32" were almost empty with some dll files and other data. Thereafter, I tried win32com folder and searched a little bit. I found the "combrowser.py"!
Just runned normaly and worked.

How to judge which version of .whl file is supported when install a Python package

Recently, I just try to connect my SQL Server in python. So I just download the .whl file from "http://www.lfd.uci.edu/~gohlke/pythonlibs/#pymssql".
in cmd windows, I use the following command:
pip install some-package.whl
My pc is window 64bit, I tried all the .whl files in the following.
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pymssql
pymssql‑1.0.3‑cp27‑none‑win32.whl
pymssql‑2.1.3‑cp27‑cp27m‑win32.whl
pymssql‑2.1.3‑cp27‑cp27m‑win_amd64.whl
pymssql‑2.1.3‑cp34‑cp34m‑win32.whl
pymssql‑2.1.3‑cp34‑cp34m‑win_amd64.whl
pymssql‑2.1.3‑cp35‑cp35m‑win32.whl
pymssql‑2.1.3‑cp35‑cp35m‑win_amd64.whl
pymssql‑2.1.3‑cp36‑cp36m‑win32.whl
pymssql‑2.1.3‑cp36‑cp36m‑win_amd64.whl
But failed to install, with the error message, the .whl file is not supported in this system. what should I do. Can somebody help me.
The simplest procedure that helped me is:
Step 1: Open cmd as an administrator
Step 2: Type python and press Enter
You will get something like this
Here, you can see your Python version and the CPU Architecture
Step 3: Go on https://www.lfd.uci.edu/~gohlke/pythonlibs/#pymssql and select .whl file that support both, python version and also the CPU architecture. i.e. the supported file for me will be pymssql‑2.2.2‑cp39‑cp39‑win_amd64.whl where cp39 means the python version that is 3.9 in my case, and amd64 is the CPU architecture.
Step 4: Go the folder where you have downloaded the required file and in the address bar type cmd or you can open cmd as an admin and move to the download directory
Step 5: Copy name of the required downloaded file along with extension and Run the following command
pip install pymssql‑2.2.2‑cp39‑cp39‑win_amd64.whl
That's all. You can use this method for any file from this website. This method is working for me perfectly
I faced the same issue. It goes with version of Python installed on your system if it is 32 bit Python Version or 64 bit Python.
So cp36 as I have python 3.6 and win32 as Python is 32 bit according to my system.
I worked for me.
I hope this helps.
whl naming structure:
{distribution}-{version}(-{build tag})?-{python tag}-{abi
tag}-{platform tag}.whl
in your case you need to know your python --version (python tag cp27 for python2.7 etc) and your cpu architecture .
Faced the same issue,
All you need to do is change the name of your whl file:
Change up to the installed python distribution
Then none for the python version and any for the platform
Should be something like
pymssql‑2.1.3‑cp3‑none‑eny.whl
You can do this using packaging.
pip install packaging
You can use this simple function compatible_wheels I wrote using packaging to filter out for the compatible wheels for your system:
from packaging.tags import sys_tags
def parse_tag(wheel_filename):
"""
Example:
>>> parse_tag('pymssql-2.2.1-cp36-cp36m-manylinux2010_i686.whl')
'cp36-cp36m-manylinux2010_i686'
"""
return '-'.join(wheel_filename.split('-')[2:])[:-4]
def compatible_wheels(wheel_filenames):
tags = [str(tag) for tag in sys_tags()]
return [
f
for f in wheel_filenames
if parse_tag(f) in tags
]
Example usage
>>> wheel_filenames = [
'pymssql-2.2.1-cp36-cp36m-manylinux2010_i686.whl',
'pymssql-2.2.1-cp36-cp36m-manylinux2014_i686.whl',
'pymssql-2.2.1-cp37-cp37m-manylinux1_i686.whl',
'pymssql-2.2.1-cp39-cp39-manylinux2014_i686.whl',
'pymssql-2.2.1-cp37-cp37m-win32.whl',
'pymssql-2.2.1-cp36-cp36m-manylinux_2_24_x86_64.whl',
'pymssql-2.2.1-cp37-cp37m-manylinux2010_x86_64.whl',
'pymssql-2.2.1-cp37-cp37m-manylinux2014_i686.whl',
'pymssql-2.2.1-cp38-cp38-manylinux2014_i686.whl',
'pymssql-2.2.1-cp36-cp36m-manylinux_2_24_i686.whl',
'pymssql-2.2.1-cp38-cp38-macosx_10_14_x86_64.whl',
'pymssql-2.2.1-cp38-cp38-manylinux2014_x86_64.whl',
'pymssql-2.2.1-cp38-cp38-win_amd64.whl',
'pymssql-2.2.1-cp39-cp39-win32.whl',
'pymssql-2.2.1-cp39-cp39-manylinux_2_24_x86_64.whl',
'pymssql-2.2.1-cp39-cp39-win_amd64.whl',
'pymssql-2.2.1-cp39-cp39-manylinux2014_x86_64.whl',
'pymssql-2.2.1-cp38-cp38-manylinux2010_x86_64.whl',
'pymssql-2.2.1-cp38-cp38-manylinux_2_24_x86_64.whl',
'pymssql-2.2.1-cp38-cp38-win32.whl',
'pymssql-2.2.1-cp39-cp39-manylinux2010_i686.whl',
'pymssql-2.2.1-cp39-cp39-manylinux_2_24_i686.whl',
'pymssql-2.2.1-cp37-cp37m-macosx_10_14_x86_64.whl',
'pymssql-2.2.1-cp37-cp37m-manylinux2010_i686.whl',
'pymssql-2.2.1-cp38-cp38-manylinux1_i686.whl',
'pymssql-2.2.1-cp38-cp38-manylinux_2_24_i686.whl',
'pymssql-2.2.1-cp37-cp37m-manylinux2014_x86_64.whl',
'pymssql-2.2.1-cp36-cp36m-manylinux2010_x86_64.whl',
'pymssql-2.2.1-cp39-cp39-manylinux1_x86_64.whl',
'pymssql-2.2.1-cp36-cp36m-manylinux1_x86_64.whl',
'pymssql-2.2.1-cp37-cp37m-manylinux1_x86_64.whl',
'pymssql-2.2.1-cp39-cp39-manylinux1_i686.whl',
'pymssql-2.2.1-cp36-cp36m-manylinux1_i686.whl',
'pymssql-2.2.1-cp36-cp36m-manylinux2014_x86_64.whl',
'pymssql-2.2.1-cp37-cp37m-manylinux_2_24_i686.whl',
'pymssql-2.2.1-cp37-cp37m-manylinux_2_24_x86_64.whl',
'pymssql-2.2.1-cp37-cp37m-win_amd64.whl',
'pymssql-2.2.1-cp38-cp38-manylinux2010_i686.whl',
'pymssql-2.2.1-cp38-cp38-manylinux1_x86_64.whl',
'pymssql-2.2.1-cp39-cp39-macosx_10_14_x86_64.whl',
'pymssql-2.2.1-cp39-cp39-manylinux2010_x86_64.whl',
]
>>> compatible_wheels(wheel_filenames)
['pymssql-2.2.1-cp39-cp39-manylinux_2_24_x86_64.whl', 'pymssql-2.2.1-cp39-cp39-manylinux2014_x86_64.whl', 'pymssql-2.2.1-cp39-cp39-manylinux1_x86_64.whl', 'pymssql-2.2.1-cp39-cp39-manylinux2010_x86_64.whl']
# Note: I get the above output because I am using Linux. You may be getting the wheels for windows accordingly based on your system.

PyUSB - No Backend Available (Windows 10) Any solutions? [duplicate]

I'm trying to have my Python application interface with an NFC device via USB.
The best option seems to be PyUSB, but I can't get it to connect to the libusb backend.
I keep getting
ValueError: No backend available
I've looked at the stack trace, and found that usb/backend/libusb10.py (which is part of pyusb) is trying to load libusb-1.0.dll to use as the backend, but it can't find it. It's not that it's not in my path, it's not on my computer at all!
I have installed libusb-win32, but the resulting directory only seems to include libusb0.dll. Where is libusb-1.0.dll???!
I would love to know either where to get that dll, or even a different suggestion to get PyUSB to work on Windows 7.
Download and install libusb-win32-devel-filter-1.2.6.0.exe. It should work.
2021 and the problem still occurs on Windows (Windows 10). I solved it by installing pyusb and libusb and adding libusb path to Windows environment:
pip install pyusb
pip install libusb
libusb-1.0.dll will be automatically added to:
\venv\Lib\site-packages\libusb\_platform\_windows\x64
and
\venv\Lib\site-packages\libusb\_platform\_windows\x32
Now just add those paths (the full path) to Windows Path and restart CMD / PyCharm.
I had a similar issue recently trying to talk to a USB device I am developing. I scoured the web looking for libusb-1.0.dll's and had no luck. I found source code, but nothing built and ready to install. I ended up installing the libusb-win32 binaries, which is the libusb0.dll.
PyUSB will search for libusb-1.0, libusb0, and openUSB backends.
libusb0.dll was already on my system, but something was still not set up right, do PyUSB was not working.
I followed the directions here to download and install the driver using the GUI tools provided to install the filter driver, and the INF wizard. Note, it didn't work until I ran the INF wizard.
I'm pretty new to programming and I've found the lack of clear documentation/examples to string this all together rather frustrating.
I am using Python 2.6.5, libusb-win32-device.bin-0.1.12.1 and pyusb-1.0.0-a0 on a windows XP system and kept receiving ValueError: No backend available.
Since there wasn't any real help on the web for this problem I spent a lot of time finding that ctypes util.py uses the Path variable to find the library file. My path did not include windows\system32 and PYUSB didn't find the library. I updated the path variable and now the USB is working.
There's a simpler solution.
Download and unpack to C:\PATH the libusb-1.0.20 from download link
Then try this line:
backend = usb.backend.libusb1.get_backend(find_library=lambda x: "C:\PATH\libusb-1.0.20\MS32\dll\libusb-1.0.dll")
dev = usb.core.find(backend=backend, find_all=True)
Depending on your system, try either MS64 or MS32 version of the .dll
Update of 17/01/2020, after a request to share more code:
import usb.core
import usb.util
from infi.devicemanager import DeviceManager
dm = DeviceManager()
devices = dm.all_devices
for i in devices:
try:
print ('{} : address: {}, bus: {}, location: {}'.format(i.friendly_name, i.address, i.bus_number, i.location))
except Exception:
pass
import usb.backend.libusb1
backend = usb.backend.libusb1.get_backend(find_library=lambda x: "C:\\libusb-1.0.20\\MS32\\dll\\libusb-1.0.dll")
dev = usb.core.find(backend=backend, find_all=True)
def EnumerateUSB(): #I use a simple function that scans all known USB connections and saves their info in the file
with open("EnumerateUSBLog.txt", "w") as wf:
counter = 0
for d in dev:
try:
wf.write("USB Device number " + str(counter) + ":" + "\n")
wf.write(d._get_full_descriptor_str() + "\n")
wf.write(d.get_active_configuration() + "\n")
wf.write("\n")
counter += 1
except NotImplementedError:
wf.write("Device number " + str(counter) + "is busy." + "\n")
wf.write("\n")
counter += 1
except usb.core.USBError:
wf.write("Device number " + str(counter) + " is either disconnected or not found." + "\n")
wf.write("\n")
counter += 1
wf.close()
I had the same problem with Windows 10, both Python 2.7.16 and Python 3.7.2. I installed libusb (through python -m pip install libusb ) but the error message remained. Also, the advice above about installing libusb-win32 did not work for me; neither of the 2 links (original post and #beebek's answer) existed.
What did work, however, is the comment by #user1495323 : I copied libusb-1.0.dll from
C:\Users\username\AppData\Roaming\Python\Python27\site-packages\libusb\_platform\_windows\x64\
to C:\Windows\System32\
download the latest libusb
Download libusb
Copy MS32\dll\libusb-1.0.dll to C:\Windows\SysWOW64
Copy MS64\dll\libusb-1.0.dll to C:\Windows\System32
3.
pip install libusb
Copy MS32\dll\libusb-1.0.dll to C:\Python\Python37-32\Lib\site-packages\libusb_platform_windows\x86
Copy MS64\dll\libusb-1.0.dll to C:\Python\Python37-32\Lib\site-packages\libusb_platform_windows\x64
This method works for me.
Had some problems with backendnotavailable at 2022 when I install pyusb and libusb on my Windows x64.
I've found a way to solve it reading -> Github solve explaining
To solve, first you need copy path to libusb-1.0.dll (..\envs<your_env_name>\Lib\site-packages\libusb_platform_windows\x64) at system's PATH variable.
Secondly restart IDE.
Third try to get_backend use usb.backend:
import usb.core
from usb.backend import libusb1
# it should find libusb-1.0.dll at our path variable
back = libusb1.get_backend()
print(type(back)) # return: <class 'usb.backend.libusb1._LibUSB'>
dev = usb.core.find(backend=back)
print(type(dev)) # return: <class 'usb.core.Device'>
# flag 'find_all=True' would return generator
# reprecent connected usb devices
dev_list = usb.core.find(find_all=True, backend=back)
print(type(dev_list)) # return: <class 'generator'>
If back is a NoneType, that means get_backend() hasn't found libusb-1.0.dll or found the wrong usblib (and that was my problem - I copied atPATH variable path to _x86 file, on my x64 machine).
Another way to solve it -> copy libusb-1.0.dll from (.._x64\libusb-1.0.dll) to (C:\Windows\System32).
"There are two versions of the libusb API: the current libusb-1.0 API, and its legacy predecessor libusb-0.1." (http://www.libusb.org/) "libusb-win32 is a port of the USB library ​libusb-0.1 to the Microsoft Windows operating systems". "Download the latest release tarball" from the same page (1.0.9 is the current version) to have libusb-1.0 equivalent, you'll find a folder Win32, where you'll find your libusb-1.0.dll to play with! You can even build it: http://www.libusb.org/wiki/windows_backend.
EDIT
You have to build it (download from/ http://sourceforge.net/projects/libusb/files/libusb-1.0/) since the tarball is from 2012, while the latest sources are from 2014-06-15.
To connect to your NFC device via USB using PYUSB, you will need to install the backend for that device. I do not think there is any backend for any device other than a libusb device.
To build a backend. You will need to know the driver (.sys file) for your device, so you could write a wrapper DLL to expose functionalities in the device. Your DLL would have to have a method to find device based on PID & VID, another method to open device and another method to send data and so on...
Just in case:
I haven't tried this on Windows but I had to set DYLD_LIBRARY_PATH path to circumvent this error on the Macintosh.
export DYLD_LIBRARY_PATH=/opt/local/lib
Discussion on whether or not to set this variable is here.
The libusb backend is initialized by the python script in /usb path,by loading the binary DLL from Windows PATH,if it's missed or installed by the zadig's dummy DLL,it will complained about this.Because the DLL installed by zadig doesn't exports any symbol to outside wolrd(dummy one I guess)

Categories