{"action":"created","issue":{"url":"https://api.github.com/repos/pypa/pipenv/issues/1625","repository_url":"https://api.github.com/repos/pypa/pipenv","labels_url":"https://api.github.com/repos/pypa/pipenv/issues/1625/labels{/name}","comments_url":"https://api.github.com/repos/pypa/pipenv/issues/1625/comments","events_url":"https://api.github.com/repos/pypa/pipenv/issues/1625/events","html_url":"https://github.com/pypa/pipenv/issues/1625","id":303723893,"number":1625,"title":"ResourceWarning: Implicitly cleaning up TemporaryDirectory.","user":{"login":"SalchiPapa","id":4594825,"avatar_url":"https://avatars0.githubusercontent.com/u/4594825?v=4","gravatar_id":"","url":"https://api.github.com/users/SalchiPapa","html_url":"https://github.com/SalchiPapa","followers_url":"https://api.github.com/users/SalchiPapa/followers","following_url":"https://api.github.com/users/SalchiPapa/following{/other_user}","gists_url":"https://api.github.com/users/SalchiPapa/gists{/gist_id}","starred_url":"https://api.github.com/users/SalchiPapa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SalchiPapa/subscriptions","organizations_url":"https://api.github.com/users/SalchiPapa/orgs","repos_url":"https://api.github.com/users/SalchiPapa/repos","events_url":"https://api.github.com/users/SalchiPapa/events{/privacy}","received_events_url":"https://api.github.com/users/SalchiPapa/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-03-09T04:51:47Z","updated_at":"2018-03-09T06:09:33Z","closed_at":null,"author_association":"NONE","body":"During a vagrant provisioning, pipenv recently started to fail at creating the Pipfile, Pipfile.lock files and install the packages.\r\n\r\nRequirements.txt:\r\n\r\n```\r\nMySQL-python\r\nPillow\r\nclosure\r\nmock\r\nyuicompressor\r\nzc.buildout\r\nrequests\r\nwebtest\r\nwebob\r\ndjango-webtest\r\ndjango-jenkins\r\ncoverage\r\npep8\r\npyflakes\r\nfreezegun\r\nfabric\r\nSphinx\r\npyparsing\r\ndjango\r\n```\r\n\r\n**This was working until yesterday.**\r\n\r\n##### Describe your environment\r\n\r\n1. OS Type: Ubuntu Xenial 64 bits\r\n2. Python version: 2.7.12\r\n3. Pipenv version: 11.1.5\r\n4. VirtualBox: 5.2.8 r121009\r\n5. Vagrant: 2.0.1\r\n\r\n##### Expected result\r\n\r\nThis should create Pipfile, Pipfile.lock and install the packages.\r\n\r\n##### Actual result\r\n\r\n```\r\n    default: requirements.txt found, instead of Pipfile! Converting…\r\n    default: Traceback (most recent call last):\r\n    default:   File \"/usr/local/bin/pipenv\", line 9, in <module>\r\n    default:     \r\n    default: load_entry_point('pipenv==11.1.5', 'console_scripts', 'pipenv')()\r\n    default:   File \"/usr/local/lib/python2.7/dist-packages/pipenv/vendor/click/core.py\", line 722, in __call__\r\n    default:     \r\n    default: return self.main(*args, **kwargs)\r\n    default:   File \"/usr/local/lib/python2.7/dist-packages/pipenv/vendor/click/core.py\", line 697, in main\r\n    default:     \r\n    default: rv = self.invoke(ctx)\r\n    default:   File \"/usr/local/lib/python2.7/dist-packages/pipenv/vendor/click/core.py\", line 1066, in invoke\r\n    default:     \r\n    default: return _process_result(sub_ctx.command.invoke(sub_ctx))\r\n    default:   File \"/usr/local/lib/python2.7/dist-packages/pipenv/vendor/click/core.py\", line 895, in invoke\r\n    default:     \r\n    default: return ctx.invoke(self.callback, **ctx.params)\r\n    default:   File \"/usr/local/lib/python2.7/dist-packages/pipenv/vendor/click/core.py\", line 535, in invoke\r\n    default:     \r\n    default: return callback(*args, **kwargs)\r\n    default:   File \"/usr/local/lib/python2.7/dist-packages/pipenv/cli.py\", line 197, in install\r\n    default:     \r\n    default: selective_upgrade=selective_upgrade\r\n    default:   File \"/usr/local/lib/python2.7/dist-packages/pipenv/core.py\", line 1731, in do_install\r\n    default:     \r\n    default: ensure_project(three=three, python=python, system=system, warn=True, deploy=deploy, skip_requirements=skip_requirements)\r\n    default:   File \"/usr/local/lib/python2.7/dist-packages/pipenv/core.py\", line 652, in ensure_project\r\n    default:     ensure_pipfile(validate=validate, skip_requirements=skip_requirements)\r\n    default:   File \"/usr/local/lib/python2.7/dist-packages/pipenv/core.py\", line 319, in ensure_pipfile                                           \r\n    default:     project.create_pipfile(python=python)                                                                                             \r\n    default:   File \"/usr/local/lib/python2.7/dist-packages/pipenv/project.py\", line 439, in create_pipfile\r\n    default:     data[u'requires'] = {'python_version': python_version(self.which('python'))[:len('2.7')]}\r\n    default: TypeError:                                                                                                                            \r\n    default: 'NoneType' object has no attribute '__getitem__'\r\n    default: /usr/local/lib/python2.7/dist-packages/pipenv/utils.py:1149: ResourceWarning: Implicitly cleaning up <TemporaryDirectory '/tmp/pipenv-hmGOVq-requirements'>                                                                                                                              \r\n    default:   warnings.warn(warn_message, ResourceWarning)\r\n```\r\n\r\n##### Steps to replicate\r\n\r\n```bash\r\n# This script is called when `vagrant up` or `vagrant provision` are called.\r\nfunction install_python_dependencies {\r\n    pip install pipenv  >> bootstrap.log\r\n    cd /vagrant\r\n   # don't use virtual env in vagrant/docker\r\n    pipenv install --system  >> bootstrap.log\r\n}\r\ninstall_python_dependencies\r\n```\r\n\r\nRelated: #90, #132 \r\n\r\n* **'NoneType' object has no attribute `'__getitem__'`**"},"comment":{"url":"https://api.github.com/repos/pypa/pipenv/issues/comments/371722880","html_url":"https://github.com/pypa/pipenv/issues/1625#issuecomment-371722880","issue_url":"https://api.github.com/repos/pypa/pipenv/issues/1625","id":371722880,"user":{"login":"SalchiPapa","id":4594825,"avatar_url":"https://avatars0.githubusercontent.com/u/4594825?v=4","gravatar_id":"","url":"https://api.github.com/users/SalchiPapa","html_url":"https://github.com/SalchiPapa","followers_url":"https://api.github.com/users/SalchiPapa/followers","following_url":"https://api.github.com/users/SalchiPapa/following{/other_user}","gists_url":"https://api.github.com/users/SalchiPapa/gists{/gist_id}","starred_url":"https://api.github.com/users/SalchiPapa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SalchiPapa/subscriptions","organizations_url":"https://api.github.com/users/SalchiPapa/orgs","repos_url":"https://api.github.com/users/SalchiPapa/repos","events_url":"https://api.github.com/users/SalchiPapa/events{/privacy}","received_events_url":"https://api.github.com/users/SalchiPapa/received_events","type":"User","site_admin":false},"created_at":"2018-03-09T06:09:33Z","updated_at":"2018-03-09T06:09:33Z","author_association":"NONE","body":"@techalchemy I wanted to use the lock file in docker/vagrant venvs are not that useful, because there is already isolation for each VM/container instance. \r\n\r\n `which` is expecting a virtual env, but I install with `--system` flag (no venv).\r\n\r\nThe issue is that `python_version` is returning None. Since it fails to determine the path to the python executable (should be an error instead of None IMO), because `which` returns an empty string for `project.virtualenv_location`, giving the wrong path.\r\n\r\n```python\r\nIn [1]: from pipenv.project import Project                    \r\n\r\nIn [2]: from pipenv.utils import python_version\r\n\r\nIn [3]: from pipenv.core import which          \r\n\r\nIn [4]: import os, sys                         \r\n\r\nIn [5]: project = Project(which=which)         \r\n\r\nIn [6]: project.virtualenv_location            \r\nOut[6]: ''\r\n\r\nIn [7]: which(\"python\")\r\nOut[7]: '/bin/python'\r\n\r\nIn [8]: python_version(which('python')) == None\r\nOut[8]: True\r\n\r\nIn [9]: project.create_pipfile()               \r\n---------------------------------------------------------------------------\r\nTypeError                                 Traceback (most recent call last)\r\n<ipython-input-9-b7788d16c4cf> in <module>()\r\n----> 1 project.create_pipfile()\r\n\r\n/usr/local/lib/python2.7/dist-packages/pipenv/project.pyc in create_pipfile(self, python)\r\n    437 \r\n    438         # Default requires.\r\n--> 439         data[u'requires'] = {'python_version': python_version(self.which('python'))[:len('2.7')]}\r\n    440\r\n    441         self.write_toml(data, 'Pipfile')\r\n\r\nTypeError: 'NoneType' object has no attribute '__getitem__'\r\n\r\nIn [10]: python_version(which('python'))[:len('2.7')]\r\n---------------------------------------------------------------------------\r\nTypeError                                 Traceback (most recent call last)\r\n<ipython-input-10-1b24167d70c7> in <module>()\r\n----> 1 python_version(which('python'))[:len('2.7')]\r\n\r\nTypeError: 'NoneType' object has no attribute '__getitem__'\r\n```\r\n\r\n"}}
{"actor":{"display_login":"SalchiPapa"}}