Trouble installing pyGObject on python3 - python

I keep getting error messages while trying to install PyGObject on python3 (Mac OS X 10.9)
Traceback (most recent call last):
File "<string>", line 20, in <module>
File "/private/var/folders/zh/hww3rvgx1rg62zwc8ct51r1r0000gn/T/pip-build-v5qjvi2y/pygobject/setup.py", line 272
raise SystemExit, 'ERROR: Nothing to do, gio could not be found and is essential.'
^
SyntaxError: invalid syntax
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/zh/hww3rvgx1rg62zwc8ct51r1r0000gn/T/pip-build-v5qjvi2y/pygobject

You are trying to install a python2 module with python 3. The syntax error occurs because there has been a change to the syntax for raising an exception. raise SystemExit, 'Message' has become raise SystemExit('Message')
You should make sure that you have the python3 versions of the module.

Related

"Name Error: name 'get_ipython' is not defined" while preparing a debugging session via "import ipdb"

I'm trying to install and use ipdb (IPython-enabled pdb) on Python 3.3.5 32 bit on Win10 using PIP 8.1.2.
I've installed via PIP (had to install it seprately) in windows cmd with no errors:
pip install ipdb
I wrote a simple test script expecting to stop in debugger before printing 'test' string, ipdb_test.py:
import ipdb
ipdb.set_trace()
print('test')
When running it from IDLE editor the following exceptions show up:
Traceback (most recent call last):
File "C:\Python33.5-32\lib\site-packages\ipdb\__main__.py", line 44, in <module>
get_ipython
NameError: name 'get_ipython' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/temp/ipdb_test.py", line 1, in <module>
import ipdb
File "C:\Python33.5-32\lib\site-packages\ipdb\__init__.py", line 7, in <module>
from ipdb.__main__ import set_trace, post_mortem, pm, run # noqa
File "C:\Python33.5-32\lib\site-packages\ipdb\__main__.py", line 51, in <module>
(...)
File "C:\Python33.5-32\lib\site-packages\prompt_toolkit\terminal\win32_output.py", line 266, in flush
self.stdout.flush()
AttributeError: 'NoneType' object has no attribute 'flush'
As the issue seemed to be related to IPython, I've checked that the version installed while resolving ipdb dependencies was: "ipython-5.1.0".
The WA solution for the issue occured to be a fallback to version 4.2.1 of IPython:
pip install "ipython<5"
(...)
Successfully uninstalled ipython-5.1.0
Successfully installed ipython-4.2.1
After that ipdb halted on a breakpoint as expected:
$ python C:\temp\ipdb_test.py
WARNING: Readline services not available or not loaded.
WARNING: Proper color support under MS Windows requires the pyreadline library.
You can find it at:
http://ipython.org/pyreadline.html
Defaulting color scheme to 'NoColor'
> c:\temp\ipdb_test.py(3)<module>()
1 import ipdb
2 ipdb.set_trace()
----> 3 print('test')
ipdb>
It may be a valid case to contact the IPython project team on the issue, meanwhile I find an initial task of running a debug session completed.

Warning: 'as' will become a reserved keyword in Python 2.6

