From: spam_and_junk <spa...@ii...> - 2014-05-07 12:13:01
|
Hi all, I have no Idea what I'm doing with this list, so apologies for whomever this goes to. There was an answer poeted on the Raspberry Pi forum regarding installation problems with pythondialog. Thanks to the author for doing so. I have posted more detailed information there http://www.raspberrypi.org/forums/viewtopic.php?f=91&t=76163&p=546152#p546152 the same error arises when trying to run setup.py locally. Excuse my ignorarance, the pi is my first foray into both linux and python (usually embedded c++ on PIC/Atmel AVR) Thanks |
From: Florent R. <f.r...@fr...> - 2014-05-07 15:15:12
|
Hello, spam_and_junk <spa...@ii...> wrote: > Hi all, > > I have no Idea what I'm doing with this list, so apologies for whomever > this goes to. You are at the right place. :-) > There was an answer poeted on the Raspberry Pi forum regarding > installation problems with pythondialog. Yup. > Thanks to the author for doing so. > > I have posted more detailed information there > http://www.raspberrypi.org/forums/viewtopic.php?f=91&t=76163&p=546152#p546152 > > the same error arises when trying to run setup.py locally. For the benefits of other readers, here is what you tried: ------------------------------------------------------------------------ pi@raspberrypi ~ $ pip install pythondialog Downloading/unpacking pythondialog Downloading pythondialog-3.0.1.tar.bz2 (72kB): 72kB downloaded Running setup.py (path:/tmp/pip_build_pi/pythondialog/setup.py) egg_info for package pythondialog Traceback (most recent call last): File "<string>", line 17, in <module> File "/tmp/pip_build_pi/pythondialog/setup.py", line 39 print(traceback.format_exc(), file=sys.stderr) ^ SyntaxError: invalid syntax Complete output from command python setup.py egg_info: ------------------------------------------------------------------------ The basic problem causing the error is that you are trying to install the "normal pythondialog", which only supports Python 3, using a pip running under Python 2 (2.7 according to your logs). The print() function in the above error only exists as a function in Python 3, and the pip executable you invoked is running under Python 2.x (in Python 2, print is a statement and uses a different syntax). [ Before describing various possibilities to perform the installation, if you only want to try pythondialog, you can do so without installing it. Simply go to the base source directory obtained from the tarball (the one containing dialog.py and demo.py) and run demo.py with the appropriate Python interpreter. Thus, if you have for instance Python 3.4, you can download pythondialog from https://pypi.python.org/pypi/pythondialog and run: python3.4 demo.py from the directory obtained after unpacking. If you only have Python 2, let's say 2.7, you should instead download from https://pypi.python.org/pypi/python2-pythondialog and run: python2.7 demo.py from the base source directory. ] First, you have to decide which version of Python you want to use for your developments and choose the appropriate pip executable accordingly. 'pip' is not explicit, but if for instance you have installed pip for Python 3.3, you can usually invoke pip-3.3 to be explicit about what you want. Since you appear to be using Debian or one of its derivatives, you can do: dpkg -S $(which pip) or: % dpkg -S /usr/bin/pip python-pip: /usr/bin/pip to find out which Debian package the pip executable comes from (here, 'python-pip'). In my case: % dpkg -S $(which pip) dpkg-query: no path found matching pattern /usr/local/bin/pip because I installed pip manually under /usr/local. If the package is 'python-pip', then: % dpkg -s python-pip | grep ^Version: Version: 1.1-3 shows the version of this package (which corresponds to pip 1.1) and, more importantly: % dpkg -s python-pip | grep ^Depends: Depends: python2.6, python (>= 2.6.6-7~), python (<< 2.8), python-pkg-resources, python-setuptools (>= 0.6c1) which shows that this pip package is supposed to work with Python 2.6 and 2.7 (the '<<' means 'strictly lower than'). It is not quite precise however, so we can do: % /usr/bin/pip --version pip 1.1 from /usr/lib/python2.7/dist-packages (python 2.7) % ls -l /usr/bin/pip lrwxrwxrwx 1 root root 7 Jun 23 2012 /usr/bin/pip -> pip-2.7 to remove any ambiguity. In practice, better use things like pip-2.7 whenever possible. Now, if you want to install for Python 3.3 for instance, the command could be: pip-3.3 install pythondialog but if you chose to work with the obsolete Python 2, then you would need the Python 2 backport of pythondialog instead, as explained at http://pythondialog.sourceforge.net/ which could be installed with: pip-2.7 install python2-pythondialog for instance. The first command downloads from: https://pypi.python.org/pypi/pythondialog whereas the second command downloads from: https://pypi.python.org/pypi/python2-pythondialog BUT the command has to be run in a way that gives pip the appropriate permissions to do the installation! There are several possibilities for this: 1) Run it as root, but keep in mind that Debian Python folks don't like that. Without more arguments, it should install under /usr/local/lib/python2.7/dist-packages on Debian or under /usr/local/lib/python3.3/site-packages more commonly, or simply if you installed Python manually under /usr/local (version numbers to be adapted, of course). 2) Create a virtualenv as explained at https://virtualenv.pypa.io/ and install your Python packages in this isolated environment. It is very easy, doesn't require root access, allows you to have several environments with possibly different Python versions and/or combinations of packages. I believe recent versions of Python (3.4 and maybe also 3.3) come with a kind of built-in virtual environment implementation (pyvenv...), but I have not tried this yet. Note: when you have a virtualenv in <venv_dir>, <venv_dir>/bin/pip is always the right executable to use to install in that virtual environment (no need to pay attention to the Python version in that case, no need to 'activate' the environment unless you want to be able to simply type 'pip' in order to invoke the pip from the virtualenv). 3) Run pip with the --user option, as in: pip-3.3 install --user pythondialog which should install, with default settings, under: ~/.local/lib/python3.3/site-packages ~/.local/bin ... as explained at: https://pip.pypa.io/en/latest/user_guide.html#user-installs and: https://docs.python.org/3/install/index.html#inst-alt-install-user Debian Python people seem to like that, *but*: - it is less flexible than virtualenvs, of which you can create as many as you wish; - uninstallation with the pip available in Debian wheezy silently fails! (this is with --user, normal uninstallations work well AFAICT) I hope these guidelines will be sufficient for you to succeed with the installation. By the way, if the 'setup.py install' method also failed, it is probably for the same reasons: - using a Python 2.x interpreter with the "normal pythondialog", as opposed to the Python 2 backport; - trying to install as a normal user to a place where writing requires root privileges. > Excuse my ignorarance, the pi is my first foray into both linux and > python (usually embedded c++ on PIC/Atmel AVR) OK, no problem. Please follow up on this mailing list (pythondialog-users), as your question doesn't seem to be specific to the Raspberry Pi. -- Florent |
From: spam_and_junk <spa...@ii...> - 2014-05-08 12:02:23
|
Thanks to Florent for the help. Running under python3 with better results. No idea why it, but it is not reccomended for the raspberry's default, hence trying to use 2.7 cheers -Antony On 8/05/14 1:12 AM, Florent Rougon wrote: > Hello, > > spam_and_junk <spa...@ii...> wrote: > >> Hi all, >> >> I have no Idea what I'm doing with this list, so apologies for whomever >> this goes to. > > You are at the right place. :-) > >> There was an answer poeted on the Raspberry Pi forum regarding >> installation problems with pythondialog. > > Yup. > >> Thanks to the author for doing so. >> >> I have posted more detailed information there >> http://www.raspberrypi.org/forums/viewtopic.php?f=91&t=76163&p=546152#p546152 >> >> the same error arises when trying to run setup.py locally. > > For the benefits of other readers, here is what you tried: > > ------------------------------------------------------------------------ > pi@raspberrypi ~ $ pip install pythondialog > Downloading/unpacking pythondialog > Downloading pythondialog-3.0.1.tar.bz2 (72kB): 72kB downloaded > Running setup.py (path:/tmp/pip_build_pi/pythondialog/setup.py) egg_info for package pythondialog > Traceback (most recent call last): > File "<string>", line 17, in <module> > File "/tmp/pip_build_pi/pythondialog/setup.py", line 39 > print(traceback.format_exc(), file=sys.stderr) > ^ > SyntaxError: invalid syntax > Complete output from command python setup.py egg_info: > ------------------------------------------------------------------------ > > The basic problem causing the error is that you are trying to install > the "normal pythondialog", which only supports Python 3, using a pip > running under Python 2 (2.7 according to your logs). The print() > function in the above error only exists as a function in Python 3, and > the pip executable you invoked is running under Python 2.x (in Python 2, > print is a statement and uses a different syntax). > > [ Before describing various possibilities to perform the installation, > if you only want to try pythondialog, you can do so without installing > it. Simply go to the base source directory obtained from the tarball > (the one containing dialog.py and demo.py) and run demo.py with the > appropriate Python interpreter. Thus, if you have for instance > Python 3.4, you can download pythondialog from > https://pypi.python.org/pypi/pythondialog and run: > > python3.4 demo.py > > from the directory obtained after unpacking. If you only have > Python 2, let's say 2.7, you should instead download from > https://pypi.python.org/pypi/python2-pythondialog and run: > > python2.7 demo.py > > from the base source directory. ] > > First, you have to decide which version of Python you want to use for > your developments and choose the appropriate pip executable accordingly. > 'pip' is not explicit, but if for instance you have installed pip for > Python 3.3, you can usually invoke pip-3.3 to be explicit about what you > want. > > Since you appear to be using Debian or one of its derivatives, you can > do: > > dpkg -S $(which pip) > > or: > > % dpkg -S /usr/bin/pip > python-pip: /usr/bin/pip > > to find out which Debian package the pip executable comes from (here, > 'python-pip'). In my case: > > % dpkg -S $(which pip) > dpkg-query: no path found matching pattern /usr/local/bin/pip > > because I installed pip manually under /usr/local. If the package is > 'python-pip', then: > > % dpkg -s python-pip | grep ^Version: > Version: 1.1-3 > > shows the version of this package (which corresponds to pip 1.1) and, > more importantly: > > % dpkg -s python-pip | grep ^Depends: > Depends: python2.6, python (>= 2.6.6-7~), python (<< 2.8), python-pkg-resources, python-setuptools (>= 0.6c1) > > which shows that this pip package is supposed to work with Python 2.6 > and 2.7 (the '<<' means 'strictly lower than'). It is not quite precise > however, so we can do: > > % /usr/bin/pip --version > pip 1.1 from /usr/lib/python2.7/dist-packages (python 2.7) > % ls -l /usr/bin/pip > lrwxrwxrwx 1 root root 7 Jun 23 2012 /usr/bin/pip -> pip-2.7 > > to remove any ambiguity. In practice, better use things like pip-2.7 > whenever possible. > > Now, if you want to install for Python 3.3 for instance, the command > could be: > > pip-3.3 install pythondialog > > but if you chose to work with the obsolete Python 2, then you would > need the Python 2 backport of pythondialog instead, as explained at > http://pythondialog.sourceforge.net/ which could be installed with: > > pip-2.7 install python2-pythondialog > > for instance. The first command downloads from: > > https://pypi.python.org/pypi/pythondialog > > whereas the second command downloads from: > > https://pypi.python.org/pypi/python2-pythondialog > > BUT the command has to be run in a way that gives pip the appropriate > permissions to do the installation! There are several possibilities for > this: > > 1) Run it as root, but keep in mind that Debian Python folks don't > like that. Without more arguments, it should install under > /usr/local/lib/python2.7/dist-packages on Debian or under > /usr/local/lib/python3.3/site-packages more commonly, or simply if > you installed Python manually under /usr/local (version numbers to > be adapted, of course). > > 2) Create a virtualenv as explained at > https://virtualenv.pypa.io/ and install your Python packages in > this isolated environment. It is very easy, doesn't require root > access, allows you to have several environments with possibly > different Python versions and/or combinations of packages. I > believe recent versions of Python (3.4 and maybe also 3.3) come > with a kind of built-in virtual environment implementation > (pyvenv...), but I have not tried this yet. > > Note: when you have a virtualenv in <venv_dir>, <venv_dir>/bin/pip > is always the right executable to use to install in that virtual > environment (no need to pay attention to the Python version in that > case, no need to 'activate' the environment unless you want to be > able to simply type 'pip' in order to invoke the pip from the > virtualenv). > > 3) Run pip with the --user option, as in: > > pip-3.3 install --user pythondialog > > which should install, with default settings, under: > > ~/.local/lib/python3.3/site-packages > ~/.local/bin > ... > > as explained at: > > https://pip.pypa.io/en/latest/user_guide.html#user-installs > > and: > > https://docs.python.org/3/install/index.html#inst-alt-install-user > > Debian Python people seem to like that, *but*: > - it is less flexible than virtualenvs, of which you can create > as many as you wish; > - uninstallation with the pip available in Debian wheezy silently > fails! (this is with --user, normal uninstallations work well > AFAICT) > > I hope these guidelines will be sufficient for you to succeed with the > installation. By the way, if the 'setup.py install' method also failed, > it is probably for the same reasons: > - using a Python 2.x interpreter with the "normal pythondialog", as > opposed to the Python 2 backport; > - trying to install as a normal user to a place where writing requires > root privileges. > >> Excuse my ignorarance, the pi is my first foray into both linux and >> python (usually embedded c++ on PIC/Atmel AVR) > > OK, no problem. Please follow up on this mailing list > (pythondialog-users), as your question doesn't seem to be specific to > the Raspberry Pi. > |
From: Florent R. <f.r...@fr...> - 2014-05-08 15:24:28
|
spam_and_junk <spa...@ii...> wrote: > Thanks to Florent for the help. > > Running under python3 with better results. No idea why it, but it is > not reccomended for the raspberry's default, hence trying to use 2.7 I wonder where this recommendation comes from... unless you have strong dependencies that have not been, and can't easily be ported to Python 3. Do you have a link? As reminded at: https://pypi.python.org/pypi/python2-pythondialog which you should definitely read, Python 3.0 was released on December 3, 2008. Python 2 is now more or less obsolete... or in end-of-line state, if you prefer. Just a few links I saw recently about the subject: http://legacy.python.org/dev/peps/pep-0404/ https://lists.debian.org/debian-python/2014/05/msg00037.html http://techs.enovance.com/6521/openstack_python3 If you still decide to work with Python 2, you should probably import many things from the future, as suggested in: https://linuxfr.org/users/thom/journaux/la-duree-de-vie-de-python-2-7-encore-repoussee#comment-1532573 Good luck... -- Florent |