I have installed scons 2.3.2 and have python 2.4.
When I run scons, I am seeing the following error:
scons
Import failed. Unable to find SCons files in:
/usr/bin/../engine
/usr/bin/scons-local-2.3.2
/usr/bin/scons-local
/usr/lib/scons-2.3.2
/usr/lib/scons-2.3.2
/usr/local/lib/scons-2.3.2
/usr/lib/python2.4/site-packages/scons-2.3.2
/usr/lib/python2.4/site-packages/scons-2.3.2
/usr/local/lib/python2.4/site-packages/scons-2.3.2
/usr/lib64/scons-2.3.2
/usr/lib/scons
/usr/lib/scons
/usr/local/lib/scons
/usr/lib/python2.4/site-packages/scons
/usr/lib/python2.4/site-packages/scons
/usr/local/lib/python2.4/site-packages/scons
/usr/lib64/scons
Traceback (most recent call last):
File "/usr/bin/scons", line 190, in ?
import SCons.Script
File "/usr/lib/scons/SCons/Script/__init__.py", line 76, in ?
import SCons.Environment
File "/usr/lib/scons/SCons/Environment.py", line 48, in ?
import SCons.Defaults
File "/usr/lib/scons/SCons/Defaults.py", line 52, in ?
import SCons.Tool
File "/usr/lib/scons/SCons/Tool/__init__.py", line 50, in ?
import SCons.Scanner.C
File "/usr/lib/scons/SCons/Scanner/C.py", line 36, in ?
import SCons.cpp
File "/usr/lib/scons/SCons/cpp.py", line 398
p = self.stack[-1] if self.stack else self.default_table
^
SyntaxError: invalid syntax
I did a find and found that SCons is present in /usr/lib/scons. I am not sure why scons is not able to pick it up.
What am I missing?
The problem (from the bottom of the traceback) is a Syntax error:
p = self.stack[-1] if self.stack else self.default_table
^
SyntaxError: invalid syntax
This is because you are running a version of Python that doesn't support conditional expressions:
Support for this syntax was added in 2.5, see the docs
Related
I am trying to import the following library:
import json2xml
from json2xml.utils import readfromstring
However, when I execute the second line I get this error:
Traceback (most recent call last):
File "C:\Users\denis\Desktop\Pazaruvaj Upload\Pazaruvaj_Part1_Test.py", line 12, in <module>
from json2xml.utils import readfromurl, readfromstring, readfromjson
File "C:\Python27\lib\site-packages\json2xml\utils.py", line 19
def readfromjson(filename: str) -> dict:
^
SyntaxError: invalid syntax
Couldn't find anything online about this issue.
Note I don't write from json2xml import json2xml because it gives the same error
According to https://pypi.org/project/json2xml/, json2xml is not compatible with Python2.
Python2 is deprecated, please update to Python3. Then this library should work.
I am using the PyYAML-3.10 as part of a Python program on macOS 10, using Python version 2.7.10. I am not able to make sense of these compilation errors. Since PyYAML-3.10 is a stable version of PyYAML, it should give no compilation errors. The errors are listed below. Any suggestions would be appreciated.
File "pyR#TE.py", line 3, in <module>
import yaml
File "/Users/PyR#TE/pyrate-1.0.0/yaml/__init__.py", line 8, in <module>
from .loader import *
File "/Users/PyR#TE/pyrate-1.0.0/yaml/loader.py", line 4, in <module>
from .reader import *
File "/Users/PyR#TE/pyrate-1.0.0/yaml/reader.py", line 45, in <module>
class Reader(object):
File "/Users/PyR#TE/pyrate-1.0.0/yaml/reader.py", line 137, in Reader
NON_PRINTABLE = re.compile('[^\x09\x0A\x0D\x20-\x7E\x85\xA0-\uD7FF\uE000-\uFFFD]')
raise error, v # invalid expression
sre_constants.error: bad character range
It seems that PyYAMP-3.10 is not compatible with Python 2. (Did you mean "PyYAML", by the way? I could not find a reference to a "PyYAMP" package anywhere.) The compilation error you are seeing is from re.compile - when Python is trying to compile a regular expression.
I tried using the line in your error message containing re.compile in Python 2 and Python 3.
Python 2:
>>> import re
>>> re.compile('[^\x09\x0A\x0D\x20-\x7E\x85\xA0-\uD7FF\uE000-\uFFFD]')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/re.py", line 194, in compile
return _compile(pattern, flags)
File "/usr/lib/python2.7/re.py", line 251, in _compile
raise error, v # invalid expression
sre_constants.error: bad character range
>>>
Python 3:
>>> import re
>>> re.compile('[^\x09\x0A\x0D\x20-\x7E\x85\xA0-\uD7FF\uE000-\uFFFD]')
re.compile('[^\t\n\r -~\x85\xa0-\ud7ff\ue000-�]')
>>>
So your options are either to find a package that supports Python 2, or to upgrade your code to Python 3. I recommend upgrading, as Python 2 is no longer supported.
Using the basic example on their website:
from OCC.Display.SimpleGui import init_display
from OCC.BRepPrimAPI import BRepPrimAPI_MakeBox
display, start_display, add_menu, add_function_to_menu = init_display()
my_box = BRepPrimAPI_MakeBox(10., 20., 30.).Shape()
display.DisplayShape(my_box, update=True)
start_display()
I can't get that to run? Any ideas?
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\WinPython-32bit-2.7.6.4\python-2.7.6\lib\site-packages\OCC\Display\SimpleGui.py", line 164, in init_display
win.canva.InitDriver()
File "C:\WinPython-32bit-2.7.6.4\python-2.7.6\lib\site-packages\OCC\Display\pysideDisplay.py", line 79, in InitDriver
self._display = OCCViewer.Viewer3d(self.GetHandle())
File "C:\WinPython-32bit-2.7.6.4\python-2.7.6\lib\site-packages\OCC\Display\pysideDisplay.py", line 55, in GetHandle
return int(self.winId())
TypeError: int() argument must be a string or a number, not 'PyCObject'
That's a duplication of a github issue:
https://github.com/tpaviot/pythonocc-core/issues/68
we need to know which GUI library your using and what verion of pythonocc you are one.
this is an older version of pythonocc, the current you can find here:
Why not try and install that newer version?
Its important that the OCE library you've got installed match.
So pythonocc-core 0.16 goes with OCE 0.16
I'm learning Xpath and XSLT using Python 2.6.6-64bit on my unix workstation. For Xpath, I'm using the xpath module provided in PyXml-0.8.4.
However, the import line itself throws the following error:
Traceback (most recent call last):
File "xp.py", line 7, in <module>
from xml.xpath import Evaluate
File "/usr/local/python-2.6.6-64bit/lib/python2.6/site-packages/_xmlplus/xpath/__init__.py", line 112, in <module>
from pyxpath import ExprParserFactory
File "/usr/local/python-2.6.6-64bit/lib/python2.6/site-packages/_xmlplus/xpath/pyxpath.py", line 59, in <module>
from xml.xpath.ParsedAbbreviatedRelativeLocationPath import ParsedAbbreviatedRelativeLocationPath
File "/usr/local/python-2.6.6-64bit/lib/python2.6/site-packages/_xmlplus/xpath/ParsedAbbreviatedRelativeLocationPath.py", line 31
as = ParsedAxisSpecifier.ParsedAxisSpecifier('descendant-or-self')
^
SyntaxError: invalid syntax
Looking it up led me to understand that this is because 'as' is a reserved name in python-2.6 and PyXML-0.8.4 tries to redefine it. However, there are no directions on how to resolve this issue.
Please advise.
PyXML is obsolete and should not be used (see here). That's why there are no updates for it. Many features that were included in it were added to Python's standard library. There are also fully-supported third-party packages for Python XML processing like lxml.
I've just installed couchapp from the instructions and have gone through the Getting Started tutorial. When I run couchapp push I get an error like this:
2012-06-23 14:05:08 [CRITICAL] unknown error [[Errno 22] Invalid argument]
Traceback (most recent call last):
File "/Library/Python/2.6/site-packages/couchapp/dispatch.py", line 48, in dispatch
return _dispatch(args)
File "/Library/Python/2.6/site-packages/couchapp/dispatch.py", line 92, in _dispatch
return fun(conf, conf.app_dir, *args, **opts)
File "/Library/Python/2.6/site-packages/couchapp/commands.py", line 76, in push
dbs = conf.get_dbs(dest)
File "/Library/Python/2.6/site-packages/couchapp/config.py", line 146, in get_dbs
return [Database(dburl, use_proxy=use_proxy) for dburl in dburls]
File "/Library/Python/2.6/site-packages/couchapp/client.py", line 223, in __init__
self.res.head()
File "/Library/Python/2.6/site-packages/restkit/resource.py", line 122, in head
params_dict=params_dict, **params)
File "/Library/Python/2.6/site-packages/couchapp/client.py", line 143, in request
raise RequestFailed("unknown error [%s]" % str(e))
RequestFailed: unknown error [[Errno 22] Invalid argument]
I'm on OS X 10.6.8, CouchDB is already setup with admins, and the .couchapprc file has the default db set as http://user:pass#localhost:5984/mydb. I've followed the instructions from couchapp.org for a Homebrew install. The only thing I can figure is that this is a Python-related problem, but I don't know Python and can't seem to figure out why this thing is failing. Any help tracking down this problem and fixing it would be much appreciated.
Thanks.
When this happens to me it usually means SOMEWHERE....SOMEHOW, some JSON in the _doc folder is formatted badly, and it could be on a weird level. So like two _ids or a _rev where it shouldn't be.
I get the same problem and solved it, by downgrade to other version.
https://github.com/downloads/couchapp/couchapp/couchapp-0.8.1-macosx.zip
Seems the best solution, for now.