question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Misleading error message when Pipfile is removed

See original GitHub issue

Issue description

When I remove the file Pipfile.lock it fails with a traceback:

...
  File "/Users/messa/code/gh/naucse.python.cz/myvenv/lib/python3.7/site-packages/pipenv/utils.py", line 355, in venv_resolve_deps
    escape_grouped_arguments(which("python", allow_global=allow_global)),
  File "/Users/messa/code/gh/naucse.python.cz/myvenv/lib/python3.7/site-packages/pipenv/core.py", line 109, in which
    if not location and os.path.exists(location):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/genericpath.py", line 19, in exists
    os.stat(path)
TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType

When I remove Pipfile it fails with another traceback:

  File "/Users/messa/code/gh/naucse.python.cz/myvenv/lib/python3.7/site-packages/pipenv/core.py", line 320, in ensure_pipfile
    project.create_pipfile(python=python)
  File "/Users/messa/code/gh/naucse.python.cz/myvenv/lib/python3.7/site-packages/pipenv/project.py", line 627, in create_pipfile
    config_parser = ConfigOptionParser(name=self.name)
  File "/Users/messa/code/gh/naucse.python.cz/myvenv/lib/python3.7/site-packages/pipenv/project.py", line 219, in name
    self._name = self.pipfile_location.split(os.sep)[-2]
AttributeError: 'NoneType' object has no attribute 'split'

Expected result

I would expect a proper error message that some required file is missing. I would expect such behavior from a high-level beginner-friendly software 😃

In case of the lock file I would expect a new lock file to be created (similar to npm, for example).

In the second case, the error happens inside create_pipfile, so maybe it is trying to create the pipflle, but still fails. So maybe it’s an another issue?


$ pipenv --support

Pipenv version: '2018.10.9'

Pipenv location: '/Users/messa/code/gh/naucse.python.cz/myvenv/lib/python3.7/site-packages/pipenv'

Python location: '/Users/messa/code/gh/naucse.python.cz/myvenv/bin/python'

Python installations found:

  • 3.7.0: /opt/local/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7
  • 3.7.0: /opt/local/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7m
  • 3.6.6: /opt/local/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6
  • 3.6.6: /opt/local/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6m
  • 3.5.6: /opt/local/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5m
  • 3.5.6: /opt/local/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5
  • 2.7.15: /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
  • 2.7.10: /usr/bin/python
  • 2.7.10: /usr/bin/pythonw
  • 2.7.10: /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.7.0',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '17.7.0',
 'platform_system': 'Darwin',
 'platform_version': 'Darwin Kernel Version 17.7.0: Thu Jun 21 22:53:14 PDT '
                     '2018; root:xnu-4570.71.2~1/RELEASE_X86_64',
 'python_full_version': '3.7.0',
 'python_version': '3.7',
 'sys_platform': 'darwin'}

System environment variables:

  • LANG
  • XPC_FLAGS
  • DISPLAY
  • OLDPWD
  • TERM_SESSION_ID
  • COLORTERM
  • __CF_USER_TEXT_ENCODING
  • ITERM_SESSION_ID
  • SSH_AUTH_SOCK
  • VIRTUAL_ENV
  • USER
  • PWD
  • HOME
  • TERM_PROGRAM
  • TERM_PROGRAM_VERSION
  • Apple_PubSub_Socket_Render
  • ITERM_PROFILE
  • TMPDIR
  • XPC_SERVICE_NAME
  • TERM
  • SHELL
  • SHLVL
  • COLORFGBG
  • LOGNAME
  • PATH
  • PS1
  • _
  • PYTHONDONTWRITEBYTECODE
  • PIP_SHIMS_BASE_MODULE
  • PIP_PYTHON_PATH

Pipenv–specific environment variables:

Debug–specific environment variables:

  • PATH: /Users/messa/code/gh/naucse.python.cz/myvenv/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/opt/local/libexec/gnubin
  • SHELL: /bin/bash
  • LANG: cs_CZ.UTF-8
  • PWD: /Users/messa/code/gh/naucse.python.cz
  • VIRTUAL_ENV: /Users/messa/code/gh/naucse.python.cz/myvenv

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
nathanielfordcommented, Oct 9, 2018

I am running into a similar problem when trying to import from a requirements file; it seems that because the Pipfile.lock is out of date it tries to remove it and fails.

PIPENV_VENV_IN_PROJECT=true pipenv install --three -r path/to/requirements.txt

Yields:

Pipfile.lock (948a23) out of date, updating to (799c69)…
Locking [dev-packages] dependencies…
Traceback (most recent call last):
  File "/usr/local/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/cli/command.py", line 249, in install
    editable_packages=state.installstate.editables,
  File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 1950, in do_install
    skip_lock=skip_lock,
  File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 1242, in do_init
    pypi_mirror=pypi_mirror,
  File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 1034, in do_lock
    pypi_mirror=pypi_mirror,
  File "/usr/local/lib/python3.6/site-packages/pipenv/utils.py", line 355, in venv_resolve_deps
    escape_grouped_arguments(which("python", allow_global=allow_global)),
  File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 109, in which
    if not location and os.path.exists(location):
  File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/genericpath.py", line 19, in exists
    os.stat(path)
TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType

This only seems to be a problem if the virtualenv is on. Thanks for the hard work maintaining this package!

1reaction
techalchemycommented, Oct 9, 2018

I would expect such behavior from a high-level beginner-friendly software 😃

Yes, software has bugs in it. This one is maintained by usually 1-2 volunteers at most. Please try to keep the conversation productive.

When you remove pipfile.lock, what fails? You removed your lockfile and then ran what command specifically? It’s not clear what happened here from the snipped output

Read more comments on GitHub >

github_iconTop Results From Across the Web

Misleading error message when Pipfile is removed - - Bountysource
Issue description. When I remove the file Pipfile.lock it fails with a traceback: .
Read more >
How to fix locking failed in pipenv? - Stack Overflow
Just delete the Pipfile.lock then rerun pipenv lock .
Read more >
Common Pipenv Errors and How to Solve Them: Why Won't it ...
Locking Issue: Pipfile Contains a Reference to an Inexistent Package ... Pipfile won't lock when it tries to install packages that don't exist,...
Read more >
Using Python's pip to Manage Your Projects' Dependencies
Reinstalling pip When Errors Occur. When you run the pip command, you may get an error in some cases. Your specific error message...
Read more >
pipenv Documentation
traceback - just the error. #2553. • Do not touch Pipfile early and rely on it so that one can do pipenv sync...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found