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

Do not raise exception for pipenv graph when virtualenv does not exist #3201

Closed
jxltom opened this issue Nov 9, 2018 · 1 comment · Fixed by #3202
Closed

Do not raise exception for pipenv graph when virtualenv does not exist #3201

jxltom opened this issue Nov 9, 2018 · 1 comment · Fixed by #3202

Comments

@jxltom
Copy link
Contributor

jxltom commented Nov 9, 2018

Issue description

When virutaulenv is not created for a project yet, pipenv graph will raise exception.

➜  pipenv graph
Traceback (most recent call last):
  File "/usr/local/bin/pipenv", line 11, in <module>
    load_entry_point('pipenv', 'console_scripts', 'pipenv')()
  File "/home/user/Documents/dev/pipenv/pipenv/vendor/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/user/Documents/dev/pipenv/pipenv/vendor/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/user/Documents/dev/pipenv/pipenv/vendor/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/user/Documents/dev/pipenv/pipenv/vendor/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/user/Documents/dev/pipenv/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/user/Documents/dev/pipenv/pipenv/cli/command.py", line 538, in graph
    do_graph(bare=bare, json=json, json_tree=json_tree, reverse=reverse)
  File "/home/user/Documents/dev/pipenv/pipenv/core.py", line 2430, in do_graph
    python_path = which("python")
  File "/home/user/Documents/dev/pipenv/pipenv/core.py", line 110, in which
    raise RuntimeError("location not created nor specified")
RuntimeError: location not created nor specified

It happens at least for v2018.10.13.

Expected result

It should be a friendly info.

➜  pipenv graph
Warning: No virtualenv has been created for this project yet! Consider running `pipenv install` first to automatically generate one for you or see`pipenv install --help` for further instructions.

Please run $ pipenv --support, and paste the results here. Don't put backticks (`) around it! The output already contains Markdown formatting.

If you're on macOS, run the following:

$ pipenv --support | pbcopy

If you're on Windows, run the following:

> pipenv --support | clip

If you're on Linux, run the following:

$ pipenv --support | xclip
@DannyDannyDanny
Copy link

I'm having an issue with setting up Pipenv in a certain directory. There used to be an old pipenv there, which I tried to delete:

  • deleted env with pew rm [env-name]
  • manually deleted the Pipfile from the directory (it was not deleted by pew rm)
  • tried to setup a new pipenv with pipenv shell

Last step failed with following output:

Creating a Pipfile for this project…
Traceback (most recent call last):
  File "/usr/local/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.7/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.7/site-packages/pipenv/vendor/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/pipenv/cli/command.py", line 374, in shell
    pypi_mirror=state.pypi_mirror,
  File "/usr/local/lib/python3.7/site-packages/pipenv/core.py", line 2069, in do_shell
    ensure_project(three=three, python=python, validate=False, pypi_mirror=pypi_mirror)
  File "/usr/local/lib/python3.7/site-packages/pipenv/core.py", line 601, in ensure_project
    validate=validate, skip_requirements=skip_requirements, system=system
  File "/usr/local/lib/python3.7/site-packages/pipenv/core.py", line 324, in ensure_pipfile
    project.create_pipfile(python=python)
  File "/usr/local/lib/python3.7/site-packages/pipenv/project.py", line 673, in create_pipfile
    required_python = self.which("python", self.virtualenv_location)
  File "/usr/local/lib/python3.7/site-packages/pipenv/core.py", line 114, in which
    raise RuntimeError("location not created nor specified")
RuntimeError: location not created nor specified

pbcopy from pipenv --support | pbcopy:

<details><summary>$ pipenv --support</summary>

Pipenv version: `'2018.10.13'`

Pipenv location: `'/usr/local/lib/python3.7/site-packages/pipenv'`

Python location: `'/usr/local/opt/python/bin/python3.7'`

Python installations found:

pipenv --support | pbcopy also crashes with following output:

Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. You can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead. You can set PIPENV_VERBOSITY=-1 to suppress this warning.
Traceback (most recent call last):
  File "/usr/local/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 1114, in invoke
    return Command.invoke(self, ctx)
  File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/pipenv/cli/command.py", line 142, in cli
    get_pipenv_diagnostics()
  File "/usr/local/lib/python3.7/site-packages/pipenv/help.py", line 33, in get_pipenv_diagnostics
    python_paths = finder.find_all_python_versions()
  File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/pythonfinder/pythonfinder.py", line 112, in find_all_python_versions
    major=major, minor=minor, patch=patch, pre=pre, dev=dev, arch=arch
  File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/pythonfinder/models/path.py", line 222, in find_all_python_versions
    return [c for c in sorted(path_filter, key=version_sort, reverse=True)]
AttributeError: 'list' object has no attribute 'as_python'

I'm going to try delete the whole directory, make a new directory (with same name) and try again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants