Django - Unqualifed exec not allowed in function 'namedtuple' - python

So, I'm using Django with Python 2.7. I've just tried running python setup.py install, and am getting an error: Unqualifed exec not allowed in function namedtuple.
The source of setup.py is huge, so is in a pastebin here: http://pastebin.com/P2uJMG9n
Does anybody have any idea of why it won't work?
Thanks,
Connor

Related

ImportError: No module named MySQLdb - Debian 6.0

I got a problem in Python while try to import mysql. The beginning of my code is (I'm using monkeyrunner to run script) :
#!/usr/bin/env python
import sys
import MySQLdb
.
.
.
etc
Each time I try to run the code, I got the current error:
dani#debian:~/public/Yandex Maps Test$ monkeyrunner test.py
130413 00:49:22.066:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] Script terminated due to an exception
130413 00:49:22.066:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]Traceback (most recent call last):
File "/home/dani/public/Yandex Maps Test/test.py", line 4, in <module>
import MySQLdb
ImportError: No module named MySQLdb
130413 00:49:22.066:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyException.fillInStackTrace(PyException.java:70)
.
.
.
etc
I tried to re-install mysql for python:
sudo apt-get reinstall python-mysqldb mysql-server
But nothing helped. Any ideas or tips?
Regards,,,
The problem is that monkeyrunner isn't the same interpreter as your default system Python, and doesn't share the same site-packages, etc.
That #!/usr/bin/env python at the top of your script is misleading. If you actually run your script with /usr/bin/env python test.py, or just ./test.py (assuming chmod +x), it will work. But you're not, you're running it with monkeyrunner.
So, nothing you install for your system Python is going to be usable within monkeyrunner. You have to install it for monkeyrunner instead.
Moreover, as the docs say:
The monkeyrunner tool uses Jython, a implementation of Python that uses the Java programming language.
While Jython is Python, and implements the same Python language and (almost) standard library as CPython, it doesn't implement the CPython C API, and therefore can't use C-API extensions like MySQLdb. (They're actually working on a clever wrapper that will change this in the future, but that doesn't help you today.)
There are other MySQL drivers that work with both CPython and Jython (because they use pure Python), such as PyMySQL. But the simplest solution is to just use Java's JDBC drivers. As the Jython FAQ suggests, the easiest way to do that is:
Use zxJDBC which gives data database connectivity from Jython using the Python DB API 2.0 interface…
Unlike using JDBC directly, using zxJDBC often means you only need to change one line in your MySQLdb code to make it work.
i have the same question with u.
and i tried to use zxJDBC to fix it.
but when i run the script, it cannot find "org.gjt.mm.mysql.Driver" either "com.mysql.jdbc.Driver". Even i put mysql-connector-java-5.1.34-bin.jar and zxJDBC.jar under system CLASSPATH.
i tried run this script under jython. it worked.
so i think this question is related with monkeyrunner.

error on importing pyIpopt

I'm trying to install and configure pyIpopt. Ipopt is already installed and the examples run fine.
From the shell, when I do import pyIpopt, I get the error:
ImportError: /***PATH***/libipopt.so.1: undefined symbol: MPI_Init
The FAQ section of the pyIpopt git project has this to offer for these kinds of errors:
Do a Google search to find the library file, and add
-lWhateverLibrary in the makefile of pyipopt.
I've googled and found this: http://www.mcs.anl.gov/research/projects/mpi/www/www3/MPI_Init.html.
I don't know how to get the library or add it to the makefile... Any assistance would be much appreciated!
Just had a similar problem on ubuntu.
Using libmumps-seq worked for me:
installed libmumps-seq-4.9.2 (just with apt-get, along side the ordinary libmumps)
in setup.py changed in the libraries list argument 'coinmumps' to 'dmumps_seq-4.9.2'
rebuilt and installed.
If I understand it correctly, the default mumps is distributed (using MPI lib which can be a world of pain), and all i needed is the sequential one, which mumps-seq provides.

Error using gnuplot from within Sage, but works fine in regular Python

I apologize if this isn't the best place to ask this question, but hopefully someone here can help. I want to run some gnuplot commands directly from within a Sage script, but I get the following error message:
dyld: Library not loaded: /opt/local/lib/libfreetype.6.dylib
Referenced from: /opt/local/bin/gnuplot
Reason: Incompatible library version: gnuplot requires version 14.0.0 or later, but libfreetype.6.dylib provides version 10.0.0
This message appears if I try to use the gnuplotpy interface in Sage, or if I just use something like os.system("gnuplot -e \"plot('sin(x)')\"") from Sage. However, the same os.system(...) command works just fine in regular python. Many thanks.
Sage changes a number of environments including PATH, LD_LIBRARY_PATH, etc. This can cause problems running binaries not installed inside Sage. For this reason it provides a shell command sage-native-execute which (mostly) changes all the variables back. So try the following—it fixes the problem for me:
os.system('''sage-native-execute gnuplot -e "plot('sin(x)')"''')

Install libxml2 bindings for python3

The Problem
I’m trying to build libxml (libxml2-2.7.8) bindings for Python 3.2. When I run the following:
./configure --with-python=/usr/bin/python3.2
The compilation of libxml2-2.7.8 works...but the Python bindings for libxml2-2.7.8 don’t!
Attempted Fixes
Ported setup.py and generator.py (using 2to3, and some basic patches on generator.py)
Patched libxml.c and types.c as follows:
replace PyInt* by PyLong*
replace PyString* by PyBytes*
Current Situation
Unfortunately, it still wasn’t enough. I ran python3.2 setup.py build and got the following error:
types.c:594:17: error: ‘PyInstanceObject’ undeclared (first use in this function)
I can’t find the Python3 equivalent of PyInstanceObject!
Has anyone managed to compile libxml2 bindings for Python 3?
Did I miss something??? Can anybody help? :(
The PyInstanceObject is a part of the support for old style types, which is gone in Python 3, and has been deprecated since Python 2.2. The trick here is to first update the bindings to use new-style classes, and then port to Python 3.
(Or use lxml, which wraps the libxml2 in a Pythonic XML classes).
I'm not 100% sure what the replacement is, I've never done old-style classes in C, but I think it's simply a PyObject.

how do I run a python script that requires pyparsing?

I got a python file which using something called pyparsing but when I run it It showed an error that pyparsing is required can any one pls tel me what to do
not that I am a dump in that thing called pything I need to run that script only :)thanks
If pyparsing is required, and you haven't got it, you need to install it. See https://pypi.org/project/pyparsing/ and/or https://github.com/pyparsing/pyparsing for instructions.

Categories