Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

salt pip AttributeError: type object 'InstallRequirement' has no attribute 'from_line' #49967

Closed
diepes opened this issue Oct 10, 2018 · 21 comments
Assignees
Labels
Bug broken, incorrect, or confusing behavior fixed-pls-verify fix is linked, bug author to confirm fix P2 Priority 2 severity-critical top severity, seen by most users, serious issues severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around State-Module v2018.3.4 unsupported version ZRELEASED - 2017.7.9 RETIRED LABEL
Milestone

Comments

@diepes
Copy link
Contributor

diepes commented Oct 10, 2018

Description of Issue/Question

after pip upgrade on ubuntu 14.04 to 9.8 -> 18.1 salt state pip.install failing with

AttributeError: type object 'InstallRequirement' has no attribute 'from_line'

To make the state work again uninstall new pip version
$ sudo pip uninstall pip
$ sudo apt install --reinstall python-pip
$ sudo pip install pip==9.0.1
#Note now the sls state pip.install below works

Setup

(Please provide relevant configs and/or SLS files (Be sure to remove sensitive info).)

#sls file
docker:
pip.installed:
- name: docker
- reload_modules: True

Steps to Reproduce Issue

(Include debug logs if possible and relevant.)
##Ubuntu 14.04
sudo pip install --upgrade pip
pip --version
vagrant@localsandbox:~$ pip --version
/usr/local/lib/python2.7/dist-packages/cryptography/hazmat/primitives/constant_time.py:26: CryptographyDeprecationWarning: Support for your Python version is deprecated. The next version of cryptography will remove support. Please upgrade to a 2.7.x release that supports hmac.compare_digest as soon as possible.
utils.DeprecatedIn23,
pip 18.1 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)

Versions Report

(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)

vagrant@localsandbox:~$ salt-call --versions-report
/usr/local/lib/python2.7/dist-packages/cryptography/hazmat/primitives/constant_time.py:26: CryptographyDeprecationWarning: Support for your Python version is deprecated. The next version of cryptography will remove support. Please upgrade to a 2.7.x release that supports hmac.compare_digest as soon as possible.
utils.DeprecatedIn23,
Salt Version:
Salt: 2018.3.2

Dependency Versions:
cffi: 1.11.5
cherrypy: Not Installed
dateutil: 2.7.3
docker-py: 3.5.0
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
Jinja2: 2.7.2
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: Not Installed
Mako: 0.9.1
msgpack-pure: Not Installed
msgpack-python: 0.4.6
mysql-python: 1.2.3
pycparser: 2.19
pycrypto: 2.6.1
pycryptodome: Not Installed
pygit2: Not Installed
Python: 2.7.6 (default, Nov 23 2017, 15:49:48)
python-gnupg: 0.4.3
PyYAML: 3.10
PyZMQ: 14.0.1
RAET: Not Installed
smmap: Not Installed
timelib: Not Installed
Tornado: 4.2.1
ZMQ: 4.0.5

System Versions:
dist: Ubuntu 14.04 trusty
locale: UTF-8
machine: x86_64
release: 4.4.0-137-generic
system: Linux
version: Ubuntu 14.04 trusty

vagrant@localsandbox:~$

@Ch3LL
Copy link
Contributor

Ch3LL commented Oct 10, 2018

looks like i'm able to replicate this. we will need to get this fixed up. thanks

@Ch3LL Ch3LL added State-Module Bug broken, incorrect, or confusing behavior severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around P2 Priority 2 labels Oct 10, 2018
@Ch3LL Ch3LL added this to the Approved milestone Oct 10, 2018
@Ch3LL Ch3LL added severity-critical top severity, seen by most users, serious issues v2018.3.4 unsupported version labels Oct 10, 2018
@g-rd
Copy link

g-rd commented Oct 11, 2018

I just hit the same error:
Using:
pip 18.1 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)
Salt Version:
Salt: 2018.3.2

