achillesrasquinha / pipupgrade

🗽 Like yarn outdated/upgrade, but for pip. Upgrade all your pip packages and automate your Python Dependency Management.

Home Page:https://git.io/pipupgrade

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incorrect path - missing " for windows

LarsK1 opened this issue · comments

What's the bug all about?

It doesn't run at, all because Windows is missing " around the path

What command led to this issue?

Please type the exact command that led to this issue.

$ pipupgrade

Logs

Please paste the logs using pipupgrade --verbose

2021-06-14 14:03:04,407 | INFO | Environment: {'version': '1.9.0', 'python_version': '3.9.5', 'os': 'Windows-10-10.0.19043-SP0', 'config': {'path': {'BASE': 'c:\\program files\\python39\\lib\\site-packages\\pipupgrade', 'DATA': 'c:\\program files\\python39\\lib\\site-packages\\pipupgrade\\data', 'CACHE': 'C:\\Users\\Lars-\\.config\\pipupgrade', 'JOBS': 'c:\\program files\\python39\\lib\\site-packages\\pipupgrade\\jobs'}}, 'settings': {'settings': {'version': '1.9.0', 'cache_timeout': '86400', 'jobs': '20'}}}
2021-06-14 14:03:04,407 | INFO | Arguments Passed: {'args': (), 'kwargs': {'ARGUMENTS': <class 'inspect._empty'>, 'packages': [], 'ignore': None, 'pip_path': None, 'yes': 0, 'check': 0, 'upgrade_type': ['minor', 'patch'], 'latest': 0, 'format': 'table', 'all': 0, 'pip': 0, 'self': False, 'requirements': None, 'pipfile': None, 'interactive': 0, 'project': None, 'git_username': None, 'git_email': None, 'pull_request': False, 'github_access_token': None, 'github_reponame': None, 'github_username': None, 'target_branch': 'master', 'jobs': 20, 'user': 0, 'no_included_requirements': 0, 'no_cache': 0, 'output': None, 'ignore_error': 0, 'force': 0, 'no_color': 0, 'verbose': True}, 'a': <pipupgrade.to_params.<locals>.O object at 0x000002522A4F2EB0>}
Checking...
2021-06-14 14:03:04,410 | INFO | `pip` executables found: ['C:\\Program Files\\Python39\\Scripts\\pip.EXE', 'C:\\Program Files\\Python39\\Scripts\\pip3.EXE']
2021-06-14 14:03:04,411 | INFO | Using 20 jobs...
2021-06-14 14:03:05,265 | INFO | Fetching installed packages for C:\Program Files\Python39\Scripts\pip.EXE...
2021-06-14 14:03:05,265 | INFO | Executing command: C:\Program Files\Python39\Scripts\pip.EXE list --outdated --format json
2021-06-14 14:03:05,288 | INFO | Fetching installed packages for C:\Program Files\Python39\Scripts\pip3.EXE...
2021-06-14 14:03:05,289 | INFO | Executing command: C:\Program Files\Python39\Scripts\pip3.EXE list --outdated --format json

multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
  File "c:\program files\python39\lib\multiprocessing\pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "c:\program files\python39\lib\site-packages\pipupgrade\commands\helper.py", line 320, in get_registry_from_pip
    _, output, _ = _pip.call("list", user = user, outdated = outdated, \
  File "c:\program files\python39\lib\site-packages\pipupgrade\_pip.py", line 75, in call
    output = popen(*params, output = output, raise_err = raise_err)
  File "c:\program files\python39\lib\site-packages\pipupgrade\util\system.py", line 92, in popen
    raise PopenError(code, command)
pipupgrade.exception.PopenError: Command 'C:\Program Files\Python39\Scripts\pip.EXE list --outdated --format json' returned non-zero exit status 1.
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "c:\program files\python39\lib\site-packages\pipupgrade\commands\__init__.py", line 78, in command
    return _command(**ARGUMENTS)
  File "c:\program files\python39\lib\site-packages\pipupgrade\commands\__init__.py", line 222, in _command
    for registry in pool.imap_unordered(
  File "c:\program files\python39\lib\multiprocessing\pool.py", line 870, in next
    raise value
pipupgrade.exception.PopenError: Command 'C:\Program Files\Python39\Scripts\pip.EXE list --outdated --format json' returned non-zero exit status 1.

An error occured while performing the above command. This could be an issue with
"pipupgrade". Kindly post an issue at https://github.com/achillesrasquinha/pipupgrade/issues

When running the command "C:\Program Files\Python39\Scripts\pip.EXE list" --outdated --format json it works perfectly fine

I've got similar error on Windows:

2022-04-17 21:47:54,867 | INFO | Environment: {'version': '0.4.0', 'python_version': '3.10.0', 'os': 'Windows-10-10.0.19044-SP0', 'config': {'path': {'BASE': 'C:\\Program Files\\Python310\\lib\\site-packages\\bpyutils', 'DATA': 'C:\\Program Files\\Python310\\lib\\site-packages\\bpyutils\\data', 'CACHE': 'C:\\Users\\user\\.config\\bpyutils', 'JOBS': 'C:\\Program Files\\Python310\\lib\\site-packages\\bpyutils\\jobs'}}, 'settings': {'settings': {'version': '0.4.0', 'cache_timeout': '86400', 'jobs': '12', 'max_chunk_download_bytes': '1024'}}}
2022-04-17 21:47:54,867 | INFO | Arguments Passed: {'args': (), 'kwargs': {'ARGUMENTS': <class 'inspect._empty'>, 'packages': [], 'resolve': False, 'ignore': None, 'pip_path': None, 'yes': True, 'clean': 0, 'check': 0, 'upgrade_type': ['minor', 'patch'], 'latest': True, 'format': 'table', 'all': 0, 'pip': 0, 'self': False, 'requirements': None, 'pipfile': None, 'interactive': 0, 'project': None, 'git_username': None, 'git_email': None, 'pull_request': False, 'github_access_token': None, 'github_reponame': None, 'github_username': None, 'target_branch': 'master', 'jobs': 12, 'user': 0, 'no_included_requirements': 0, 'no_cache': 0, 'output': None, 'ignore_error': 0, 'force': 0, 'doctor': False, 'no_color': 0, 'verbose': True}, 'a': <pipupgrade.commands.to_params.<locals>.O object at 0x0000014B88666620>}
Checking...
2022-04-17 21:47:54,870 | INFO | `pip` executables found: ['C:\\Program Files\\Python310\\Scripts\\pip.exe', 'C:\\Program Files\\Python310\\Scripts\\pip3.exe']
2022-04-17 21:47:54,870 | INFO | Using 12 jobs...
2022-04-17 21:47:55,450 | INFO | Fetching installed packages for C:\Program Files\Python310\Scripts\pip.exe...
2022-04-17 21:47:55,451 | INFO | Executing command: C:\Program Files\Python310\Scripts\pip.exe list --outdated --format json
2022-04-17 21:47:55,451 | INFO | Fetching installed packages for C:\Program Files\Python310\Scripts\pip3.exe...
2022-04-17 21:47:55,451 | INFO | Executing command: C:\Program Files\Python310\Scripts\pip3.exe list --outdated --format json

concurrent.futures.process._RemoteTraceback:
"""
Traceback (most recent call last):
  File "C:\Program Files\Python310\lib\concurrent\futures\process.py", line 243, in _process_worker
    r = call_item.fn(*call_item.args, **call_item.kwargs)
  File "C:\Program Files\Python310\lib\concurrent\futures\process.py", line 202, in _process_chunk
    return [fn(*args) for args in chunk]
  File "C:\Program Files\Python310\lib\concurrent\futures\process.py", line 202, in <listcomp>
    return [fn(*args) for args in chunk]
  File "C:\Program Files\Python310\lib\site-packages\pipupgrade\commands\helper.py", line 319, in get_registry_from_pip
    _, output, _ = _pip.call("list", user = user, outdated = outdated, \
  File "C:\Program Files\Python310\lib\site-packages\pipupgrade\_pip.py", line 79, in call
    output = popen(*params, output = output, raise_err = raise_err)
  File "C:\Program Files\Python310\lib\site-packages\bpyutils\util\system.py", line 113, in popen
    raise PopenError(code, command)
bpyutils.exception.PopenError: Command 'C:\Program Files\Python310\Scripts\pip.exe list --outdated --format json' returned non-zero exit status 1.
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Program Files\Python310\lib\site-packages\pipupgrade\commands\__init__.py", line 79, in command
    return _command(**ARGUMENTS)
  File "C:\Program Files\Python310\lib\site-packages\pipupgrade\commands\__init__.py", line 240, in _command
    for registry in pool.imap_unordered(
  File "C:\Program Files\Python310\lib\concurrent\futures\process.py", line 567, in _chain_from_iterable_of_lists
    for element in iterable:
  File "C:\Program Files\Python310\lib\concurrent\futures\_base.py", line 608, in result_iterator
    yield fs.pop().result()
  File "C:\Program Files\Python310\lib\concurrent\futures\_base.py", line 445, in result
    return self.__get_result()
  File "C:\Program Files\Python310\lib\concurrent\futures\_base.py", line 390, in __get_result
    raise self._exception
bpyutils.exception.PopenError: Command 'C:\Program Files\Python310\Scripts\pip.exe list --outdated --format json' returned non-zero exit status 1.

As a workaround I've added quoting of the path (that contains spaces in this case) in the call function inside _pip.py file:

def call(*args, **kwargs):
    pip_exec  = kwargs.pop("pip_exec", None)  or _PIP_EXECUTABLE
    # ... skipped some lines ...

    # Quote the path if it contains spaces (might be replaced with escaping)
    if ' ' in pip_exec and pip_exec[0] not in ["'", '"']:
        pip_exec = '"' + pip_exec + '"'

    # ... rest of the function ...

That fixed the issue for me.

@achillesrasquinha is that solution good enough for PR or should it be implemented in more elegant way?

@Habetdin please do go ahead with that PR.