i am starting to use Databases and am using MariaDB, Got that ready, but i want Python integration so i can get started on the program.
I have downloaded PyMySQL-0.7.10.tar.gz from the official python website
and have unzipped and have navigated an Command Prompt to there using cd (dir).
My command is:
"G:\Python\Portable\Portable Python 3.2.5.1\App\python.exe" setup.py install
(Yes, i am on Windows 10 and i am using Portable Python. This is because i learn it at school but also want to be able to work at it at home.)
The error it returns is the following:
Traceback (most recent call last):
File "setup.py", line 4, in <module>
version_tuple = __import__('pymysql').VERSION
File "C:\Users\Natan Samuel Geldorp.Remytop-PC\Downloads\PyMySQL-0.7.10\pymysql\__init__.py", line 28, in <module>
from .converters import escape_dict, escape_sequence, escape_string
File "C:\Users\Natan Samuel Geldorp.Remytop-PC\Downloads\PyMySQL-0.7.10\pymysql\converters.py", line 60
_escape_table[0] = u'\\0'
^
SyntaxError: invalid syntax
Does anyone know how to fix this?
-Natan
As requested, as an answer:
You need a newer Python version, in 3.0 to 3.2 the u prefix was forbidden, it was allowed again in version 3.3.
Since Portable Python is no longer being developed (according to their site) you need to pick an alternative. One suggested on the site is WinPython.
(Also the PyMySQL site states that the minimum required Python versions are either >= 2.6 or >= 3.3)
Related
I want to use the pdfminer for extracting the text info. I have downloaded the pdfminer-20131113. I have installed the python in C:\python34.
Now using cmd, I am setting the path to the setup.py file of pdfminer.
and running the following command.
python setup.py install
But I am getting the below error.
> D:\pdfminer-20101226>python setup.py install
Traceback (most recent call last):
File "setup.py", line 3, in <module>
from pdfminer import __version__
File "D:\pdfminer-20101226\pdfminer\__init__.py", line 4
if __name__ == '__main__': print __version__
^
SyntaxError: invalid syntax
It seems to be some error in the setup.py file of pdfminer, which I am not sure how to resolve.
Also, I saw a pdf2txt.py file in the build folder of pdfminer. I tried to use that also as pdf2txt.py -o output.html pdffilename.pdf (with full path). but instead of converting it. it opens the pdf2txt.py file.
The PDFMiner project homepage states:
Written entirely in Python. (for version 2.4 or newer)
and further down:
Install Python 2.4 or newer. (Python 3 is not supported.)
so you'll have to install Python 2 to run this project.
Alternatively, you could try the Python 3 port, pdfminer3k; it hasn't seen any updates in 20 months, while PDFMiner does have more recent releases, so your mileage may vary.
This should solve your problem in Python 3
pip install pdfminer.six
pdfminer.six is a fork with Python 2+3 support using six. Last commit was 15 days ago.
I'm trying to get Chirp to run under Maemo5 (a debian based mobile operating system).
When running .chirpw or setup.py I get this as a result
Nokia-N900:~/compile/chirp-0.3.1# ./chirpw
CHIRP 0.3.1 on Linux - Maemo 5 %h (Python 2.5.4)
Traceback (most recent call last):
File "./chirpw", line 105, in <module>
from chirp import *
File "/root/compile/chirp-0.3.1/chirp/icq7.py", line 50
class ICQ7Radio(icf.IcomCloneModeRadio):
^
SyntaxError: invalid syntax
I am using the chirp source found here: http://chirp.danplanet.com/download/0.3.1/chirp-0.3.1.tar.gz
The idea is to be able to program my radios from my linux powered phone, however I can't seem to figure out why the program is getting held up on the ICQ7Radio class.
Any help/pointers would be much appreciated.
That version is quite old, have a try with latest daily build http://trac.chirp.danplanet.com/chirp_daily/LATEST/
You can also download full hg repository with
hg clone http://d-rats.com/hg/chirp.hg
See also http://chirp.danplanet.com/projects/chirp/wiki/Developers
I was trying to install the module ConfigObj. I did everything correctly
Typed in CMD:
python setup.py install
But tells me a traceback (error)
> C:\Users\Frederik\Desktop\configobj-4.7.2>python setup.py install
> Traceback (most recent call last): File "setup.py", line 13, in
> <module>
> from configobj import __version__ as VERSION File "C:\Users\Frederik\Desktop\configobj-4.7.2\configobj.py", line 1644
> except Exception, e:
> ^ SyntaxError: invalid syntax
>
> C:\Users\Frederik\Desktop\configobj-4.7.2>
Can everyone tell me how to fix this, there shouldn't be an error in the configobj.py i've installed it before on a another computer.
Downloaded the module from here: https://pypi.python.org/pypi/configobj
My operating system is Windows 7
configObj is for python 2 only.
I should elaborate.
the module you are trying to install is using a syntax that was dropped in python 3. it is available in python 2 up to 2.7.5 (current). As the error is showing perfectly valid python 2 as a syntax error, one must conclude that you are using python 3, and the module does not support python 3. Also, the Pypi link only lists python 2 versions in its categories.
Downgrade your python, or port the module to python 3
I would like to make the jump and get acquainted with Python 3.
I followed the instructions found here with the installation working flawlessly.
I'm also able to use the provided virtualenv to create enviroments for Python 2 and Python 3 (Followed the instuctions here.). Unfortunalty pip3 fails when no virtualenv is activated. I need to use it to install global modules for python3.
This is the error message:
± |master ✓| → pip3
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/local/lib/python2.7/site-packages/distribute-0.6.45-py2.7.egg/pkg_resources.py", line 51
def _bypass_ensure_directory(name, mode=0777):
^
SyntaxError: invalid token
It looks like pip3 is trying to access distribute of python2. Is there any workaround for this?
I was having the same problem as you were and I had
export PYTHONPATH="/usr/local/lib/python2.7/site-packages:$PYTHONPATH"
in my ~/.bash_profile. Removing that line solved the problem for me. If you have that or something like it in your ~/.bashrc or ~/.bash_profile, try removing it.
I just completed a fresh install of Ubuntu 10.10 and I'm trying to run some scripts that use xml and xpath. I get an error from inside PyXML.
I think this is an install error. To get this installed I did the following:
prompt> sudo apt-get install python2.6-dev # The next line wouldn't install without this.
prompt> sudo easy_install PyXML
-------BEGIN ERROR---------
username#ubuntu:~/data/code$ MyScript.py
Traceback (most recent call last):
File "/home/username/data/code/app/trunk/MyScript.py", line 17, in <module>
from xml import xpath
File "/usr/local/lib/python2.6/dist-packages/PyXML-0.8.4-py2.6-linux-i686.egg/_xmlplus/xpath/__init__.py", line 112, in <module>
from pyxpath import ExprParserFactory
File "/usr/local/lib/python2.6/dist-packages/PyXML-0.8.4-py2.6-linux-i686.egg/_xmlplus/xpath/pyxpath.py", line 59, in <module>
from xml.xpath.ParsedAbbreviatedRelativeLocationPath import ParsedAbbreviatedRelativeLocationPath
File "/usr/local/lib/python2.6/dist-packages/PyXML-0.8.4-py2.6-linux-i686.egg/_xmlplus/xpath/ParsedAbbreviatedRelativeLocationPath.py", line 31
as = ParsedAxisSpecifier.ParsedAxisSpecifier('descendant-or-self')
^
SyntaxError: invalid syntax
-------------END ERROR-------------------
I'm about at my limits with PyXML. I simply want to read an xml file and read/write data with xpath. Is there a simpler library that will easily work out of the box? Or any ideas on how to fix this?
Just for the record, if you really need PyXML (i.e. legacy code that you don't have the time to port right now), just changing as in the two places it is used to some other variable name will do.
Additionally, I noticed that Gentoo added the method use_pyxml() to PyXML which explicitly needs to be called; so the standard library XML modules are not used. See here if that is of interest.
PyXML should have been written for very old version of Python (< 2.4) and it used one of the later keywords 'as' as its variable. If your requirement is simple, you can just use ElementTree from Python Standard library which has support for XPath expressions. An example is here.
For using the standard library module, do:
from xml.etree.ElementTree import ElementTree