openshift/openshift-restclient-python

Install openshift error in ubuntu

pain301 opened this issue · 5 comments

Exec command pip install openshift and get error message as follows:

Exception:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 278, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1266, in prepare_files
    req_to_install.extras):
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2291, in requires
    dm = self._dep_map
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2484, in _dep_map
    self.__dep_map = self._compute_dependencies()
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2508, in _compute_dependencies
    parsed = next(parse_requirements(distvers))
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 45, in <lambda>
    next = lambda o: o.next()
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2605, in parse_requirements
    line, p, specs = scan_list(VERSION,LINE_END,line,p,(1,2),"version spec")
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2583, in scan_list
    "Expected ',' or end-of-list in",line,"at",line[p:]
ValueError: ("Expected ',' or end-of-list in", 'websocket-client !=0.40.0,!=0.41.*,!=0.42.*,>=0.32.0', 'at', '*,!=0.42.*,>=0.32.0')

Storing debug log for failure in /home/vagrant/.pip/pip.log

I think you may need to update your setuptools package

I think you may need to update your setuptools package

I have installed openshift with pip3.5, but failed to use k8s module, and get error message as follows:

TASK [namespace : Create k8s namespace] *****************************************************************************************************
fatal: [192.168.200.22]: FAILED! => {"changed": false, "msg": "This module requires the OpenShift Python client. Try `pip install openshift`"}

Is it possible that Ansible is still using python2?

What you are showing is constistent with you having the python3 version of openshift and using Ansible with python2.

Maybe this would help? https://docs.ansible.com/ansible/latest/reference_appendices/python_3_support.html

Check which version of python Ansible is using. I realize you said this is on Ubuntu but without a system handy to look at I can only offer that on the most recent version(s) of Fedora Ansible has started using python 3 and there are separate pip and pip3 commands for dealing with the appropriate version.

$ which pip
/usr/bin/pip

$ pip  --version
pip 18.1 from /usr/lib/python2.7/site-packages/pip (python 2.7)

$ which pip3
/usr/bin/pip3

$ pip3 --version
pip 18.1 from /usr/lib/python3.7/site-packages/pip (python 3.7)

$ rpm -q --whatprovides /usr/bin/ansible
ansible-2.7.2-1.fc29.noarch

$ head -n1 /usr/bin/ansible
#!/usr/bin/python3 -s

If you Ansible is still using python 2 you may need to do something along the lines of pip -U setuptools before running pip install openshift.

I think the problem has been resolved. The python version for ansible is 3.6.5 in local machine

[vagrant@c1 test_k8s]$ ansible --version
ansible 2.7.4
  config file = None
  configured module search path = ['/home/vagrant/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.6/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.6.5 (default, Apr 10 2018, 17:08:37) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]

but the remote k8s server python version is 3.7. So I specify the ansible_python_interpreter in site.yml and exec previous command success

---
- hosts: "{{ host }}"
  remote_user: pain
  vars:
    ansible_python_interpreter: /usr/local/bin/python3.7

  roles:
  - namespace