Dependency Versions:
cffi: Not Installed
cherrypy: 8.9.1
dateutil: 2.6.1
docker-py: Not Installed
gitdb: 2.0.3
gitpython: 2.1.8
ioflo: Not Installed
Jinja2: 2.10
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: Not Installed
Mako: 1.0.7
msgpack-pure: Not Installed
msgpack-python: 0.5.6
mysql-python: Not Installed
pycparser: Not Installed
pycrypto: 2.6.1
pycryptodome: Not Installed
pygit2: Not Installed
Python: 2.7.15rc1 (default, Apr 15 2018, 21:51:34)
python-gnupg: 0.4.1
PyYAML: 3.12
PyZMQ: 16.0.2
RAET: Not Installed
smmap: 2.0.3
timelib: Not Installed
Tornado: 4.5.3
ZMQ: 4.2.5

System Versions:
dist: Ubuntu 18.04 bionic
locale: UTF-8
machine: x86_64
release: 4.15.0-36-generic
system: Linux
version: Ubuntu 18.04 bionic

Error occurs in /usr/lib/python2.7/dist-packages/salt/states/pip_state.py at line 134 ("install_req = InstallRequirement.from_line(pkg)")

because InstallRequirement does not have a from_line method any longer. I don't have enough experience with saltstack and pip to figure out how to fix it.
Temporary fix is to use downgrade to pip==18.0 to get around this issue, but I hope it gets fixed soon.

@rallytime
Copy link
Contributor

@gtmanfred I've assigned this one to your for 2018.3.4 :)

@lmbss
Copy link

lmbss commented Oct 12, 2018

i have de some error when i use module.pip for install pyinotify:

pip.pkgs:
  pip.installed:
    - pkgs:
      - pyinotify
    - proxy: CONFIDENTIAL
          ID: pip.pkgs
    Function: pip.installed
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/usr/lib/python2.7/site-packages/salt/state.py", line 1905, in call
                  **cdata['kwargs'])
                File "/usr/lib/python2.7/site-packages/salt/loader.py", line 1830, in wrapper
                  return f(*args, **kwargs)
                File "/usr/lib/python2.7/site-packages/salt/states/pip_state.py", line 681, in installed
                  out = _check_pkg_version_format(pkg)
                File "/usr/lib/python2.7/site-packages/salt/states/pip_state.py", line 147, in _check_pkg_version_format
                  install_req = InstallRequirement.from_line(pkg)
              AttributeError: type object 'InstallRequirement' has no attribute 'from_line'
     Started: 13:24:25.286429
    Duration: 232.88 ms
     Changes:

@gtmanfred
Copy link
Contributor

gtmanfred commented Oct 12, 2018

Yup that is what this issue is about, it will be fixed for 2018.3.4, in the mean run downgrade pip to less than 18.1

@lmbss
Copy link

lmbss commented Oct 12, 2018

Okay, no problem, I'm still using it in the lab, it was just reporting the problem.
thank you

@lsh-0
Copy link

lsh-0 commented Oct 19, 2018

I'm seeing this too after upgrading from 2017.7.5 to 2017.7.7 in order to fix this bug: #46163

----------
          ID: global-python-requisites
    Function: pip.installed
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/usr/lib/python2.7/dist-packages/salt/state.py", line 1879, in call
                  **cdata['kwargs'])
                File "/usr/lib/python2.7/dist-packages/salt/loader.py", line 1826, in wrapper
                  return f(*args, **kwargs)
                File "/usr/lib/python2.7/dist-packages/salt/states/pip_state.py", line 682, in installed
                  out = _check_pkg_version_format(pkg)
                File "/usr/lib/python2.7/dist-packages/salt/states/pip_state.py", line 149, in _check_pkg_version_format
                  install_req = InstallRequirement.from_line(pkg)
              AttributeError: type object 'InstallRequirement' has no attribute 'from_line'
     Started: 03:38:45.261020
    Duration: 431.364 ms
     Changes:   

versions

