Repository navigation
Closed
Labels
QuestionThe issue is more of a question rather than a bug or a feature requestneeds-more-infowaiting for more info
Milestone
Description
Description of Issue/Question
pip.installed fails to run:
----------
ID: devpi_venv_pkgs
Function: pip.installed
Result: False
Comment: An importable Python 2 pip module is required but could not be found on your system. This usually means that the system's pip package is not installed properly.
An importable Python 2 pip module is required but could not be found on your system. This usually means that the system's pip package is not installed properly.
Started: 16:46:18.340387
Duration: 1.242 ms
Changes: Setup
Relevant parts:
devpi_pip_pkg:
__env__: base
__sls__: venvs.webapps.devpi
pkg:
- name: py35-pip
- require:
- pkg: devpi_python_pkg
- installed
- order: 10007
devpi_python_pkg:
__env__: base
__sls__: venvs.webapps.devpi
pkg:
- name: python35
- installed
- order: 10005
devpi_venv:
__env__: base
__sls__: venvs.webapps.devpi
virtualenv:
- name: /usr/local/venvs/devpi
- venv_bin: /usr/local/bin/pyvenv-3.5
- system_site_packages: false
- user: www-devpi
- clear: false
- pip_upgrade: true
- pip_pkgs:
- pip
- setuptools
- certifi
- require:
- file: /usr/local/venvs/devpi
- user: www-devpi
- pkg: devpi_python_pkg
- pkg: postgresql93-client
- managed
- order: 10006
devpi_venv_pkgs:
__env__: base
__sls__: venvs.webapps.devpi
pip:
- pkgs:
- devpi-server
- devpi-web
- user: www-devpi
- cwd: /usr/local/venvs/devpi
- bin_env: /usr/local/venvs/devpi/bin/pip
- reload_modules: true
- require:
- virtualenv: devpi_venv
- pkg: devpi_pip_pkg
- installed
- order: 10008This is my complete sls:
{% if cfg.lang == 'python' %}
##########
# PYTHON #
##########
# Python packages
{{ venv }}_python_pkg:
pkg.installed:
- name: python{{ cfg.python_version|string|replace('.', '') }}
# Python virtualenv (only needed for Python 2)
{% if cfg.python_version == 2.7 %}
{{ venv }}_virtualenv_pkg:
pkg.installed:
- name: py27-virtualenv
{% endif %}
# Install the virtualenv
{{ venv }}_venv:
virtualenv.managed:
- name: {{ cfg.full_path }}
- venv_bin: {{ cfg.venv_builder }}
- system_site_packages: False
- user: {{ cfg.user }}
- clear: False
- pip_upgrade: True
- pip_pkgs:
- pip
- setuptools
- certifi
- require:
- file: {{ cfg.full_path }}
- user: {{ cfg.user }}
- pkg: {{ venv }}_python_pkg
- pkg: {{ salt['pillar.get']('postgresql:lookup:pkg_client') }}
{% if cfg.pip_pkgs is defined %}
{{ venv }}_pip_pkg:
pkg.installed:
- name: py{{ cfg.python_version|string|replace('.', '') }}-pip
- require:
- pkg: {{ venv }}_python_pkg
{{ venv }}_venv_pkgs:
pip.installed:
- pkgs:
{{ cfg.pip_pkgs|yaml }}
- user: {{ cfg.user }}
- cwd: {{ cfg.full_path }}
- bin_env: {{ cfg.pip }}
- reload_modules: True
- require:
- virtualenv: {{ venv }}_venv
- pkg: {{ venv }}_pip_pkg
{% endif %}
# Upgrade pip,setuptools,certifi to latest version (once the virtualenv is installed)
#{{ venv }}_upgrade_pip:
# cmd.run:
# - name: {{ cfg.pip }} --no-cache-dir install -U pip setuptools certifi
# - runas: {{ cfg.user }}
# - reload_modules: True
# - require:
# - virtualenv: {{ venv }}_venv
Steps to Reproduce Issue
Any pip.installed with Python 3 (haven't tested with Python 2) should fail, even when the pip package is installed globally (which should not be needed anyway).
This is because of https://github.com/saltstack/salt/blob/develop/salt/states/pip_state.py#L112-L119
Versions Report
salt% salt --versions-report
Salt Version:
Salt: 2017.7.2
Dependency Versions:
cffi: 1.11.2
cherrypy: Not Installed
dateutil: 2.6.1
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
ioflo: 1.5.0
Jinja2: 2.10
libgit2: Not Installed
libnacl: 1.5.2
M2Crypto: Not Installed
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.4.7
mysql-python: Not Installed
pycparser: 2.10
pycrypto: 2.6.1
pycryptodome: Not Installed
pygit2: Not Installed
Python: 2.7.14 (default, Jan 8 2018, 23:05:24)
python-gnupg: Not Installed
PyYAML: 3.11
PyZMQ: 16.0.3
RAET: 0.6.5
smmap: Not Installed
timelib: Not Installed
Tornado: 4.5.2
ZMQ: 4.2.2
System Versions:
dist:
locale: UTF-8
machine: amd64
release: 10.3-RELEASE
system: FreeBSD
version: Not InstalledMetadata
Metadata
Assignees
Labels
QuestionThe issue is more of a question rather than a bug or a feature requestneeds-more-infowaiting for more info
Activity
silenius commentedon Feb 23, 2018
Mmh I think I found the issue, Salt runs 2.7 and installed pip module was 3.5, it works when the py27-pip package is installed. Now I wonder why the pip package must be installed globally as it is already available in the virtualenv. I haven't yet looked in depth in the code, but I think that if bin_env is provided it should not be necessary to install pip globally .. or I missed something?
gtmanfred commentedon Feb 23, 2018
The pip module for the version of python that salt is running with needs to be installed, so that it can be imported and used to compare versions of packages.
ketzacoatl commentedon Apr 28, 2018
I am seeing this on
2018.3.0, and I believe this ticket should be re-opened (unless of course, I'm misunderstanding and there is known solution I'm not following) .Here is my versions report:
Pip is installed:
and it works:
But the same operation fails in salt's pip state or module:
ketzacoatl commentedon Apr 29, 2018
With
2017.7.3, and pip9.0.3, I can get this to work:That was tested with
salt-call --local state.low '{"state": "pip", "fun": "installed", "name": "django", "__id__": "django"}'. I will test other combinations of versions of saltstack and pip to see if I can pinpoint the issue more specifically. I think it might have to do with changes in pip 10.xketzacoatl commentedon Apr 29, 2018
It seems related to pip 10.x:
Here I downgrade to pip
9.0.3:Then install django with
pip.installedandstate.low:Upgrade to pip
10.0.1:Re-try using
pip.installed:ketzacoatl commentedon Apr 29, 2018
Where is saltstack trying to use pip's internals? Most places I look in the code I see saltstack using the pip executable, rather than importing and running from within salt. Is salt using pip in some way to introspect before calling the executable?
python/pip: pin version of pip installed
gtmanfred commentedon Apr 29, 2018
It is used in the pip state for comparing versions.
ketzacoatl commentedon Apr 30, 2018
Ah yes, your previous comment about that is now more clear to me. Using pip internals means salt breaks when those internals changes. Is there a way to do the version comparison using the executable instead of pip's internals?
rosscdh commentedon May 6, 2018
Suffering the same in Salt: 2018.3.0
ketzacoatl commentedon May 6, 2018
@rosscdh to confirm, the short-term workaround is to not use pip 10.x, eg pin pip to install 9.x.
rosscdh commentedon May 6, 2018
thanks yeah got that :) appreciate the feedback on sunday mate! keep up the amazing work
gtmanfred commentedon May 6, 2018
fixes for pip10 will be in 2017.7.6 and 2018.3.1 releases.
Tanoti commentedon May 25, 2018
@gtmanfred Do you know when the Centos and Red Hat rpms for these will be available? This has broken our salt/pip systems.
gtmanfred commentedon May 25, 2018
Both releases have been branched. Once the 2018.3.1 tests pass then there will be releases
https://jenkinsci.saltstack.com/job/2018.3.1/
Also, there is one last thing for 2017.7.6 and tornado 5.0 on python3 >=3.5
Reiner030 commentedon Nov 8, 2018
mmh... bug still exists / something else broken?
tested with:
and its already setup ???
MadsRC commentedon Jan 18, 2019
@ReinReiner030 I realize that I'm pretty late to the game, but I just fixed an identical problem for a client of mine (Hotfix, so I haven't digged into the actual source), but essentially it was due to an incompatible urlllib3 module being installed on the system.
Running "pip uninstall urllib3" removed version 1.24.1 from /usr/local/lib/python2.7/dist-packages, after which the Salt-Minion process was able to find version 1.19.1 which was installed in /usr/lib/python2.7/dist-packages (or run pip install urllib3==1.19.1)
A bit of salt hacking lead me to the actual exception happening when importing pip (pip_state.py). The exception was simply discarded, instead of logged - If I can find the time later, I'll see what I can do about making a PR.
Reiner030 commentedon Jan 25, 2019
Thanks @MadsRC - it seems now already fixed somehow by package update of Debian or perhaps saltstack.
compared to previous
salt-call --versions-reportI have now also setup:and aws cli was already setup in some run before.
Testing it now I get also an update like this - and there is shown that I have only urllib3 version 1.19.1 installed and now got 1.24.1 downloaded (and installed?):
And it's still running fine.
so it must be something else which depends of/to urllib or is meanwhile fixed.
Reiner030 commentedon Jan 25, 2019
Update: as @MadsRC wrote before (thx 😄 ) I had now also to uninstall urllib3 version 1.24.1 - in my case salt-cloud wasn't working:
michaelsaah commentedon Nov 6, 2019
I'd like to suggest that the version incompatibilities noted here (namely, that pip2 >= 10.* is incompatible w/ 2018.3.0) be added to the docs: https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.pip.html
EDIT: I see that the docs are hosted publicly; I'll make a PR.
dhs-rec commentedon Jan 29, 2020
Which Salt version contains the fix? I'm still seeing this (on Linux) runnig Salt Minion 2018.3.4 when I try to install modules into the systems Python 2 (no virtualenv) when the Minion itself is Python 3. Windows Python 3 minons (same version) don't have the problem. Path to pip is specified on both platforms using bin_env.
dhs-rec commentedon Jan 29, 2020
Quick test with 2018.3.5 (Py3) still triggers the error.
dhs-rec commentedon Jun 8, 2020
Still there in 3000.3(!). However, this time I even want to install Python 3 modules on a minion running Python3 Salt after explicitely installing python3-pip AND specifying
bin_env: /usr/bin/pip3.Please reopen.
peter-slovak commentedon Mar 26, 2021
FWIW, this is happening because the
Python2error message is hardcoded here regardless of what Python version you're runningsalt-minionin.Also, the
HAS_PIPflag is set based on whether we succeeded toimport pipin the interpreter that runssalt-minion(i.e. systempython3in case of @dhs-rec and mine), not based on whether there'spiporpip3installed in the targetbin_envvirtualenv.The workaround for me (Salt 3002.5 running on Ubuntu 20.04 with stock Python 3.8) is installing
python3-pipso that thepipstate is able toimport pipand happily continue.alan-cugler commentedon Feb 21, 2022
This is still an issue in 2022. The above solution from @peter-slovak also still works.