installing mysql for python 2.7 - python

D:\PythonPack\MySQL-python-1.2.3>python setup.py install
Traceback (most recent call last):
File "setup.py", line 15, in <module>
metadata, options = get_config()
File "D:\PythonPack\MySQL-python-1.2.3\setup_windows.py", line 7, in get_confi
g
serverKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, options['registry_ke
y'])
WindowsError: [Error 2] The system cannot find the file specified
I am trying to install mysqldb for python in windows7 and run into that error message
Do you have an idea how I can make it work ? I already have pythonsetuptool installed

Actually there are many ways and i tried them for few hours and realize its time waste process bcoz MYSQLdb is vary from version to version i.e 2.6,2.7 and 3.2 but all those are confuse and time waste processes,
Instead best way is to get precompiled executables from : http://www.lfd.uci.edu/~gohlke/pythonlibs .
here choose version wise links like python 2.7 and 32bit so that you won't get any errors and now run the downloaded file, finally set path in environment variables.
Now open python IDLE editor or from command prompt c:>python
import MySQLdb
if u don't get any errors then it's working fine...enjoy with u r work

Just install with the exe from here.
And maybe you can find more information about this in the previous asked questions like this.

Related

pip install py2neo failing

I am trying to install py2neo module but ending with below error. Please help me to resolve it.
(base) C:\Users\ADMIN>pip install py2neo Collecting py2neo Using cached https://files.pythonhosted.org/packages/cd/79/a77cc0ad86c021c25dac9f52a0cd33f6832c6af7fa5e58f4438d781ae9c3/py2neo-4.0.0.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\users\admin\appdata\local\temp\pip-install-xj8t67\py2neo\setup.py", line 25, in <module>
from py2neo.meta import __author__, __email__, __license__, __package__, __version__
File "py2neo\__init__.py", line 19, in <module>
from py2neo.data import *
File "py2neo\data.py", line 26, in <module>
from py2neo.cypher import LabelSetView, cypher_repr, cypher_str
File "py2neo\cypher\__init__.py", line 36, in <module>
from py2neo.internal.collections import SetView
File "py2neo\internal\collections.py", line 24, in <module>
from py2neo.internal.compat import bytes_types, string_types
File "py2neo\internal\compat.py", line 45, in <module>
DEVNULL = open(devnull, "rw")
ValueError: Invalid mode ('rw')
Command "python setup.py egg_info" failed with error code 1 in c:\users\admin\appdata\local\temp\pip-install-xj8t67\py2neo\
I tried to upgrade setuptools and pip too but didn't able to install py2neo after that also.
My python version is 2.7 and working on win 10 OS.
try this as well :
This is the basic requirements :
Python 2.7 / 3.4 / 3.5 / 3.6 / 3.7
Neo4j 3.2 / 3.3 / 3.4 / 3.5 (the latest point release of each version is recommended)
pip install git+https://github.com/technige/py2neo.git#egg=py2neo
This is a bug in the library. It is illegal to open a file with mode "rw", and they're clearly doing it. You can see the code here. It should almost certainly be using "r+" here.
It's worth noting that this piece of code only runs on old versions of Python, before subprocess.DEVNULL was added in 3.3. While 2.7 is still listed as officially supported, it seems to be in "legacy mode", with a bunch of "compat" code that tries to make 2.7 act like 3.3+, including this line, and some of that compat code is probably not heavily tested.
Also, this piece of code may only be needed on Windows. If so, as the README says:
Note also that Py2neo is developed and tested under Linux using standard CPython distributions. While other operating systems and Python distributions may work, support for these is not available.
So, the fact that their 2.7 compat code is broken on a platform they don't support isn't all that surprising…
What can you do about it?
Try running Python 3.7 or 3.6 instead of 2.7. That will definitely eliminate this problem, and possibly others that you haven't run into yet.
Run a linux VM (/container/user-mode kernel/whatever), and install Python (ideally 3.7) and py2neo under linux. This will definitely eliminate this problem, and possibly others.
Fix the bug yourself and submit a pull request.
File a bug report and wait and see if someone fixes it.

Python module sqlite3 cannot be found, but is listed [duplicate]

I would like to have an interface between Python and sqlite. Both are installed on the machine. I had an old version of Python (2.4.3). So, pysqlite was not included by default. First, I tried to solve this problem by installing pysqlite but I did not succeed in this direction. My second attempt to solve the problem was to install a new version of Python. I do not have the root permissions on the machine. So, I installed it locally. The new version of Python is (2.6.2). As far as I know this version should contain pysqlite by default (and now it is called "sqlite3", not "pysqlite2", as before).
However, if I type:
from sqlite3 import *
I get:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/verrtex/opt/lib/python2.6/sqlite3/__init__.py", line 24, in <module>
from dbapi2 import *
File "/home/verrtex/opt/lib/python2.6/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: No module named _sqlite3
It has to be noted, that the above error message is different from those which I get if I type "from blablabla import *":
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named blablabla
So, python see something related with pysqlite but still has some problems. Can anybody help me, pleas, with that issue?
P.S.
I use CentOS release 5.3 (Final).
On Windows, _sqlite3.pyd resides in C:\Python26\DLLs. On *nix, it should be under a path similar to /usr/lib/python2.6/lib-dynload/_sqlite3.so. Chances are that either you are missing that shared library or your PYTHONPATH is set up incorrectly.
Since you said you did not install as a superuser, it's probably a malformed path; you can manually have Python search a path for _sqlite3.so by doing
import sys
sys.path.append("/path/to/my/libs")
but the preferred approach would probably be to change PYTHONPATH in your .bashrc or other login file.
You have a "slite3.py" (actually its equivalent for a package, sqlite3/__init__.py, so import sqlite3 per se is fine, BUT that module in turns tries to import _sqlite3 and fails, so it's not finding _sqlite3.so. It should be in python2.6/lib-dynload under your local Python root, AND ld should be instructed that it has permission to load dynamic libraries from that directory as well (typically by setting appropriate environment variables e.g. in your .bashrc). Do you have that lib-dynload directory? What's in it? What environment variables do you have which contain the string LD (uppercase), i.e. env|grep LD at your shell prompt?

Django GeoIP Module Not Found

I've spent several hours attempting to resolve my problems setting up GeoIP in Django to no avail and was hoping to get some guidance on what the problem(s) might be.
I'm working on an existing Django application that required some geolocation abilities, specifically getting a users IP and lat/long and then placing that info on a map marker. GeoIP and the associated libraries appeared to be the best solution for the first step.
I installed GeoIP on a Mac using Homebrew. I then manually created a folder in the root directory of my project with the GeoIPv6.data and GeoLiteCity.dat files. After this, I added the path in my settings file:
import os
DEBUG = True
TEMPLATE_DEBUG = DEBUG
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
GEOIP_PATH = os.path.join(BASE_DIR, 'geoip'),
I then opened a command shell for the project and received the following error:
>>> from django.contrib.gis.geoip import GeoIP
Traceback (most recent call last):
File "<console>", line 1, in <module>
ImportError: No module named geoip
I can't seem to remedy this problem. One issue that may be the cause is extracting the two dat.gz files was an issue. Neither could be unzipped from the command line – neither are .zip files – and had to use Stuffit Expander to open these. The resulting dat files in my project IDE (pyCharm) have a VLC (?) icon on each. Perhaps this is part of the issue (finding a way to uncompress the file was a challenge in itself). I'm not sure as the module was not even found.
Any help would be extremely appreciated in resolving this issue as I can't progress any further without figuring out what's wrong.
Many thanks.
*Edit. Okay, it first appeared an imroper import statement might have been the problem. Fixed it: from django.contrib.gis.utils.geoip import GeoIP. Unfortunately, once fixed, the following error results:
>>> from django.contrib.gis.utils.geoip import GeoIP
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/gis/utils/geoip.py", line 68, in <module>
lgeoip = CDLL(lib_path)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 353, in __init__
self._handle = _dlopen(self._name, mode)
OSError: dlopen(/usr/local/lib/libGeoIP.dylib, 6): no suitable image found. Did find:
/usr/local/lib/libGeoIP.dylib: mach-o, but wrong architecture
This is perplexing. Not sure what the problem is exactly.
The arch mismatch message means that the libgeoIP library you installed was built with a different CPU architecture than the architecture that the Python interpreter is running in. From the paths involved, you appear to be using a newer (non-Apple-supplied) Python 2.7. Chances are that the libgeoIP was built as 64-bit (-arch x86_64) while the Python you installed is a 32-bit -only Python 2.7 (-arch i386). Or possibly the reverse. In either case, you could try reinstalling GeoIP with the universal option so that it contains both archs. Or you could try reinstalling Python 2.7 using a 64-bit/32-bit version such as downloadable from python.org. You can see for sure which archs are involved by using the file command:
$ file /usr/local/lib/libGeoIP.dylib
$ file $(python2.7 -c 'import sys;print(sys.executable)')
There needs to be at least one common architecture between the two.
The proper way to import GeoIP on Django 1.4 and up (including the current 1.9 release) is:
from django.contrib.gis.geoip import GeoIP
Its not an issue with your dat files. Its a problem with the import statement, and it finding the GeoIP module.
From the docs:
https://docs.djangoproject.com/en/1.4/ref/contrib/gis/geoip/
In Django 1.4, the GeoIP object was moved out of
django.contrib.gis.utils and into its own module,
django.contrib.gis.geoip. A shortcut is still provided in utils, but
will be removed in Django 1.6.
If you are using django 1.3.x, try:
from django.contrib.gis.utils import GeoIP
Note the difference in the import paths between these two versions:
https://docs.djangoproject.com/en/1.3/ref/contrib/gis/geoip/
https://docs.djangoproject.com/en/1.4/ref/contrib/gis/geoip/
Previously i was facing this issue : from django.contrib.gis.geoip import GeoIP ImportError: cannot import name GeoIP
Solution :
yum install GeoIP-devel -y

Python module audiolab returns error when function is called

I need to install the Python module audiolab for a research project, and while I have managed to install it and get the module to import in the Python shell, it returns an error in calling one of the most basic functions in the module, wavread().
I am using Python2.7.1 mainly, though I did try backtracking and installing audiolab for Python2.6.6, only to find the same error message after importing and calling the wavread() function.
My operating system is Mac OS X 10.5.8 with an intel processor.
This is generally how it goes:
import numpy
import scipy
import scikits.audiolab as audio
x, fs, nbits = audio.wavread('test.wav')
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
x, fs, nbits = audio.wavread('test.wav')
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/scikits.audiolab-0.11.0-py2.7-macosx-10.3- fat.egg/scikits/audiolab/pysndfile/matapi.py", line 91, in basic_reader
hdl = Sndfile(filename, 'r')
File "_sndfile.pyx", line 488, in scikits.audiolab.pysndfile._sndfile.Sndfile.__init__ (scikits/audiolab/pysndfile/_sndfile.c:4251)
IOError: error while opening test.wav
->error while opening file test.wav
-> System error : No such file or directory.
I installed the libsndfile library (which I believe audiofile is simply a wrapper around) using pip and that seemed to install fine without error. I then tried to install audiolab from the tar.gz file, using the command python setup.py install in Terminal. This is as directed in the documentation, found here under the header 'build'
The documentation also talks about in some cases needing to make a 'site.cfg' file, which from what I saw after some google searching, only really applies to Windows users, though I'm not certain about this.
Any light you could shed on my problem would be much appreciated!!
The audiolab documentation is somewhat lacking, but wavread() requires an input file. In your code, that input is test.wav. If it doesn't exist in the working directory (usually the location of your python script), you need to provide the full path to the file.

Why my python does not see pysqlite?

I would like to have an interface between Python and sqlite. Both are installed on the machine. I had an old version of Python (2.4.3). So, pysqlite was not included by default. First, I tried to solve this problem by installing pysqlite but I did not succeed in this direction. My second attempt to solve the problem was to install a new version of Python. I do not have the root permissions on the machine. So, I installed it locally. The new version of Python is (2.6.2). As far as I know this version should contain pysqlite by default (and now it is called "sqlite3", not "pysqlite2", as before).
However, if I type:
from sqlite3 import *
I get:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/verrtex/opt/lib/python2.6/sqlite3/__init__.py", line 24, in <module>
from dbapi2 import *
File "/home/verrtex/opt/lib/python2.6/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: No module named _sqlite3
It has to be noted, that the above error message is different from those which I get if I type "from blablabla import *":
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named blablabla
So, python see something related with pysqlite but still has some problems. Can anybody help me, pleas, with that issue?
P.S.
I use CentOS release 5.3 (Final).
On Windows, _sqlite3.pyd resides in C:\Python26\DLLs. On *nix, it should be under a path similar to /usr/lib/python2.6/lib-dynload/_sqlite3.so. Chances are that either you are missing that shared library or your PYTHONPATH is set up incorrectly.
Since you said you did not install as a superuser, it's probably a malformed path; you can manually have Python search a path for _sqlite3.so by doing
import sys
sys.path.append("/path/to/my/libs")
but the preferred approach would probably be to change PYTHONPATH in your .bashrc or other login file.
You have a "slite3.py" (actually its equivalent for a package, sqlite3/__init__.py, so import sqlite3 per se is fine, BUT that module in turns tries to import _sqlite3 and fails, so it's not finding _sqlite3.so. It should be in python2.6/lib-dynload under your local Python root, AND ld should be instructed that it has permission to load dynamic libraries from that directory as well (typically by setting appropriate environment variables e.g. in your .bashrc). Do you have that lib-dynload directory? What's in it? What environment variables do you have which contain the string LD (uppercase), i.e. env|grep LD at your shell prompt?

Categories