I am attempting to use spatialite with both Python 2 and 3 on Windows 7.
Rather than try to patch pyspatialite for Python 3, I decided to use the load_extension approach with sqlite3 Python built-in package, similar to how is done here: Sqlite load_extension fail for spatialite in Python and here: Use spatialite extension for SQLite on Windows.
But, on the official (C)Python 2.7 installer, the load_extension was disabled for an issue related to MacOS. This is not with the counterpart for Python 3.4. Furthermore, both installers are built without SQLITE_ENABLE_RTREE=1 (that I'd also like to have).
At first, for Python 2.7, a workaround was to build pysqlite tweaking the setup files to have both R*Tree and extensions. This way does not work for Python 3, since it does not seem to be supported by the current setup.py. From my understand, this is because the package moved to the core Python repository: https://github.com/ghaering/pysqlite/issues/72#issuecomment-94319589
My current solution was to re-build both Python 2.7 and 3.4 with required settings for sqlite3 package. It worked, and I was able to load spatialite as an extension and to create R*Tree.
Does it exist an alternative simpler solution? Did somebody find an alternative solution by working on the setup.py of pyspatialite or pysqlite?
There is an easier solution that I just got working. I'm running Windows 10 with Python 3.5 using the default sqlite3 package, and Spatialite 4.3.
This is how I did it:
Let start with a simple program that loads the spatialite extension (which we haven't installed yet):
import sqlite3
with sqlite3.connect(":memory:") as conn:
conn.enable_load_extension(True)
conn.load_extension("mod_spatialite")
If you run this program you get:
C:\> python test.py
Traceback (most recent call last):
File "test2.py", line 5, in <module>
conn.load_extension("mod_spatialite")
sqlite3.OperationalError: The specified module could not be found.
That means it can't find the mod_spatialite extension. Let's download it from the Spatialite website. At the bottom there's links to "MS Windows binaries". I picked the x86 version, current stable version, and downloaded the file called mod_spatialite-4.3.0a-win-x86.7z. Unzipping that file to the same directory your test.py file is in, and running the program now produces no errors (ie. it works!):
C:\> python test.py
C:\>
Related
I want to install Anaconda on my x64 Windows machine, and I downloaded the Python 2.7 version 64-bit installer. The installation process looks good.
Then I installed pip with choco and installed several packages like zbar,
however, when I want to try to launch Anaconda, I entered conda in Powershell, this is what I got:
Traceback (most recent call last):
File "C:\Users\Ruiyang\Anaconda2\Scripts\conda-script.py", line 3, in <module>
import conda.cli
ImportError: No module named conda.cli
Does anyone knows how to fix this?
add anaconda's bin directory to path.
set path=whatever\anaconda\bin;path;
This issue is related to the path variable setting. Quoting from another SO post:
fire up your interpreter and add this line: export PATH=/Users/add
your username here/anaconda/bin:$PATH
Now type python into the interpreter and you will see Anaconda 1.8.0
or whatever version you have. You will have to do this each time you
start a new interpreter.
Also, note that this might occur when the user name in the path on windows contains a space character. Taken from here.
Though #devautor's method doesn't work for me, a comment in his reference shows me the correct answer:
Unset both PYTHONPATH and PYTHONHOME, then my problem is solved.
I am trying to use spyder on windows 10 using python 2.7 32 bit version of anaconda. I am unable to open spyder through the anaconda interface, through a command prompt or through the spyder.exe. I get the following error message in the command prompt:
Traceback (most recent call last):
File "C:\Users\Brendan\Anaconda2\Scripts\spyder-script.py", line 5, in <module>
sys.exit(spyder.app.start.main())
File "C:\Users\Brendan\Anaconda2\lib\site-packages\spyder\app\start.py", line 103, in main
from spyder.app import mainwindow
File "C:\Users\Brendan\Anaconda2\lib\site-packages\spyder\app\mainwindow.py", line 92, in <module>
from qtpy import QtWebEngineWidgets # analysis:ignore
File "C:\Users\Brendan\Anaconda2\lib\site-packages\qtpy\QtWebEngineWidgets.py", line 26, in <module>
from PyQt5.QtWebKitWidgets import QWebPage as QWebEnginePage
ImportError: DLL load failed: The specified procedure could not be found.
Note that I previously had the 64 bit version of anaconda with python 2.7 and spyder worked fine. I have had this problem ever since I uninstalled the 64 bit version and installed the 32 bit version. I also deleted all of the .anaconda, .spyder, etc. folders before reinstalling.
I have also tried most of the suggestions found here: Python Spyder reset here: ImportError: DLL load failed: The specified procedure could not be found. Python and here: Can no Longer open Spyder IDE for Python Programming, including updating all packages
Any insight would be appreciated as I am relatively new to using python and I do not understand the error message being thrown. I am able to locate the QtWebKitWidgets file in the PyQt5 folder.
I know this is old, but I was having the same problem and found the solution! I had an old Anaconda2 64-bit version installed on my computer (Windows 10 x64), but needed to switch to 32-bit Python for a project. I uninstalled the 64-bit version and installed the 32-bit version and couldn't open Anaconda Navigator, Spyder, etc and got a similar error message to above.
The solution can be found here. In short, you need to reinstall a specific PyQt version conda install pyqt=4.10.4. After this, Spyder opened without issue.
I know this is an old thread, but the following worked for me when my spyder IDE wouldn't load.
The problem was that the status of spyder was still running so wouldn't open. To fix this you need to look for a directory called .spyder-py3 in your Users\ directory, then find a file called "spyder.lock". Underneath this file there were a bunch of files called "spyder.lock.a_bunch_of_numbers.newlink". Once I removed all the spyder lock files the Spyder IDE opened.
I have python 2.7.6 and python 3.4 installed on windows 7 machine.
When I open command prompt for windows and type python, python 2.7.6 starts by default.
I have a python script which I want to compile (or interpret officially speaking) using python 3.4.
Is there a command to use python 3.4 from c:/ prompt? or make 3.4 the default python interpreter?
thanks
Recent versions of Python for Windows install a script called py that will do what you want.
You can either do py -3 script.py to explicitly tell the launcher that you want to use Python 3
or put something containing "python3" on the first line in a comment (ideally #!/usr/bin/env python3 for compatibility with other systems...) and just run script.py; the installer associates *.py files with the launcher, which in turn determines the version to run by looking at the first line of the script.
This mechanism is described in PEP 397.
To make sure that you are always running python 3, you can modify your Windows PATH Environment variable to include the python 3 directory, and remove the python 2 directory.
I'm really new to Python and Django.... What I'm trying to do is:
Install Python 2.7 on Mac OS 10.6.8
Install pip Install Django
Install virtualenvwrapper
Create virtual environment
Install Django-Cms
I think, I'll be is ok from Install virtualenvwrapper to the Django-Cms installation because I have already done it, but in the first steps I got some troubles.
I download Python 2.z from python.org the Python 2.7.3 Mac OS X 64-bit/32-bit x86-64/i386 Installer (for Mac OS X 10.6 and later [2]), installed whit the wizard . That create a directory /System/Library/Frameworks/Python.framework/Versions with inside my 2.7 folder.
My directory /System/Library/Python is empty
I'm sure I've Python installed cos:
python --version
Python 2.7.3
but when I try easy_install pip it gave me:
Could not find platform independent libraries <prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
'import site' failed; use -v for traceback
Traceback (most recent call last):
File "/usr/bin/easy_install-2.6", line 7, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 16, in <module>
import sys, os, zipimport, time, re, imp, new
ImportError: No module named os**
Now no idea of what does mean ...so if somebody could help out from this and put me on the direction where I can istall my virtualenvwrapper I can take it from there.
I'm Junior a front end developer never touch back end so pls be specific and explain me what I need to do as u speak with a child.
You seem to have things turned around. Virtualenv creates a python environment that encapsulates a python install. So you want to do the following:
Install python
Create a virtualenv using that version of python (eg. virtualenv --python="path to python in 1" virt)
Switch to that virtualenv (workon virt)
Now install Django, etc. inside of the virtualenv virt
Here is the recipe I used to get my environment setup and running.
Are you using homebrew? I've found that's the most reliable way to get stuff on the mac.
I'm new to Linux and am trying to set up Python / Django on my machine! I installed Python 3.3 from the source file and it was compiled into /usr/local/bin. Then I created a symbolic link between /usr/bin/python and /usr/local/bin/python3, so that whenever I invoke python from the command line it uses the latest version.
Now I am trying to install MySQL Python and I got the following output:
apt-get install python-mysqldb
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-mysqldb is already the newest version.
The following extra packages will be installed:
apt-listchanges python-apt
Suggested packages:
python-glade2 python-gtk2 python-apt-dbg python-vte python-apt-doc
The following packages will be upgraded:
apt-listchanges python-apt
2 upgraded, 0 newly installed, 0 to remove and 142 not upgraded.
3 not fully installed or removed.
Need to get 0 B/394 kB of archives.
After this operation, 250 kB of additional disk space will be used.
Do you want to continue [Y/n]? Y
Traceback (most recent call last):
File "/usr/bin/apt-listchanges", line 28, in <module>
import apt_pkg
ImportError: No module named 'apt_pkg'
Any ideas on how to fix this? Or any tips on how to clean up this install (if this one is too broken)?
Re-installing Python (apt-get install --reinstall python) should fix your installation issue.
Note that your approach will result in a lot of brokenness. Changing system Python version involves far than just changing symlinks, which is why you should leave it to the distro makers (see a similar question).
One other fact is that Debian already packages 3.3 (currently in Experimental), so rather install that. I just don't know if the system Python modules (e.g. python-apt) will work with it. If not, just use 3.2.
One other thing, if you want to use python-mysqldb, you have to stick to Python 2, because it will not run with Python 3. If you insist on Python 3, use python3-mysql.connector.