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

PkgResourcesDeprecationWarning for every command executed with pipenv #4960

Closed
ShaiAvr opened this issue Feb 18, 2022 · 10 comments
Closed

PkgResourcesDeprecationWarning for every command executed with pipenv #4960

ShaiAvr opened this issue Feb 18, 2022 · 10 comments
Labels
Type: Question ❔ This is a question or a request for support.

Comments

@ShaiAvr
Copy link

ShaiAvr commented Feb 18, 2022

Issue description

I installed pipenv using pip install pipenv in my conda base environment. The installation was successful, but every command I run shows a weird warning at the start:

Anaconda3\lib\site-packages\pkg_resources\__init__.py:116: PkgResourcesDeprecationWarning: -PKG-VERSION is an invalid version and will not be supported in a future release
  warnings.warn(

This was from the simple command pipenv -h, but every command emits this warning before proceeding. The commands seem to work correctly, however. For pipenv -h, for example, the program displays the help message correctly after the warning.
Another thing I should note is that it looks like the warning slows down pipenv. When I run pipenv -h, for example, it takes about a second or two to display the warning, and after that, it takes additional 1~2 seconds to display the actual help message, or run the specified command for this matter.

Expected result

The commands executed by pipenv should not display this weird warning which seems out of nowhere. The commands shouldn't be slowed down because of this as well.

Actual result

Every command executed by pipenv displays this warning and executes around 1~2 seconds after that.

Steps to replicate

Just run any command like pipenv -h and see the warning. I am using Anaconda with Python 3.9.9 on Windows 11. I am not sure if any of these factors are related to the problem. As mentioned before, I installed pipenv into my (base) conda environment by running pip install pipenv.

$ pipenv --support result (Notice this command also printed the warning)

D:\Programs\Anaconda3\lib\site-packages\pkg_resources\__init__.py:116: PkgResourcesDeprecationWarning: -PKG-VERSION is an invalid version and will not be supported in a future release
  warnings.warn(
<details><summary>$ pipenv --support</summary>

Pipenv version: '2022.1.8'

Pipenv location: 'D:\\Programs\\Anaconda3\\lib\\site-packages\\pipenv'

Python location: 'D:\\Programs\\Anaconda3\\python.exe'

Python installations found:

  • 3.9.9: D:\Programs\Anaconda3\python.exe
  • 3.9.9: D:\Programs\Anaconda3\python.exe

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.9.9',
 'os_name': 'nt',
 'platform_machine': 'AMD64',
 'platform_python_implementation': 'CPython',
 'platform_release': '10',
 'platform_system': 'Windows',
 'platform_version': '10.0.22000',
 'python_full_version': '3.9.9',
 'python_version': '3.9',
 'sys_platform': 'win32'}

System environment variables:

  • ALLUSERSPROFILE
  • APPDATA
  • AZ_ENABLED
  • COMMONPROGRAMFILES
  • COMMONPROGRAMFILES(X86)
  • COMMONPROGRAMW6432
  • COMPUTERNAME
  • COMSPEC
  • CONDA_DEFAULT_ENV
  • CONDA_EXE
  • CONDA_PREFIX
  • CONDA_PROMPT_MODIFIER
  • CONDA_PYTHON_EXE
  • CONDA_SHLVL
  • DRIVERDATA
  • GOPATH
  • HOMEDRIVE
  • HOMEPATH
  • INTELLIJ IDEA COMMUNITY EDITION
  • JAVA_HOME
  • LOCALAPPDATA
  • LOGONSERVER
  • MOREPATHS
  • NUMBER_OF_PROCESSORS
  • ONEDRIVE
  • ONEDRIVECOMMERCIAL
  • ONEDRIVECONSUMER
  • OS
  • PATH
  • PATHEXT
  • PIPENV_VENV_IN_PROJECT
  • POSH_GIT_ENABLED
  • POWERLINE_COMMAND
  • POWERSHELL_DISTRIBUTION_CHANNEL
  • PROCESSOR_ARCHITECTURE
  • PROCESSOR_IDENTIFIER
  • PROCESSOR_LEVEL
  • PROCESSOR_REVISION
  • PROGRAMDATA
  • PROGRAMFILES
  • PROGRAMFILES(X86)
  • PROGRAMW6432
  • PSMODULEPATH
  • PUBLIC
  • PYCHARM COMMUNITY EDITION
  • SYSTEMDRIVE
  • SYSTEMROOT
  • TEMP
  • TMP
  • USERDOMAIN
  • USERDOMAIN_ROAMINGPROFILE
  • USERNAME
  • USERPROFILE
  • WINDIR
  • WORKON_HOME
  • WSLENV
  • WT_PROFILE_ID
  • WT_SESSION
  • _CONDA_EXE
  • _CONDA_ROOT
  • PIP_SHIMS_BASE_MODULE
  • PIP_DISABLE_PIP_VERSION_CHECK
  • PYTHONDONTWRITEBYTECODE
  • PIP_PYTHON_PATH
  • PYTHONFINDER_IGNORE_UNSUPPORTED

Pipenv–specific environment variables:

  • PIPENV_VENV_IN_PROJECT: 1

Debug–specific environment variables:

  • PATH: D:\Programs\Anaconda3;D:\Programs\Anaconda3\Library\mingw-w64\bin;D:\Programs\Anaconda3\Library\usr\bin;D:\Programs\Anaconda3\Library\bin;D:\Programs\Anaconda3\Scripts;D:\Programs\Anaconda3\bin;D:\Programs\Anaconda3\condabin;C:\Program Files\PowerShell\7;D:\Programs\Anaconda3;D:\Programs\Anaconda3\Library\mingw-w64\bin;D:\Programs\Anaconda3\Library\usr\bin;D:\Programs\Anaconda3\Library\bin;D:\Programs\Anaconda3\Scripts;D:\Portable_Programs\geckodriver;D:\Portable_Programs\Go\bin;D:\dev\go-workspace\bin;D:\Programs\NASM;.;C:\Program Files (x86)\Razer\ChromaBroadcast\bin;C:\Program Files\Razer\ChromaBroadcast\bin;C:\Program Files (x86)\Razer Chroma SDK\bin;C:\Program Files\Razer Chroma SDK\bin;c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\bin;d:\portable_programs\kotlin\kotlinc\bin;c:\program files (x86)\razer chroma sdk\bin;c:\program files\razer chroma sdk\bin;c:\program files (x86)\intel\intel(r) management engine components\icls;c:\program files\intel\intel(r) management engine components\icls;c:\windows\system32;c:\windows;c:\windows\system32\wbem;c:\windows\system32\windowspowershell\v1.0;c:\windows\system32\openssh;c:\program files (x86)\intel\intel(r) management engine components\dal;c:\program files\intel\intel(r) management engine components\dal;c:\program files (x86)\intel\intel(r) management engine components\ipt;c:\program files\intel\intel(r) management engine components\ipt;c:\windows\system32\config\systemprofile\appdata\local\microsoft\windowsapps;d:\programs\cmake\bin;c:\program files\nvidia corporation\nvidia nvdlisr;C:\Program Files\dotnet;D:\nodejs\npm;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Users\shai\AppData\Local\Microsoft\WindowsApps;C:\Users\shai\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\shai\AppData\Roaming\npm;D:\Programs\Git\cmd;C:\Users\shai\.dotnet\tools;C:\Program Files\Microsoft SQL Server\130\Tools\Binn;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn;D:\Programs\Calibre2;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;D:\Portable_Programs\Gradle\gradle-7.0.2\bin;D:\.jdks\openjdk-15.0.2\bin;D:\Programs (x86)\texlive\2021\bin\win32;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;D:\Programs\nodejs;C:\Program Files\PowerShell\7;C:\Program Files\Microsoft SQL Server\150\Tools\Binn;C:\Users\shai\.cargo\bin;D:\Programs\JetBrains\IntelliJ IDEA Community Edition 2018.3\bin;D:\Programs\JetBrains\PyCharm Community Edition 2019.2\bin;C:\Users\shai\AppData\Local\GitHubDesktop\bin;C:\Users\shai\AppData\Local\Programs\oh-my-posh\bin;C:\Users\shai\AppData\Local\Programs\oh-my-posh\themes

@matteius matteius added OS: Windows This issue affects the Windows Operating System. Type: Question ❔ This is a question or a request for support. labels Feb 18, 2022
@matteius
Copy link
Member

@ShaiAvr Have you tried it outside of Conda with a normal python install? I notice you have pipenv installed on a system path but the recommendation for using it well is to have it installed at the --user level and add that to your PATH. For example pip install pipenv --user instead of just pip install pipenv. I've used the latest version you are describing on Windows in recent days without these type of issues but I am not using Anaconda python. Also, this thread seems related: pdm-project/pdm#720

@matteius
Copy link
Member

@ShaiAvr I don't see also where you included a Pipfile to help debug with. If you create a new Pipfile with just one requirement say requests then do you still get this behavior?

@matteius
Copy link
Member

@ShaiAvr what version of setuptools do you have installed?
I have:

>>> import setuptools
>>> setuptools.__version__
'58.1.0'

This thread also seems related: pypa/setuptools#2466

@ShaiAvr
Copy link
Author

ShaiAvr commented Feb 19, 2022

@matteius I tried reinstalling it at the --user level after deactivating the conda environment, but the warning remains. Also, when I did which python or which pip in the base environment, I got the same results, which leads me to believe there is no difference between the base environment and the global interpreter.

Indeed I haven't tried creating a project. The warning was shown for the simple command pipenv -h and any other command which requires a project generates this warning and correctly fails since no Pipfile is present. I tried to create a simple project with the requests package. The install command still displayed the warning and the installation actually failed with this error message:

D:\Programs\Anaconda3\lib\site-packages\pkg_resources\__init__.py:116: PkgResourcesDeprecationWarning: -PKG-VERSION is an invalid version and will not be supported in a future release
  warnings.warn(
Creating a virtualenv for this project...
Pipfile: D:\dev\python\demo\Pipfile
Using D:/Programs/Anaconda3/python.exe (3.9.9) to create virtualenv...
[=== ] Creating virtual environment...created virtual environment CPython3.9.9.final.0-64 in 6826ms
  creator CPython3Windows(dest=D:\dev\python\demo\.venv, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=C:\Users\shai\AppData\Local\pypa\virtualenv)
    added seed packages: pip==22.0.3, setuptools==60.6.0, wheel==0.37.1
  activators BashActivator,BatchActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

Successfully created virtual environment!
Virtualenv location: D:\dev\python\demo\.venv
Creating a Pipfile for this project...
Installing requests...
Error:  An error occurred while installing requests!
Error text:
Traceback (most recent call last):
  File "D:\Programs\Anaconda3\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "D:\Programs\Anaconda3\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "D:\dev\python\demo\.venv\lib\site-packages\pip\__main__.py", line 29, in <module>
    from pip._internal.cli.main import main as _main
  File "D:\dev\python\demo\.venv\lib\site-packages\pip\_internal\cli\main.py", line 9, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "D:\dev\python\demo\.venv\lib\site-packages\pip\_internal\cli\autocompletion.py", line 10, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "D:\dev\python\demo\.venv\lib\site-packages\pip\_internal\cli\main_parser.py", line 8, in <module>
    from pip._internal.cli import cmdoptions
  File "D:\dev\python\demo\.venv\lib\site-packages\pip\_internal\cli\cmdoptions.py", line 23, in <module>
    from pip._internal.cli.parser import ConfigOptionParser
  File "D:\dev\python\demo\.venv\lib\site-packages\pip\_internal\cli\parser.py", line 12, in <module>
    from pip._internal.configuration import Configuration, ConfigurationError
  File "D:\dev\python\demo\.venv\lib\site-packages\pip\_internal\configuration.py", line 24, in <module>
    from pip._internal.utils import appdirs
  File "D:\dev\python\demo\.venv\lib\site-packages\pip\_internal\utils\appdirs.py", line 13, in <module>
    from pip._vendor import platformdirs as _appdirs
  File "D:\dev\python\demo\.venv\lib\site-packages\pip\_vendor\platformdirs\__init__.py", line 33, in <module>
    PlatformDirs = _set_platform_dir_class()  #: Currently active platform
  File "D:\dev\python\demo\.venv\lib\site-packages\pip\_vendor\platformdirs\__init__.py", line 29, in _set_platform_dir_class
    result: type[PlatformDirsABC] = getattr(importlib.import_module(module), name)
  File "D:\Programs\Anaconda3\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "D:\dev\python\demo\.venv\lib\site-packages\pip\_vendor\platformdirs\windows.py", line 3, in <module>
    import ctypes
  File "D:\Programs\Anaconda3\lib\ctypes\__init__.py", line 8, in <module>
    from _ctypes import Union, Structure, Array
ImportError: DLL load failed while importing _ctypes: The specified module could not be found.

Installation Failed

As for setuptools:

>>> import setuptools
>>> setuptools.__version__
'59.8.0'

@ShaiAvr
Copy link
Author

ShaiAvr commented Feb 20, 2022

@matteius

Update:

I managed to fix the error by reinstalling pipenv using conda instead of pip. It looks like the pip installation creates troubles in a conda environment. The weird warning still shows, however.

I created a sample project with the requests package. Everything was installed and executed successfully. However, every command still displayed the same warning. The Pipfile is extremely simple, so I don't believe it is useful or relevant to the issue, but here it is anyway:

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
requests = "*"

[dev-packages]

[requires]
python_version = "3.9"

And Pipfile.lock:

{
    "_meta": {
        "hash": {
            "sha256": "b8c2e1580c53e383cfe4254c1f16560b855d984fde8b2beb3bf6ee8fc2fe5a22"
        },
        "pipfile-spec": 6,
        "requires": {
            "python_version": "3.9"
        },
        "sources": [
            {
                "name": "pypi",
                "url": "https://pypi.org/simple",
                "verify_ssl": true
            }
        ]
    },
    "default": {
        "certifi": {
            "hashes": [
                "sha256:78884e7c1d4b00ce3cea67b44566851c4343c120abd683433ce934a68ea58872",
                "sha256:d62a0163eb4c2344ac042ab2bdf75399a71a2d8c7d47eac2e2ee91b9d6339569"
            ],
            "version": "==2021.10.8"
        },
        "charset-normalizer": {
            "hashes": [
                "sha256:2857e29ff0d34db842cd7ca3230549d1a697f96ee6d3fb071cfa6c7393832597",
                "sha256:6881edbebdb17b39b4eaaa821b438bf6eddffb4468cf344f09f89def34a8b1df"
            ],
            "markers": "python_version >= '3'",
            "version": "==2.0.12"
        },
        "idna": {
            "hashes": [
                "sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff",
                "sha256:9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d"
            ],
            "markers": "python_version >= '3'",
            "version": "==3.3"
        },
        "requests": {
            "hashes": [
                "sha256:68d7c56fd5a8999887728ef304a6d12edc7be74f1cfa47714fc8b414525c9a61",
                "sha256:f22fa1e554c9ddfd16e6e41ac79759e17be9e492b3587efa038054674760e72d"
            ],
            "index": "pypi",
            "version": "==2.27.1"
        },
        "urllib3": {
            "hashes": [
                "sha256:000ca7f471a233c2251c6c7023ee85305721bfdf18621ebff4fd17a8653427ed",
                "sha256:0e7c33d9a63e7ddfcb86780aac87befc2fbddf46c58dbb487e0855f7ceec283c"
            ],
            "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4'",
            "version": "==1.26.8"
        }
    },
    "develop": {}
}

@ShaiAvr
Copy link
Author

ShaiAvr commented Feb 20, 2022

@matteius

Another Update:

I just checked on my MacBook Pro with Anaconda installed and it seemed to work. I didn't get any warnings. This probably means the problem is happening in Windows or in Anaconda in Windows.

@kyleguarco
Copy link

I get this warning in Debian Sid Linux #1 SMP PREEMPT Debian 5.16.7-2 (2022-02-09) GNU/Linux.

$ pipenv 1> /dev/null
/home/kyleg/.local/lib/python3.9/site-packages/pkg_resources/__init__.py:122: PkgResourcesDeprecationWarning: 2.8.2.dev9999-git.b-82c1373ba0b424c57e8c12cb5f6f1a7ee3829c27- is an invalid version and will not be supported in a future release
  warnings.warn(
/home/kyleg/.local/lib/python3.9/site-packages/pkg_resources/__init__.py:122: PkgResourcesDeprecationWarning: 1.16.0-unknown is an invalid version and will not be supported in a future release
  warnings.warn(

Which is funny, because neither of these warnings relate to pipenv at all. These are versions of other python packages installed on my system (powerline-status==2.8.2.dev9999-git.b-82c1373ba0b424c57e8c12cb5f6f1a7ee3829c27- on user and gpg==1.16.0-unknown via the apt package python3-gpg).

Why is it showing warnings for other packages and how do we silence them?

@kyleguarco
Copy link

kyleguarco commented Feb 23, 2022

Related issue; This led to setuptools introducing the warning.
pypa/setuptools#296 (located using the setuptools version history)

@matteius
Copy link
Member

Why is it showing warnings for other packages and how do we silence them?

I don't exactly know what is going on here, but I think if the versions of things you had installed were compliant version numbers then you wouldn't get the warning. Sorry I am not more help here but I am going to take off the Windows label because I don't believe it is specific to windows. I think that @ShaiAvr has some old package as well that is violating the correct version numbering constraints and so getting a warning on Windows.

Would be really helpful if there were clear steps on how to reproduce this on a new machine that isn't having the warnings show up. If the answer is install a version of something that violates the package versioning that won't be supported in the future then I think we can close this as won't fix because it was a decision in the packages we depend on to through this warning and eventually not support those version numbers.

@matteius matteius removed the OS: Windows This issue affects the Windows Operating System. label Mar 13, 2022
@ytoku
Copy link

ytoku commented Aug 4, 2022

workaround for unix-like system users
Replace your pipenv command file with following warning filtered version

#!/usr/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
import warnings
from pkg_resources import PkgResourcesDeprecationWarning
warnings.simplefilter("ignore", category=PkgResourcesDeprecationWarning)
from pipenv import cli
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(cli())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Question ❔ This is a question or a request for support.
Projects
None yet
Development

No branches or pull requests

4 participants