while running npm install (e.g. https://github.com/donpark/html2jade), I run into this error:
/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py:852: Warning: 'as' will become a reserved keyword in Python 2.6
Traceback (most recent call last):
File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp", line 15, in <module>
import gyp
File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 8, in <module>
import gyp.input
File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 852
except ImportError as e:
^
SyntaxError: invalid syntax
python --version generates 'Python 2.7.1'
This would not be a syntax error in Python 2.7.1. A quick workaround would be to run this programme as python /full/path/to/scriptname.py, which will actually use Python 2.7.1.

Installing unicode csv for Python?

I'm new to github and I'm trying to install unicodecsv (https://github.com/jdunck/python-unicodecsv).
I'm trying
sudo pip install -e git://github.com/jdunck/python-unicodecsv.git#egg=unicodecsv
But I'm getting an error message. I'm probably doing someone basic wrong, can someone help?
Obtaining unicodecsv from git+git://github.com/jdunck/python-unicodecsv.git#egg=unicodecsv
Cloning git://github.com/jdunck/python-unicodecsv.git to ./src/unicodecsv
Running setup.py egg_info for package unicodecsv
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "/Users/dave/Dropbox/Promoter/working/src/unicodecsv/setup.py", line 5, in <module>
version = __import__('unicodecsv').__version__
File "unicodecsv/__init__.py", line 49
except TypeError, e:
^
SyntaxError: invalid syntax
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "/Users/dave/Dropbox/Promoter/working/src/unicodecsv/setup.py", line 5, in <module>
version = __import__('unicodecsv').__version__
File "unicodecsv/__init__.py", line 49
except TypeError, e:
^
SyntaxError: invalid syntax
----------------------------------------
Command python setup.py egg_info failed with error code 1
Storing complete log in /Users/dave/.pip/pip.log
Davids-MacBook-Air:working dave$ sudo pip install -e git://github.com/jdunck/python-unicodecsv.git#egg=unicodecsv
Obtaining unicodecsv from git+git://github.com/jdunck/python-unicodecsv.git#egg=unicodecsv
Updating ./src/unicodecsv clone
^[ Running setup.py egg_info for package unicodecsv
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "/Users/dave/Dropbox/Promoter/working/src/unicodecsv/setup.py", line 5, in <module>
version = __import__('unicodecsv').__version__
File "unicodecsv/__init__.py", line 49
except TypeError, e:
^
SyntaxError: invalid syntax
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "/Users/dave/Dropbox/Promoter/working/src/unicodecsv/setup.py", line 5, in <module>
version = __import__('unicodecsv').__version__
File "unicodecsv/__init__.py", line 49
except TypeError, e:
^
SyntaxError: invalid syntax
----------------------------------------
Command python setup.py egg_info failed with error code 1
Storing complete log in /Users/dave/.pip/pip.log
The problem is that you're using Python 3.0 or later, and trying to use a library which is only compatible with 2.7 and earlier.
The specific problem is the line the traceback points at:
except TypeError, e:
This syntax was deprecated in 2.6, in favor of (more flexible and more consistent) new syntax:
except TypeError as e:
In 3.0 and later, the deprecated syntax is no longer allowed at all.
So, if you want to use this library, someone will have to port it—you, the author, or someone else. It may just be a matter of running 2to3, or fixing each except statement manually—but it may be a lot more to do than that, especially considering this library is all about Unicode.
However, it's worth noting that Python 3.x doesn't have the same problem as 2.x did. You can pass the csv module text/Unicode file objects, and it will just handle them. Adapting the example from the unicodecsv docs:
>>> import csv
>>> from io import StringIO
>>> f = StringIO()
>>> w = csv.writer(f)
>>> w.writerow(('é', 'ñ'))
>>> f.seek(0)
>>> r = csv.reader(f)
>>> row = r.next()
>>> print row[0], row[1]
é ñ
Note that I didn't even have to specify utf-8, because StringIO is a Unicode str buffer, not a bytes buffer. You don't have to worry about coding at all.
If you didn't even know you were running Python 3.x (as in, you knew you installed it, but you were careful to keep Apple's pre-installed Python 2.7 higher on the PATH), there are three common reasons this can happen.
Apple's Python doesn't come with pip; all of the popular Python 3.x installers and packages do. So, if you haven't installed pip for 2.7, the only one you have is 3.x.
Apple's Python installs scripts like pip to /usr/local/bin. So do some of the popular Python 3.x installers and packages. So, whichever you installed more recently wins. (The 3.x one should also be available as /usr/local/bin/pip3, so overwriting its /usr/local/bin/pip with 2.7's is usually fine… unless pip3 is a symlink to pip.)
sudo deliberately discards most of your user environment, so 2.7 may be higher on your PATH when running as yourself, but not when running with sudo.

Error when building a project

I cloned an organism project from github.
I tried to install it, but there is no one setup.py file and no documentation.
Could you advise me how to correctly build and install it under Ubuntu 12.04?
I tried so far:
sudo python3 organism.setup.py install
which shows error message:
byte-compiling /usr/local/lib/python3.2/site-packages/organism/coreaux/configuration.py to configuration.pyc
File "/usr/local/lib/python3.2/site-packages/organism/coreaux/configuration.py", line 31
_USER_FOLDER_PERMISSIONS = 0750
^
SyntaxError: invalid token
and running it shows this error message:
$ organism
Traceback (most recent call last):
File "/usr/local/bin/organism", line 23, in <module>
organism.main()
File "/usr/local/lib/python3.2/site-packages/organism/__init__.py", line 21, in main
import coreaux
ImportError: No module named coreaux
I'm not sure if I should use all the files organism-development.setup.py, organism-organizer.setup.py, organism.setup.py, organism-tk.setup.py in the build process or the error is elsewhere.

Error installing selenium python

Getting this error when running pip install -U selenium. Mid way through the script, it gets the following SyntaxError:
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "C:\Python32\Scripts\build\rdflib\setup.py", line 6, in <module>
from rdflib import __version__
File "rdflib\__init__.py", line 64, in <module>
from rdflib.term import URIRef, BNode, Literal, Variable
File "rdflib\term.py", line 367
except TypeError, te:
^
SyntaxError: invalid syntax
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "C:\Python32\Scripts\build\rdflib\setup.py", line 6, in <module>
from rdflib import __version__
File "rdflib\__init__.py", line 64, in <module>
from rdflib.term import URIRef, BNode, Literal, Variable
File "rdflib\term.py", line 367
except TypeError, te:
^
SyntaxError: invalid syntax
----------------------------------------
Command python setup.py egg_info failed with error code 1
Since it is a Syntax Error, I assume it is a python version problem, I'm running 3.2.2.
Pip did come with a pip-3.2.exe file, which I tried to run. But I got the same error. I'm pretty new to Python so it might be something simple.
And how can it be a syntaxError? pip is an already made program.
Running Win7, Python 3.2.2
Selenium does not support Python 3. Use Python 2.7 instead.
Sadly, almost all Python software requires Python 2.x.
[Update]
Selenium supports Python 3.x now.

Categories

Resources