Pipenv: TypeError: 'NoneType' object is not subscriptable

Created on 17 Feb 2018  Â·  9Comments  Â·  Source: pypa/pipenv

Ubuntu: 16.04.3
Python: 3.5.2
Pipenv: 9.0.3

I was trying to initialize pipenv in a directory that happened to contain a file copy.py.

mkdir test
cd test
touch copy.py
pipenv --three

This fails with the following stack trace:

ubuntu@ip-172-30-1-145:~/test$ pipenv --three
Creating a virtualenv for this project…
Using /usr/bin/python3 to create virtualenv…
â ‹Already using interpreter /usr/bin/python3
Using base prefix '/usr'
Traceback (most recent call last):
  File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/virtualenv.py", line 2328, in <module>
    main()
  File "/home/ubuntu/.local/lib/python3.5/site-packages/virtualenv.py", line 713, in main
    symlink=options.symlink)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/virtualenv.py", line 925, in create_environment
    site_packages=site_packages, clear=clear, symlink=symlink))
  File "/home/ubuntu/.local/lib/python3.5/site-packages/virtualenv.py", line 1132, in install_python
    copy_required_modules(home_dir, symlink)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/virtualenv.py", line 1062, in copy_required_modules
    dst_filename = change_prefix(filename, dst_prefix)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/virtualenv.py", line 1036, in change_prefix
    (filename, prefixes)
AssertionError: Filename /home/ubuntu/test/copy.py does not start with any of these prefixes: ['/usr', '/usr']

Virtualenv location:
Creating a Pipfile for this project…
Traceback (most recent call last):
  File "/home/ubuntu/.local/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File "/home/ubuntu/.local/lib/python3.5/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/pipenv/vendor/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/pipenv/vendor/click/core.py", line 1043, in invoke
    return Command.invoke(self, ctx)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/pipenv/vendor/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/pipenv/cli.py", line 1724, in cli
    ensure_project(three=three, python=python, warn=True, site_packages=site_packages)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/pipenv/cli.py", line 642, in ensure_project
    ensure_pipfile(validate=validate)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/pipenv/cli.py", line 337, in ensure_pipfile
    project.create_pipfile(python=python)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/pipenv/project.py", line 406, in create_pipfile
    data[u'requires'] = {'python_version': python_version(python)[:len('2.7')]}
TypeError: 'NoneType' object is not subscriptable

If I remove copy.py pipenv works fine. I initially discovered this on OS X, but tried it out on a brand new Ubuntu EC2 instance to verify the same behavior.

Most helpful comment

It is not about whose bug it is, it is about users' ability or inability to use the product.
Virtualenv does work on its own and works reliably. So if PIPENV claims to be an advanced tool, but needs virtualenv to change, it is a no go.
Either you make it work with existing virtualenv, or create you own version of virtualenv (perhaps forked and patched original one, whatever) - otherwise the product is virtually useless. At least for our company.

All 9 comments

Thanks for opening this ticket, this is actually a virtualenv bug, not a pipenv bug :-/ (if you switch out virtualenv --python=python3 myenv for the pipenv install --three line you'll see a similar error)

So probably better to open it over here - https://github.com/pypa/virtualenv

I'm going to close this for now.

Uh, ok.

The problem is that python import semantics are such that the copy.py file
shadows the built in copy library. Tricky to deal with that :-/
On Sat, Feb 17, 2018 at 2:50 PM Ed Summers notifications@github.com wrote:

Uh, ok.

—
You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub
https://github.com/pypa/pipenv/issues/1441#issuecomment-366477223, or mute
the thread
https://github.com/notifications/unsubscribe-auth/ABhjq6W0WxhJxw5n0vMV8K_4kWM0YDjOks5tV1eegaJpZM4SJZ4A
.

It is not about whose bug it is, it is about users' ability or inability to use the product.
Virtualenv does work on its own and works reliably. So if PIPENV claims to be an advanced tool, but needs virtualenv to change, it is a no go.
Either you make it work with existing virtualenv, or create you own version of virtualenv (perhaps forked and patched original one, whatever) - otherwise the product is virtually useless. At least for our company.

@irving-ssk Last time I checked both Pipenv and virtualenv are very short on developers. Lend a hand if your company wants this so badly. We can use some resources. 🙂

Great point! Will try to find some time. :)

On Tue, Apr 24, 2018 at 3:24 PM, Tzu-ping Chung notifications@github.com
wrote:

@irving-ssk https://github.com/irving-ssk Last time I check both Pipenv
and virtualenv are very short on developers. Lend a hand if your company
wants this so badly. We can use some resources. 🙂

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/pypa/pipenv/issues/1441#issuecomment-384099254, or mute
the thread
https://github.com/notifications/unsubscribe-auth/Aifsa_54jxDZSn--TVSCPZ9mHgvlBnN-ks5tr6YqgaJpZM4SJZ4A
.

--

Irving Rabin, Software Guy Say Say K, Inc https://www.saysayk.com/
[email protected] 408-242-1299

@irving-ssk please don't come here and issue us ultimatums. If pipenv is 'useless' to your company because you insist on putting a file on your path which breaks virtualenv and you can't change that process, that's too bad.

Either you make it work with existing virtualenv, or create you own version of virtualenv (perhaps forked and patched original one, whatever)

This is not a productive approach. This is a volunteer project and it is open source, as @uranusjr mentions if your company has needs, it should invest its resources. Certainly it is not in a position to be making demands of what we do in our free time. I would direct you to our code of conduct and the code of conduct of the PyPA before you make any further contributions to our issue board.

Dan, sorry if it sounded this way - I am in no position to order to myself,
much less to anyone else.
I wasn't aware that it was a volunteer product. Sorry for miscommunication.
Please direct my to the code and if I can make some progress I would
definitely share it with you.
Thanks!

On Tue, Apr 24, 2018 at 3:30 PM, Dan Ryan notifications@github.com wrote:

@irving-ssk https://github.com/irving-ssk please don't come here and
issue us ultimatums. If pipenv is 'useless' to your company because you
insist on putting a file on your path which breaks virtualenv and you can't
change that process, that's too bad.

Either you make it work with existing virtualenv, or create you own
version of virtualenv (perhaps forked and patched original one, whatever)

This is not a productive approach. This is a volunteer project and it is
open source, as @uranusjr https://github.com/uranusjr mentions if your
company has needs, it should invest its resources. Certainly it is not in a
position to be making demands of what we do in our free time. I would
direct you to our code of conduct and the code of conduct of the PyPA
before you make any further contributions to our issue board.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/pypa/pipenv/issues/1441#issuecomment-384100449, or mute
the thread
https://github.com/notifications/unsubscribe-auth/Aifsa94XL-ttlv_PGa7mq2IKD07VeLfpks5tr6eIgaJpZM4SJZ4A
.

--

Irving Rabin, Software Guy Say Say K, Inc https://www.saysayk.com/
[email protected] 408-242-1299

No worries :D We all have the same goal which is to make better tools so it's never my aim to be harsh -- I just err on the side of strong reminders that we are volunteers because we legitimately do want help!

I honestly have absolutely no idea what copy.py is needed for or why it is searched -- will have to dig into the virtualenv code a bit to figure that out

Was this page helpful?
0 / 5 - 0 ratings