# salt-call --versions
Salt Version:
           Salt: 2017.7.7
 
Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 2.4.2
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.8
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: 1.0.3
   msgpack-pure: Not Installed
 msgpack-python: 0.4.6
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.12 (default, Dec  4 2017, 14:50:18)
   python-gnupg: Not Installed
         PyYAML: 3.11
          PyZMQ: 15.2.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.1.4
 
System Versions:
           dist: Ubuntu 16.04 xenial
         locale: UTF-8
        machine: x86_64
        release: 4.4.0-1030-aws
         system: Linux
        version: Ubuntu 16.04 xenial

@gtmanfred
Copy link
Contributor

gtmanfred commented Oct 19, 2018 via email

@gtmanfred gtmanfred added fixed-pls-verify fix is linked, bug author to confirm fix ZRELEASED - 2017.7.9 RETIRED LABEL labels Oct 29, 2018
@gtmanfred
Copy link
Contributor

This is fixed with #50280

@plagov
Copy link

plagov commented Dec 13, 2018

How can I install an older version of pip within a salt state? I tried the following declaration:

install python-pip:
  pkg.installed:
    - name: python-pip
    - version: 9.0.3

install python lib for docker:
  pip.installed:
    - name: docker == 3.6.0
    - require:
      - pkg: install python-pip

And still get the error. But also, I don't know what version of pip is being installed here.

@Ch3LL
Copy link
Contributor

Ch3LL commented Dec 14, 2018

can you verify its actually installing 9.0.3 when you run that state?Also if you run it a second time do you still see the error?

@plagov
Copy link

plagov commented Dec 14, 2018

@Ch3LL actually, I run it with the test=True flag, because the state is under WIP and I can't check the actual impact that the state makes.

@martinm82
Copy link

martinm82 commented Dec 17, 2018

I see that this issue got fixed in 2018.3.4 (#50280) but I still get it with that version.

@gtmanfred
Copy link
Contributor

How are you installing 2018.3.4, because that hasn't been released yet.

@dwickwire
Copy link

dwickwire commented Dec 19, 2018

Can I get a ball-park idea of when to expect 2018.3.4 please? Just upgraded all our minions to 2018.3.3 and am starting to try and use pip v18.1. Thanks!

@martinm82
Copy link

I am so sorry, I just added the version in my kitchen.yml and I somehow missed the error that the version does not exist.

@gtmanfred
Copy link
Contributor

you can check #releases on the salt community slack listed on the community page of saltstack.com https://saltstackcommunity.herokuapp.com

but @saltstack/team-triage might know a date.

I know right now they are working on getting an RC out for fluorine.

@gtmanfred
Copy link
Contributor

if you have to use pip 18.1 right now, you can always drop the pip.py module into salt://_modules like all other dynamic modules.

https://docs.saltstack.com/en/latest/ref/file_server/dynamic-modules.html

@dwickwire
Copy link

OK, I don't need pip v18.1 but this is more of a blocker to get to python 3.7, which is more important to me. Python doesn't seem to want to install 3.7 with pip v9.0.3, whereas it seems to install fine v18.1. Its been two months since the fix, which is why I asked. I'll check out the dynamic modules though, thanks for the tip.

@gtmanfred
Copy link
Contributor

did you try pip 10.x?

@dwickwire
Copy link

Oh hey, good idea. Just tried it, unfortunately python still won't install. All I'm getting is:

----------
          ID: python-3.7.0
    Function: pyenv.installed
      Result: False
     Comment: Could not install python.
     Started: 13:21:55.953496
    Duration: 1069.615 ms
     Changes:   

This doesn't occur with pip 18.1, instead I get the known AttributeError. I guess I can wait, its just nice to stay with the latest python. Or I'll just look into the dynamic modules you cited. Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior fixed-pls-verify fix is linked, bug author to confirm fix P2 Priority 2 severity-critical top severity, seen by most users, serious issues severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around State-Module v2018.3.4 unsupported version ZRELEASED - 2017.7.9 RETIRED LABEL
Projects
None yet
Development

No branches or pull requests

10 participants