ocdev won't run: SyntaxError: invalid Syntax - python

I can't get the ocdev tool to run. when I try running it i receive "SyntaxError: invalid syntax" with some code.
My guess is maybe wrong python version? Since python --version outputs 2.7.3.
I also have python3 installed but it's not the standard version. I installed ocdev using pip-3.2. I already tried reinstalling it multiple times. I also have python3-jinja2 installed. I'm running debian 7.8.
Here is the whole error:
Traceback (most recent call last):
File "/usr/local/bin/ocdev", line 9, in <module>
load_entry_point('ocdev==0.1.2', 'console_scripts', 'ocdev')()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 337, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2280, in load_entry_point
return ep.load()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 1990, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/local/lib/python3.2/dist-packages/ocdev/application.py", line 20, in <module>
from ocdev.plugins import PLUGINS
File "/usr/local/lib/python3.2/dist-packages/ocdev/plugins/__init__.py", line 1, in <module>
from ocdev.plugins.startapp.startapp import StartApp
File "/usr/local/lib/python3.2/dist-packages/ocdev/plugins/startapp/startapp.py", line 7, in <module>
from jinja2 import Environment, FileSystemLoader
File "/usr/local/lib/python3.2/dist-packages/jinja2/__init__.py", line 33, in <module>
from jinja2.environment import Environment, Template
File "/usr/local/lib/python3.2/dist-packages/jinja2/environment.py", line 639
u'\xff\xff\xff\xff'.encode('iso-8859-15')
^
SyntaxError: invalid syntax

In order to get ocdev to work with Python 3.2 you need to install legacy versions of Jinja2(source) and MarkupSafe(source). This is because the newer versions require Python 3.3.
To do the proper install follow the regular setup guide and use the following pip/pip3 commands:
pip install -Iv Jinja2==2.6
pip install -Iv MarkupSafe==0.15
pip install ocdev
I also reported this in the ocdev GitHub repository here.

It looks like you're running Python 3.2.
To use the u'unicode' syntax with Python 3 you'll need at least Python 3.3. (see What's New In Python 3.3)

Related

Python pip returning incomplete read error

quick thing: YES I KNOW THERE IS ANOTHER POST ON THIS, but its answers do NOT solve my issue.
So I installed this package called hangups on my raspberry pi. It ruined my pip installation and gave me the error below. However if you google this error, you will come to a post that does have a solution: re installing pip. I had done this several times; Once reinstalling pip from apt, 2nd time from get-pip.py, last by reinstalling python3. Irregardless, none of these methods solved my error (Oh and i also must mention that i did try the easy_install reinstallation of pip but that fails too). Nothing seems to work. My theory is that some repository somewhere is not updated because the error message points to some ancient version of pip (<= 2) (on my mac pip is at 9 running same version of python 3) and for some reason, pip has this dependency that isnt there just disables my pip binary. I would install them, but (lol) i dont have pip. The error is below. How do I fix this?
please comment if you need more information. Thanks!!!
/usr/local/lib/python3.4/dist-packages/requests/__init__.py:80:
RequestsDependencyWarning: urllib3 (1.22) or chardet (2.3.0) doesn't
match a supported version!
RequestsDependencyWarning)
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
load_entry_point('pip==1.5.6', 'console_scripts', 'pip3')()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 356, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2476, in load_entry_point
return ep.load()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2190, in load
['__name__'])
File "/usr/lib/python3/dist-packages/pip/__init__.py", line 74, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/lib/python3/dist-packages/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "/usr/lib/python3/dist-packages/pip/download.py", line 25, in <module>
from requests.compat import IncompleteRead
ImportError: cannot import name 'IncompleteRead'
Yeah ok so for future reference kids, easy_install does (like pip) have a python 3.x version. Just do sudo easy_install3 -U pip.

No Module Named Extern

I am having real trouble trying to use pip to install pyserial for python 3.5.2, I am trying to install pip using 'sudo easy_install pip'.
I keep getting this error message:
sudo easy_install pip
Traceback (most recent call last):
File "/usr/local/bin/easy_install", line 11, in <module>
load_entry_point('setuptools==29.0.1', 'console_scripts', 'easy_install')()
File"/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 565, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File"/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2697, in load_entry_point
return ep.load()
File"/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2370, in load
return self.resolve()
File"/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2376, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "build/bdist.macosx-10.12-intel/egg/setuptools/__init__.py", line 10, in <module>
File "build/bdist.macosx-10.12 intel/egg/setuptools/extern/__init__.py", line 1, in <module>
ImportError: No module named extern
Any Help would be appreciated.
Running sudo easy_install pip will install pip for Python 2, which you don't want if you're using Python 3.
You might have pip installed for Python 3 already (run which pip3 to check). If so, you can install pyserial using pip3
pip3 install pyserial
However, it would be better to use a virtual environment. See the hitchhiker's guide to Python to get started.

Python version conflicts and pip3

