Repository: pypa/pipenv

Issue:
Can not generate Pipfile.lock by installing packages with requirementx.txt on Python 2.7
Describe the issue briefly here.
Run: $pipenv install -r requirements.txt
Got error: 
Creating a virtualenv for this project...
Pipfile: /home/ec2-user/test/Pipfile
Using /usr/bin/python2.7 (2.7.14) to create virtualenv...
⠋Already using interpreter /usr/bin/python2.7
New python executable in /home/ec2-user/.local/share/virtualenvs/test-LVXQY0Nl/bin/python2.7
Also creating executable in /home/ec2-user/.local/share/virtualenvs/test-LVXQY0Nl/bin/python
Installing setuptools, pip, wheel...done.
Setting project for test-LVXQY0Nl to /home/ec2-user/test

Virtualenv location: /home/ec2-user/.local/share/virtualenvs/test-LVXQY0Nl
Creating a Pipfile for this project...
Requirements file provided! Importing into Pipfile...
Traceback (most recent call last):
  File "/usr/local/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python2.7/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/pipenv/vendor/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/pipenv/cli.py", line 416, in install
    selective_upgrade=selective_upgrade,
  File "/usr/local/lib/python2.7/site-packages/pipenv/core.py", line 1854, in do_install
    import_requirements(r=project.path_to(requirements), dev=dev)
  File "/usr/local/lib/python2.7/site-packages/pipenv/core.py", line 228, in import_requirements
    project.recase_pipfile()
  File "/usr/local/lib/python2.7/site-packages/pipenv/project.py", line 766, in recase_pipfile
    if self.ensure_proper_casing():
  File "/usr/local/lib/python2.7/site-packages/pipenv/project.py", line 802, in ensure_proper_casing
    casing_changed = self.proper_case_section(pfile.get('packages', {}))
  File "/usr/local/lib/python2.7/site-packages/pipenv/project.py", line 826, in proper_case_section
    self.register_proper_name(new_casing)
  File "/usr/local/lib/python2.7/site-packages/pipenv/project.py", line 366, in register_proper_name
    f.write('{0}\n'.format(name))
TypeError: write() argument 1 must be unicode, not str
/usr/local/lib/python2.7/site-packages/pipenv/_compat.py:108: ResourceWarning: Implicitly cleaning up <TemporaryDirectory '/tmp/pipenv-2ttppI-requirements'>
  warnings.warn(warn_message, ResourceWarning)


Please run `$ python -m pipenv.help`, and paste the results here.
<details><summary>$ python -m pipenv.help output</summary>

Pipenv version: `'2018.6.25'`

Pipenv location: `'/usr/local/lib/python2.7/site-packages/pipenv'`

Python location: `'/usr/bin/python'`

Other Python installations in `PATH`:

  - `2.7`: `/usr/bin/python2.7`
  - `2.7`: `/usr/bin/python2.7`

  - `2.7.14`: `/usr/bin/python`

PEP 508 Information:

```
{'implementation_name': 'cpython',
 'implementation_version': '0',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '4.14.33-51.37.amzn1.x86_64',
 'platform_system': 'Linux',
 'platform_version': '#1 SMP Thu May 3 20:07:43 UTC 2018',
 'python_full_version': '2.7.14',
 'python_version': '2.7',
 'sys_platform': 'linux2'}
```

System environment variables:

  - `LC_CTYPE`
  - `PYTHONDONTWRITEBYTECODE`
  - `LESSOPEN`
  - `SSH_CLIENT`
  - `LOGNAME`
  - `USER`
  - `HOME`
  - `PATH`
  - `AWS_PATH`
  - `LANG`
  - `LESS_TERMCAP_se`
  - `TERM`
  - `SHELL`
  - `EC2_AMITOOL_HOME`
  - `LESS_TERMCAP_me`
  - `LESS_TERMCAP_md`
  - `LESS_TERMCAP_mb`
  - `HISTSIZE`
  - `AWS_ELB_HOME`
  - `JAVA_HOME`
  - `EC2_HOME`
  - `AWS_AUTO_SCALING_HOME`
  - `PIP_PYTHON_PATH`
  - `_`
  - `LESS_TERMCAP_ue`
  - `SSH_CONNECTION`
  - `AWS_CLOUDWATCH_HOME`
  - `SSH_TTY`
  - `OLDPWD`
  - `HOSTNAME`
  - `HISTCONTROL`
  - `SHLVL`
  - `PWD`
  - `LESS_TERMCAP_us`
  - `MAIL`
  - `LS_COLORS`

Pipenv–specific environment variables:


Debug–specific environment variables:

  - `PATH`: `/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/aws/bin:/home/ec2-user/.local/bin:/home/ec2-user/bin`
  - `SHELL`: `/bin/bash`
  - `LANG`: `en_US.UTF-8`
  - `PWD`: `/home/ec2-user/test`


---------------------------

Contents of `Pipfile` ('/home/ec2-user/test/Pipfile'):

```toml
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[dev-packages]

[packages]
flask = "==0.10.1"
"jinja2" = "==2.7.3"
werkzeug = "==0.10"

[requires]
python_version = "2.7"

```

</details>
If you're on MacOS, just run the following:

    $ python -m pipenv.help | pbcopy

------------

##### Expected result

Describe what you expected.

##### Actual result

When possible, provide the verbose output (`--verbose`), especially for locking and dependencies resolving issues.


Discussion:

Resolving patch:
diff --git a/pipenv/project.py b/pipenv/project.py
--- a/pipenv/project.py
+++ b/pipenv/project.py
@@ -363,7 +363,7 @@ def proper_names(self):
     def register_proper_name(self, name):
         """Registers a proper name to the database."""
         with self.proper_names_db_path.open('a') as f:
-            f.write('{0}\n'.format(name))
+            f.write(u'{0}\n'.format(name))
 
     @property
     def pipfile_location(self):


Test patch: