TypeError: 'NoneType' object is not subscriptable
See original GitHub issueUbuntu: 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.
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
TypeError: 'NoneType' object is not subscriptable
NoneType is the type of the None object which represents a lack of value, for example, a function that does not explicitly return...
Read more >Python Math - TypeError: 'NoneType' object is not subscriptable
The reason that lista gets set to None is because the return value of list.sort() is None ... it does not return a...
Read more >Python TypeError: 'NoneType' object is not subscriptable
The “TypeError: 'NoneType' object is not subscriptable” error is common if you assign the result of a built-in list method like sort() ,...
Read more >Python Nonetype Object Is Not Subscriptable - MindMajix
The TypeError: Nonetype object is not subscriptable is an error that occurs when you try to subscript an object that has a none...
Read more >TypeError: 'NoneType' object is not subscriptable - STechies
In python, objects which implement the __getitem__ method known as a subscriptable object. In simple words, we can say it describes objects that...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub 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 thepipenv 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.
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.