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

Install fails for local package with (escaped) space in local path #6308

Open
webbsledge opened this issue Nov 3, 2024 · 2 comments
Open
Labels
Contributor Candidate The issue has been identified/triaged and contributions are welcomed/encouraged.

Comments

@webbsledge
Copy link

webbsledge commented Nov 3, 2024

Issue description

pipenv install -e /path/to\ the\ local/directory/ fails when run from the command line using zsh. I did not test other shells.

After further testing, I found that the package installed successfully with pipenv install -e /path/to_the_local/directory, which leads me to believe pipenv has a bug which needs to resolve globing/regex from the command line

Expected result

I would have expected pipenv to handle the escaped spaces in the path sequence correctly.

Actual result

Output below from pipenv install -e /Users/sledge/Development/API/IBKR/IB\ Gateway/IBTJts/source/pythonclient/

Note the escaped space in .../IB\ Gateway/... above.

Installing -e /Users/sledge/Development/API/IBKR/IB Gateway/IBJts/source/pythonclient/...
✔ Installation Succeeded
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
Installing dependencies from Pipfile.lock (f449ce)...
All dependencies are now up-to-date!
Upgrading -e /Users/sledge/Development/API/IBKR/IB Gateway/IBJts/source/pythonclient/ in  dependencies.
Building requirements...
Resolving dependencies...
✘ Locking Failed!
⠼ Locking packages...False
<console width=216 ColorSystem.EIGHT_BIT>
Traceback (most recent call last):
  File "/opt/homebrew/bin/pipenv", line 8, in <module>
    sys.exit(cli())
             ~~~^^
  File "/opt/homebrew/Cellar/pipenv/2024.3.1/libexec/lib/python3.13/site-packages/pipenv/vendor/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/pipenv/2024.3.1/libexec/lib/python3.13/site-packages/pipenv/cli/options.py", line 52, in main
    return super().main(*args, **kwargs, windows_expand_args=False)
           ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/pipenv/2024.3.1/libexec/lib/python3.13/site-packages/pipenv/vendor/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/opt/homebrew/Cellar/pipenv/2024.3.1/libexec/lib/python3.13/site-packages/pipenv/vendor/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/opt/homebrew/Cellar/pipenv/2024.3.1/libexec/lib/python3.13/site-packages/pipenv/vendor/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/pipenv/2024.3.1/libexec/lib/python3.13/site-packages/pipenv/vendor/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/opt/homebrew/Cellar/pipenv/2024.3.1/libexec/lib/python3.13/site-packages/pipenv/vendor/click/decorators.py", line 92, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/pipenv/2024.3.1/libexec/lib/python3.13/site-packages/pipenv/vendor/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/opt/homebrew/Cellar/pipenv/2024.3.1/libexec/lib/python3.13/site-packages/pipenv/cli/command.py", line 207, in install
    do_install(
    ~~~~~~~~~~^
        state.project,
        ^^^^^^^^^^^^^^
    ...<14 lines>...
        skip_lock=state.installstate.skip_lock,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/opt/homebrew/Cellar/pipenv/2024.3.1/libexec/lib/python3.13/site-packages/pipenv/routines/install.py", line 310, in do_install
    new_packages, _ = handle_new_packages(
                      ~~~~~~~~~~~~~~~~~~~^
        project,
        ^^^^^^^^
    ...<9 lines>...
        index=index,
        ^^^^^^^^^^^^
    )
    ^
  File "/opt/homebrew/Cellar/pipenv/2024.3.1/libexec/lib/python3.13/site-packages/pipenv/routines/install.py", line 114, in handle_new_packages
    do_update(
    ~~~~~~~~~^
        project,
        ^^^^^^^^
    ...<7 lines>...
        categories=pipfile_categories,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/opt/homebrew/Cellar/pipenv/2024.3.1/libexec/lib/python3.13/site-packages/pipenv/routines/update.py", line 75, in do_update
    upgrade(
    ~~~~~~~^
        project,
        ^^^^^^^^
    ...<9 lines>...
        extra_pip_args=extra_pip_args,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/opt/homebrew/Cellar/pipenv/2024.3.1/libexec/lib/python3.13/site-packages/pipenv/routines/update.py", line 367, in upgrade
    upgrade_lock_data = venv_resolve_deps(
        requested_packages[pipfile_category],
    ...<6 lines>...
        pypi_mirror=pypi_mirror,
    )
  File "/opt/homebrew/Cellar/pipenv/2024.3.1/libexec/lib/python3.13/site-packages/pipenv/utils/resolver.py", line 907, in venv_resolve_deps
    c = resolve(cmd, st, project=project)
  File "/opt/homebrew/Cellar/pipenv/2024.3.1/libexec/lib/python3.13/site-packages/pipenv/utils/resolver.py", line 771, in resolve
    raise RuntimeError("Failed to lock Pipfile.lock!")
RuntimeError: Failed to lock Pipfile.lock!

Steps to replicate

Provide the steps to replicate (which usually at least includes the commands and the Pipfile).

Simply try to install any local directory as a package, where the local directory has spaces in the path name that need to be escaped in the system shell.


$ pipenv --support

Pipenv version: '2024.3.1'

Pipenv location: '/opt/homebrew/Cellar/pipenv/2024.3.1/libexec/lib/python3.13/site-packages/pipenv'

Python location: '/opt/homebrew/Cellar/pipenv/2024.3.1/libexec/bin/python'

OS Name: 'posix'

User pip version: '24.2'

user Python installations found:

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.13.0',
 'os_name': 'posix',
 'platform_machine': 'arm64',
 'platform_python_implementation': 'CPython',
 'platform_release': '24.1.0',
 'platform_system': 'Darwin',
 'platform_version': 'Darwin Kernel Version 24.1.0: Thu Oct 10 21:03:11 PDT '
                     '2024; root:xnu-11215.41.3~2/RELEASE_ARM64_T6020',
 'python_full_version': '3.13.0',
 'python_version': '3.13',
 'sys_platform': 'darwin'}

System environment variables:

  • TERM_SESSION_ID
  • SSH_AUTH_SOCK
  • LC_TERMINAL_VERSION
  • COLORFGBG
  • ITERM_PROFILE
  • XPC_FLAGS
  • LANG
  • PWD
  • SHELL
  • __CFBundleIdentifier
  • TERM_FEATURES
  • TERM_PROGRAM_VERSION
  • TERM_PROGRAM
  • PATH
  • LC_TERMINAL
  • COLORTERM
  • COMMAND_MODE
  • TERM
  • TERMINFO_DIRS
  • HOME
  • TMPDIR
  • USER
  • XPC_SERVICE_NAME
  • LOGNAME
  • ITERM_SESSION_ID
  • __CF_USER_TEXT_ENCODING
  • SHLVL
  • OLDPWD
  • HOMEBREW_PREFIX
  • HOMEBREW_CELLAR
  • HOMEBREW_REPOSITORY
  • INFOPATH
  • PYENV_SHELL
  • P9K_TTY
  • _P9K_TTY
  • ZSH
  • LS_COLORS
  • ZSH_COMPDUMP
  • PAGER
  • LESS
  • LSCOLORS
  • P9K_SSH
  • _P9K_SSH_TTY
  • EDITOR
  • FZF_DEFAULT_OPTS
  • FZF_DEFAULT_COMMAND
  • FZF_CTRL_T_COMMAND
  • FZF_ALT_C_COMMAND
  • FZF_CTRL_T_OPTS
  • FZF_ALT_C_OPTS
  • BAT_THEME
  • AICHAT_CONFIG_DIR
  • NVM_DIR
  • NVM_CD_FLAGS
  • NVM_BIN
  • NVM_INC
  • PYENV_ROOT
  • _
  • PIP_DISABLE_PIP_VERSION_CHECK
  • PYTHONDONTWRITEBYTECODE
  • PYTHONFINDER_IGNORE_UNSUPPORTED

Pipenv–specific environment variables:

Debug–specific environment variables:

  • PATH: /Users/sledge/.pyenv/versions/3.11.10/bin:/Users/sledge/.pyenv/versions/3.12.7/bin:/Users/sledge/.pyenv/versions/3.13.0/bin:/Users/sledge/.pyenv/versions/3.10.15/bin:/Users/sledge/.pyenv/shims:/Users/sledge/.nvm/versions/node/v20.16.0/bin:/Users/sledge/.pyenv/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Applications/iTerm.app/Contents/Resources/utilities:/Users/sledge/Library/Application Support/JetBrains/Toolbox/scripts
  • SHELL: /opt/homebrew/bin/zsh
  • EDITOR: nvim
  • LANG: en_US.UTF-8
  • PWD: /Users/sledge/Development/Python/security-analysis

Contents of Pipfile ('/Users/sledge/Development/Python/security-analysis/Pipfile'):

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

[packages]
sqlalchemy = "*"
psycopg = "*"
ipykernel = "*"
jupyter = "*"
fredapi = "*"
schwab-py = "*"
quantlib = "*"
pandas = "*"
numpy = "*"
matplotlib = "*"
pyarrow = "*"
sec-edgar-api = "*"
scikit-learn = "*"
edgartools = {file = "../edgartools", editable = true}
pyportfolioopt = {file = "../PyPortfolioOpt", editable = true}
ibapi = {file = "../../API/IBKR/IB_Gateway/IBJts/source/pythonclient", editable = true}

[dev-packages]

[requires]
python_version = "3.13"
python_full_version = "3.13.0"

Contents of Pipfile.lock ('/Users/sledge/Development/Python/security-analysis/Pipfile.lock'):

This is too long to include.

@matteius matteius added the Contributor Candidate The issue has been identified/triaged and contributions are welcomed/encouraged. label Nov 5, 2024
@jaeyongjaykim
Copy link

encountering same issue..

@jaeyongjaykim
Copy link

I've had exact same issue but now I figured out by running pipenv sync. @webbsledge

After running pipenv sync,

...
: Collecting psycopg2==2.9.9 (from -r /var/folders/zb/82_7gyvx75gbnnh0qqls8bjm0000gn/T/pipenv-a0t8wv86-requirements/pipenv-acc5wlq8-hashed-reqs.txt
(line 62))
:   Using cached psycopg2-2.9.9.tar.gz (384 kB)
:   Installing build dependencies: started
:   Installing build dependencies: finished with status 'done'
:   Getting requirements to build wheel: started
:   Getting requirements to build wheel: finished with status 'error'
: error: subprocess-exited-with-error
:
:   × Getting requirements to build wheel did not run successfully.
:   │ exit code: 1
:   ╰─> [21 lines of output]
:       running egg_info
:       writing psycopg2.egg-info/PKG-INFO
:       writing dependency_links to psycopg2.egg-info/dependency_links.txt
:       writing top-level names to psycopg2.egg-info/top_level.txt
:
:       Error: pg_config executable not found.
:
:       pg_config is required to build psycopg2 from source.  Please add the directory
:       containing pg_config to the $PATH or specify the full executable path with the
:       option:
:
:           python setup.py build_ext --pg-config /path/to/pg_config build ...
:
:       or with the pg_config option in 'setup.cfg'.
:
:       If you prefer to avoid building psycopg2 from source, please install the PyPI
:       'psycopg2-binary' package instead.
:
:       For further information please check the 'doc/src/install.rst' file (also at
:       <https://www.psycopg.org/docs/install.html>).
:
:
:
:   note: This error originates from a subprocess, and is likely not a problem with pip.
: error: subprocess-exited-with-error
:
: × Getting requirements to build wheel did not run successfully.
: │ exit code: 1
: ╰─> See above for output.
:
: note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Couldn't install package: [1m{}[0m
 [33mPackage installation failed...[0m

I've changed psycopg2psycopg2-binary and now pipenv lock works back again with no error.

If you have psycopg2 on your Pipfile, then try switching to psycopg2-binary or try running pipenv sync to see if it gives more helpful error message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Contributor Candidate The issue has been identified/triaged and contributions are welcomed/encouraged.
Projects
None yet
Development

No branches or pull requests

3 participants