I'm working on a GIS project, and I would like to implement and test some geo-spatial algorithms in Python. For this purpose, I will not only need sqlite, but also spatialite, in order to store and query the location data. Now I've tried to install the pyspatialite package, but no matter what Python version I tried (I tried all versions from 2.6 to 3.3), the pip keeps insisting, that none of the existing sqlite packages are compatible with my version of Python.
If I try to do this using easy_install, I get a traceback and an error:
AttributeError: MSVCCompiler instance has no attribute 'compiler'
And that also occurs, if I try to install the package manually, by executing the setup.py file.
From what I've already searched, some people suggest to connect to a spatialite database somehow using sqlite and loading extension, but frankly I have no idea how to do it, and couldn't understand any of these answers. I will be really grateful if someone here is able to propose a solution in a clear, step-by step way, as I'm not a very experienced Python programmer yet. Thanks in advance.
Related
I am trying to create a database that I can then read from / write to in Python. I've tried installing the recommended dev installation via this https://dev.mysql.com/downloads/windows/installer/8.0.html. I then went into the designer and added a table with some entities. However, the UX in MySQL is really terrible and I can't work out how to actually view the table in the database I've just created and add test values or whatever. I got frustrated and uninstalled MySQL completely because either I downloaded it incorrectly (I selected dev machine but I want to develop and run it on this machine, was that the wrong option?) or it's just terrible to deal with. However, it seems like there are no real alternatives unfortunately and so I would appreciate some help with regards to just setting up a simple database and connecting it to Python so I can perform SQL statements from my Python code. Also, another complication is that my normal Python installation (i.e. the one linked to PATH etc.) is 3.6, but I was forced to install 3.7 when I downloaded MySQL so I'm not really sure how that will work.
Thanks.
I'm trying to install PennyBlack:
https://github.com/allink/pennyblack
I've done some reading, and it appears that "email_re" was removed from the latest version of Django.
I am VERY new. I was wondering if anyone could tell me a workaround so that I can get this older package installed?
The most correct way to behave in this situation would be not to use the module that is not maintained and doesn't support several latest django versions. Instead, find an alternative, see Django Packages.
Another possible solution would be to fork the project on github and make it work with the version of django you are currently using.
Also see the relevant compatibility issue.
I have worked many hours over several days trying to get MySQL working with Mac OS X, Python (I've tried both 2.7 and 3.3), and Django 1.6.
This topic is addressed on many webpages, both in SO and elsewhere, and over a period of many years (one solution specifically uses MySQLdb 1.2.2, which was last modified in March 2007). Some of the posts seem to say they have it working, but when I try their solution, it doesn't work for me. On the other hand, one post from a few months ago flatly says it can't be done.
The heart of the problem seems to be installing a driver (whether MySQLdb or mysql-connector), and symptoms vary depending on which instructions you follow. Typical show-stoppers from the various attempted solutions have been "No module named 'MySQLdb'" and "Symbol not found: _mysql_affected_rows" when you finally try "python manage.py syncdb".
One wonders whether the very act of trying so many solutions has itself messed up my dev environment so that what would have worked with a clean slate won't work now. Yes, I've tried this both with and without virtualenv. I don't know whether virtualenv has gotten me closer or not, because I don't know how to recognize getting closer.
I happen to have OS X 10.7.5 (Lion) and MySQL 5.0 on my machine. Those are not the latest versions of either, but I don't know whether that matters and I'm reluctant to keep changing things. They work fine for other MySQL applications on my machine. I'll gladly upgrade either or both if a solution is available for later versions.
Does anyone actually have the configuration listed as the title of this post working, with either Python 2.7 or 3.3? If so, I'd be most grateful if you'd direct me to the solution.
UPDATE
I just wanted to let readers know that I eventually did get my app running with Python 3.3, Django 1.6, and sort-of MySQL. My app has been running smoothly for months.
I'm sorry, I don't have the time to recreate the many hours of steps and mis-steps I followed to get this working. I'll just outline the key points:
I started using Macs more than a decade ago, starting with PowerBooks, so my Mac has a lot of old stuff on it. The first thing I finally decided I had to do was to get rid of every copy of Python and Django; installers such as MacPorts and Fink; and any of the directories they like to put their installations into. Google was of course invaluable to me in learning how to do this, and all the other steps mentioned below.
I then started fresh (as much as I could give my Mac a fresh start) using Homebrew as my only command-line installer.
I also used virtualenv. I don't actually understand virtualenv very well, and again don't have the time to research it, but I've got it working and it does seem to be a good idea.
Well, within virtualenv, I also used pip, which I guess is also a command-line installer, but it seems to be part of the Homebrew/virtualenv methodology. Sorry I can't provide any expertise on this.
As I mentioned, the app sort-of worked with MySQL, but when I used Homebrew to uninstall MySQL, and install MariaDB instead, it started to work really well. As far as I can tell, Django, Sequel Pro, PyCharm's DB features, and other programs that think they're talking to MySQL can't tell the difference between MySQL and MariaDB. I also really like the MariaDB online documentation. Admittedly, "MariaDB" isn't a great name, but neither is "MySQL".
Bottom line: If someone tells you it's impossible to get Python3.3 and Django1.6 running with MySQL (or at least MariaDB) on a Mac, don't believe them. It can be done, it's just hard to do if your system has a lot of legacy files and apps that can get into conflict with what you're trying to do.
One more thing: When I started work on this project, I suspended my work on a GAE app I'd been making great progress on for over a year. Since I'll be going back to that project soon, I wanted to keep my GAE install up-to-date on my machine, but sadly, I can no longer run the GAE installer for updates. I get some error about not being able to find python2.5. Sigh. That's what I'll have to look forward to solving when I get back to working on that project.
You could try using the pure-python pymysql:
sudo easy_install pymysql
(Use pip if you have it installed.) Then, add this before execute_from_command_line in manage.py:
try:
import pymysql
pymysql.install_as_MySQLdb()
except ImportError:
pass
I feel your struggle. I went through the same thing and found the setup process very frustrating. I don't really know which instructions you follow on which website that is throwing exceptions. But I find that all these instructions are missing either one or two small prerequisites. For example, xcode and command-line tools needed to be installed before doing any pip install. For the connectors, if you are using mysql-python, you probably need to install python-devel. I used this instruction. You are probably right that with so many installation attempts your system is probably corrupt and you might need to re-install your osx and start clean, again. It's painful, but that's what I had to do to make it work. I hope your next attempt works.
I want to write a visualization of the Dependency-Graph of all python-packages installed with pip. My problem is that the code is poorly documented, and im unable to find where the Graph is stored in the source Code.
I hope someone has enough knowledge about pip-sourcecode to help me out.
Also im new to python and am not sure if i should just make my adjustments in the existing source-code, or write a module for it, although im leaning more towards the latter.
// edit: I can get all installed modules via pip freeze, but that givbes me only one list without the dependencies. So i have to find a way to extract the dependencies from that list.
Yes, its code is quite unreadable if you're not used to it. I don't recall something like that and I would not use it. You may find yourself better suited with distlib, which has a module just for that: https://distlib.readthedocs.org/en/latest/depgraph.html
Heres what i found during my search:
Pip doesn't use a Dependency-graph at all internally. (As of version 1.3.X)
So one solution is to do the following:
You can install setuptools, if you havent allready. It brings a module named pkg_resources.
This module has all the tools, to see all installed modules (not only the ones installed with pip) in your desired dists-directory. You can then read out the metadata (including requirements/dependencies) with methods that are as well included in pkg_resources.
I was using Python 2.6.5 to build my application, which came with sqlite3 3.5.9. Apparently though, as I found out in another question of mine, foreign key support wasn't introduced in sqlite3 until version 3.6.19. However, Python 2.7 comes with sqlite3 3.6.21, so this work -- I decided I wanted to use foreign keys in my application, so I tried upgrading to python 2.7.
I'm using twisted, and I couldn't for the life of me get it to build. Twisted relies on zope.interface and I can't find zope.interface for python 2.7 -- I thought it might just "work" anyway, but I'd have to just copy all the files over myself, and get everything working myself, rather than just using the self-installing packages.
So I thought it might be wiser to just re-build python 2.6 and link it against a new version of sqlite3. But I don't know how--
How would I do this?
I have Visual Studio 2008 installed as a compiler, I read that that is the only one that is really supported for Windows, and I am running a 64 bit operating system
download the latest version of sqlite3.dll from sqlite website and replace the the sqlite3.dll in the python dir.
sqlite3 is not a built-in module; it's an extension module (the binary is C:\Python26\DLLs_sqlite3.pyd (on my machine)). A pyd is a DLL with a different filename extension and only 1 entry point. There's also a sqlite3.dll, which contains the SQLite code. python.exe is not linked against either of those, and thus rebuilding python.exe has no point.
The next idea is to go to the pysqlite2 download site, and get the latest Windows installer for Python 2.6. Unfortunately there's no docs about which version of SQLite it contains; one needs to install it and then muck about:
>>> import sqlite3 as standard
>>> from pysqlite2 import dbapi2 as latest
>>> for m in (standard, latest):
... print m.sqlite_version
...
3.5.9
3.6.2
>>>
So, it contains only SQLite version 3.6.2, which doesn't have the real foreign key support that you want.
I suggest that you check the mailing list to see if your question is answered there, and if not ask about the possibility of a Python 2.6 installer containing a later SQLite (e.g. the one included with Python 2.7).
I decided I'd just give this a shot when I realized that every library I've ever installed in python 2.6 resided in my site-packages folder. I just... copied site-packages to my 2.7 installation, and it works so far. This is by far the easiest route for me if this works -- I'll look further into it but at least I can continue to develop now.
I won't accept this answer, because it doesn't even answer my question, but it does solve my problem, as far as I can tell so far.