grundic/yagocd

importing Yagocd causes SyntaxError

dokaspar opened this issue · 8 comments

I just installed yagocd with pip and now I get this error tying to import the library:

Python 2.6.6 (r266:84292, Aug  9 2016, 06:11:56) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from yagocd import Yagocd
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/site-packages/yagocd/__init__.py", line 30, in <module>
    from yagocd.client import Yagocd
  File "/usr/lib/python2.6/site-packages/yagocd/client.py", line 33, in <module>
    from yagocd.resources.agent import AgentManager
  File "/usr/lib/python2.6/site-packages/yagocd/resources/agent.py", line 32, in <module>
    from yagocd.resources.job import JobInstance
  File "/usr/lib/python2.6/site-packages/yagocd/resources/job.py", line 30, in <module>
    from yagocd.resources.artifact import ArtifactManager
  File "/usr/lib/python2.6/site-packages/yagocd/resources/artifact.py", line 136
    parameters = {p: self._require_param(p, func_args) for p in self.PATH_PARAMETERS}
                                                         ^
SyntaxError: invalid syntax

Is yagocd not compatible with python 2.6.6 or am I doing something wrong?
This is the latest and version I can get with yum on my RHEL6 workstation:

Package python-devel-2.6.6-66.el6_8.x86_64 already installed and latest version
Nothing to do

Hi, @dokaspar,

I'm pretty sure that it won't work with python 2.6. The line with error you just showed is using dictionary comprehension, which is not available in your version.
There are workarounds of course, but it could be no the single place with newest syntax.

I would recommend you to upgrade to newer version of python, as 2.6 is not supported officially for some time.

Thank you for the explanation.

You are welcome. It should be possible to get python 2.7 for RHEL6 though..

I followed your link and tried to install python 2.7 for RHEL6... unfortunately ran into problems when executing "make altinstall":

/usr/bin/install -c python /usr/local/bin/python2.7
if test -f libpython2.7.so; then \
		if test -n "" ; then \
			/usr/bin/install -c -m 555  /usr/local/bin; \
		else \
			/usr/bin/install -c -m 555 libpython2.7.so /usr/local/lib/libpython2.7.so.1.0; \
			if test libpython2.7.so != libpython2.7.so.1.0; then \
				(cd /usr/local/lib; ln -sf libpython2.7.so.1.0 libpython2.7.so) \
			fi \
		fi; \
	else	true; \
	fi
running build
running build_ext
sh: build/temp.linux-x86_64-2.7/multiarch: Permission denied
error: [Errno 2] No such file or directory: 'build/temp.linux-x86_64-2.7/multiarch'
make: *** [sharedmods] Error 1

sudo make altinstall?

yes exactly. with sudo. the file/directory build/temp.linux-x86_64-2.7/multiarch does not exist

Also the make command contains some suspicious messages:

Python build finished, but the necessary bits to build these modules were not found:
bsddb185           dl                 imageop         
sunaudiodev                                           
To find the necessary bits, look in setup.py in detect_modules() for the module's name.

Here is another guide how to install it with more details.

Instead of sudo, run sudo su to get root access and then try again. Also, check comments in aforementioned article as they may help you as well.

Thanks! That more detailed guide was helpful. For example, the required packages also included expat-devel which I did not have on my workstation and which is not mentioned as a requirement in the first tutorial you linked.

Also, it was really important to first become root and then execute everything as root (including the python download, unpacking, etc). I failed first with only sudo.

Now I was able to install yagocd, run python2.7 and import Yagocd:

sudo pip2.7 install yagocd

python2.7
>>> from yagocd import Yagocd