It is a tough situation I am dealing with. Here is short version of my problem:
I am working on Ubuntu 12.04
I would like to install Python 3.5.x with openCV library. I would also like to use pip3 for managing package installation of python.
Here is how the version of my pythons looks like
$ python --version
Python 2.7.3
$ python3 --version
Python 3.5.2
So far it looks I have achieved my goal.
When I use virtualenv to manage python3 libraries:
virtualenv -p /usr/bin/python3 py3env
source py3env/bin/activate
I see the version of my python as follows:
(py3env)yxxxxa#yxxxxa-Precision-M4800:~$ python3 --version
Python 3.2.3
I seems there is another version of python in my machine 3.2.3 messing up with the version 3.5.2 that I have installed. This is my first problem.
The second related problem is that I am unable to install pip 3. There is this error I receive due to the same python version conflict:
$ pip
/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/_vendor /pkg_resources/__init__.py:80: UserWarning: Support for Python 3.0-3.2 has been dropped. Future versions will fail here.
warnings.warn(msg)
Traceback (most recent call last):
File "/usr/local/bin/pip", line 9, in <module>
load_entry_point('pip==8.1.2', 'console_scripts', 'pip')()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 337, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2280, in load_entry_point
return ep.load()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 1990, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/__init__.py", line 16, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/download.py", line 36, in <module>
from pip.utils.ui import DownloadProgressBar, DownloadProgressSpinner
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/utils/ui.py", line 15, in <module>
from pip._vendor.progress.bar import Bar, IncrementalBar
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/_vendor/progress/bar.py", line 48
empty_fill = u'∙'
^
SyntaxError: invalid syntax
yasharatena#yasharatena-Precision-M4800:~$ pip3
/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/_vendor/pkg_resources/__init__.py:80: UserWarning: Support for Python 3.0-3.2 has been dropped. Future versions will fail here.
warnings.warn(msg)
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 9, in <module>
load_entry_point('pip==8.1.2', 'console_scripts', 'pip3')()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 337, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2280, in load_entry_point
return ep.load()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 1990, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/__init__.py", line 16, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/download.py", line 36, in <module>
from pip.utils.ui import DownloadProgressBar, DownloadProgressSpinner
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/utils/ui.py", line 15, in <module>
from pip._vendor.progress.bar import Bar, IncrementalBar
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/_vendor/progress/bar.py", line 48
empty_fill = u'∙'
^
SyntaxError: invalid syntax
What are your expert opinions about the stated problem? Any cool idea to handle this? Thanks alot in advance
This solved my first problem. Now the second problem aslo remains, how
can I install pip3 under python 3.5.2 (preferably using viretualenv) ?
Here is answer:
python3 -m virtualenv py3env
source py3env/bin/activate
Python 3.5 should have pip by default, also after above commands You can use pip:)
For example :
python -m pip install requests
EDIT:
Here You could find very good explainations if You still need install pip after create virtualenv.

pip install * have "Syntax error"

A have a problem where try to install module from pip like:
Install packages failed: Error occurred when installing package lxml.
The following command was executed:
packaging_tool.py install --build-dir C:\Users\User\AppData\Local\Temp\pycharm-packaging2629877941665473195.tmp lxml
The error output of the command:
C:\Python32\lib\site-packages\pip\_vendor\pkg_resources\__init__.py:87: UserWarning: Support for Python 3.0-3.2 has been dropped. Future versions will fail here.
warnings.warn(msg)
Traceback (most recent call last):
File "C:\Program Files (x86)\JetBrains\PyCharm 3.1\helpers\packaging_tool.py", line 125, in main
retcode = do_install(pkgs)
File "C:\Program Files (x86)\JetBrains\PyCharm 3.1\helpers\packaging_tool.py", line 56, in do_install
import pip
File "C:\Python32\lib\site-packages\pip\__init__.py", line 16, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "C:\Python32\lib\site-packages\pip\vcs\mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "C:\Python32\lib\site-packages\pip\download.py", line 36, in <module>
from pip.utils.ui import DownloadProgressBar, DownloadProgressSpinner
File "C:\Python32\lib\site-packages\pip\utils\ui.py", line 15, in <module>
from pip._vendor.progress.bar import Bar, IncrementalBar
File "C:\Python32\lib\site-packages\pip\_vendor\progress\bar.py", line 48
empty_fill = u'\u2219'
^
SyntaxError: invalid syntax
How fix this? I can not install any module or rollback pip.
Python 3.2
Pip 8.1.1
You need to upgrade your Python. Python 3.2 does not support Unicode string literals with the u"..." syntax (the idea was that these are not needed anymore because all string literals are Unicode in Python 3.x). This is why you are getting the error.
In Python 3.3, this feature was restored to make it easier to write code that runs on either Python 2.x or 3.x and clearly PIP is taking advantage of this.
Indeed, the documentation for PIP 8.1.1 mentions that it needs Python 3.3 or later.

Cannot install virtualenv using pip

I first installed distribute, then pip with easy_install but when I run:
sudo pip install virtualenv
I get these error messages:
Traceback (most recent call last):
File "/usr/bin/pip", line 8, in ? sys.exit(
File "/usr/lib/python2.4/site-packages/distribute-0.6.49-py2.4.egg/pkg_resources.py", line 345, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.4/site-packages/distribute-0.6.49-py2.4.egg/pkg_resources.py", line 2381, in load_entry_point
return ep.load()
File "/usr/lib/python2.4/site-packages/distribute-0.6.49-py2.4.egg/pkg_resources.py", line 2087, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/lib/python2.4/site-packages/pip-1.4-py2.4.egg/pip/__init__.py", line 10, in ?
from pip.util import get_installed_distributions, get_prog
File "/usr/lib/python2.4/site-packages/pip-1.4-py2.4.egg/pip/util.py", line 17, in ?
from pip.vendor.distlib import version
File "/usr/lib/python2.4/site-packages/pip-1.4-py2.4.egg/pip/vendor/__init__.py", line 8
from __future__ import absolute_importSyntaxError: from __future__ imports must occur at the beginning of the file
I do not know what to do to install virtualenv properly now?
You appear to be using Python 2.4 - try creating the virtualenv with a version of Python which includes from __future__ import absolute_import (Python 2.5 or later).
You can specify which Python to use like this:
virtualenv -p /usr/bin/python2.7

Categories