Pipenv: Traceback when trying to create an environment w/ interpreter specified by its path

Created on 8 Mar 2018  Â·  12Comments  Â·  Source: pypa/pipenv

Can't create an environment with the Python interpreter specified on the command-line (don't know if other options work since I only have py on my PATH).

Describe your environment
  1. OS Type: Windows 10
  2. Python version: 3.6.4
  3. Pipenv version: 1.11.5
Expected result

A virtual environment is created.

Actual result

An exception was raised.

Steps to replicate
> py -3 -m pipenv --python C:\Users\brcan\AppData\Local\Programs\Python\Python36\python.exe
Creating a virtualenv for this project…
Using C:\Users\brcan\AppData\Local\Programs\Python\Python36\python.exe to create virtualenv…
Already using interpreter C:\Users\brcan\AppData\Local\Programs\Python\Python36\python.exe
Using base prefix 'C:\\Users\\brcan\\AppData\\Local\\Programs\\Python\\Python36'
New python executable in C:\Users\brcan\.virtualenvs\bunk-M_X9FcBv\Scripts\python.exe
Installing setuptools, pip, wheel...done.

Virtualenv location:
Traceback (most recent call last):
  File "C:\Users\brcan\AppData\Local\Programs\Python\Python36\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\brcan\AppData\Local\Programs\Python\Python36\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\brcan\AppData\Local\Programs\Python\Python36\lib\site-packages\pipenv\__main__.py", line 4, in <module>
    cli()
  File "C:\Users\brcan\AppData\Local\Programs\Python\Python36\lib\site-packages\pipenv\vendor\click\core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\brcan\AppData\Local\Programs\Python\Python36\lib\site-packages\pipenv\vendor\click\core.py", line 697, in main
    rv = self.invoke(ctx)
  File "C:\Users\brcan\AppData\Local\Programs\Python\Python36\lib\site-packages\pipenv\vendor\click\core.py", line 1043, in invoke
    return Command.invoke(self, ctx)
  File "C:\Users\brcan\AppData\Local\Programs\Python\Python36\lib\site-packages\pipenv\vendor\click\core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\brcan\AppData\Local\Programs\Python\Python36\lib\site-packages\pipenv\vendor\click\core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "C:\Users\brcan\AppData\Local\Programs\Python\Python36\lib\site-packages\pipenv\vendor\click\decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "C:\Users\brcan\AppData\Local\Programs\Python\Python36\lib\site-packages\pipenv\cli.py", line 154, in cli
    core.ensure_project(three=three, python=python, warn=True, site_packages=site_packages)
  File "C:\Users\brcan\AppData\Local\Programs\Python\Python36\lib\site-packages\pipenv\core.py", line 638, in ensure_project
    crayons.green(shorten_path(path_to_python))
  File "C:\Users\brcan\AppData\Local\Programs\Python\Python36\lib\site-packages\pipenv\core.py", line 698, in shorten_path
    short = os.sep.join([s[0] if len(s) > (len('2long4')) else s for s in location.split(os.sep)])
AttributeError: 'NoneType' object has no attribute 'split'
Type

All 12 comments

I apologize for there being so many issues with Windows — our userbase on Windows is small, so we don't get many reports.

We do test on Windows, though!

P.S. Want to write a breaking test? :)

wow I haven't ever seen that one before....

No problem about the breakage; I realize I'm trailblazing here. 😄 I'm happy to keep trying and filing issues as I come across them to help out, so no hard feelings at all on my end.

As for writing the test, I will see if I can find the time but I unfortunately can't make any promises ATM (I'm still playing catch-up with stuff that backed up from our latest release of VS Code which added pipenv support 😉 ).

Just trying to trick @brettcannon into becoming a committer :)

You can make him a committer but that probably doesn't guarantee he'll ever commit anything :p

@techalchemy I can guarantee it makes not guarantees, just ask Nathaniel Smith about how much I have contributed to Trio after getting committer rights 😉

I think I’ve got it. The problem is not Windows-specific, but happens when you don’t have any python command available in PATH at all. Un*x systems typically always have a system-wide python, which is likely why no-one found out until now.

Aha! Nice catch, @uranusjr!

I’ll produce a pull request later (at work right now).

@kennethreitz Are you open to adding type-checking to some code paths (with something like mypy)? It would prevent some of these problems in the future.

I think that would just add maintenance burden (and I’m not personally a fan of commented mypy typing, prefer hardcoded style).

Sent from my iPhone

On Mar 8, 2018, at 8:55 PM, Tzu-ping Chung notifications@github.com wrote:

@kennethreitz Are you open to adding type-checking to some code paths (with something like mypy)? It would prevent some of these problems in the future.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jacebrowning picture jacebrowning  Â·  3Comments

jerzyk picture jerzyk  Â·  3Comments

hynek picture hynek  Â·  3Comments

konstin picture konstin  Â·  3Comments

jakul picture jakul  Â·  3Comments