Repository: pypa/pipenv

Issue:
TypeError: On `pipenv graph`
<details><summary>$ python -m pipenv.help output</summary>

Pipenv version: `'2018.05.18'`
Pipenv location: `'/usr/local/lib/python3.6/site-packages/pipenv'`
Python location: `'/usr/local/opt/python/bin/python3.6'`

Other Python installations in `PATH`:

  - `2.7`: `/usr/bin/python2.7`
  - `2.7`: `/usr/bin/python2.7`
  - `3.6`: `/usr/local/bin/python3.6m`
  - `3.6`: `/usr/local/bin/python3.6`

  - `2.7.10`: `/usr/bin/python`
  - `3.6.5`: `/usr/local/bin/python3`

PEP 508 Information:

```
{'implementation_name': 'cpython',
 'implementation_version': '3.6.5',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '17.5.0',
 'platform_system': 'Darwin',
 'platform_version': 'Darwin Kernel Version 17.5.0: Fri Apr 13 19:32:32 PDT '
                     '2018; root:xnu-4570.51.2~1/RELEASE_X86_64',
 'python_full_version': '3.6.5',
 'python_version': '3.6',
 'sys_platform': 'darwin'}
```

System environment variables:

  - `Apple_PubSub_Socket_Render`
  - `HOME`
  - `LC_CTYPE`
  - `LOGNAME`
  - `PATH`
  - `PWD`
  - `SECURITYSESSIONID`
  - `SHELL`
  - `SSH_AUTH_SOCK`
  - `TERM`
  - `TERM_PROGRAM`
  - `TERM_PROGRAM_VERSION`
  - `TERM_SESSION_ID`
  - `TMPDIR`
  - `TMUX`
  - `TMUX_PANE`
  - `USER`
  - `XPC_FLAGS`
  - `XPC_SERVICE_NAME`
  - `SHLVL`
  - `OLDPWD`
  - `PYTHONSTARTUP`
  - `PYTHONDONTWRITEBYTECODE`
  - `BETTER_EXCEPTIONS`
  - `EDITOR`
  - `LESS`
  - `HOMEBREW_AUTO_UPDATE`
  - `HOMEBREW_NO_AUTO_UPDATE`
  - `HOMEBREW_GITHUB_API_TOKEN`
  - `ZSH_MULTILINE`
  - `NMAPDIR`
  - `GOPATH`
  - `STUDIO_JDK`
  - `ANDROID_HOME`
  - `ANDROID_NDK`
  - `ONO_GAC_PREFIX`
  - `JAVA_HOME`
  - `JDK_HOME`
  - `JRE_HOME`
  - `CLASSPATH`
  - `MPLBACKEND`
  - `ITERMPLOT`
  - `ITERMPLOT_LINES`
  - `PS1`
  - `RPS1`
  - `_`
  - `__CF_USER_TEXT_ENCODING`
  - `PIP_PYTHON_PATH`

Pipenv–specific environment variables:


Debug–specific environment variables:

  - `PATH`: `/usr/local/opt/llvm/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/opt/sqlite/bin:/Users/gordio/Library/Python/3.6/bin:/usr/local/opt/go/libexec/bin:/Users/gordio/Development/Deps/jdk1.8.0_101.jdk/Contents/Home/bin:/Users/gordio/Development/Deps/android-sdk-macosx/platform-tools:/usr/local/opt/fzf/bin`
  - `SHELL`: `/usr/local/bin/zsh`
  - `EDITOR`: `/usr/local/bin/nvim`
  - `PWD`: `/Users/gordio/Development/myproj`


---------------------------

Contents of `Pipfile` ('/Users/gordio/Development/myproj/Pipfile'):

```toml

```

</details>

------------

##### Expected result

You know… :-)

##### Actual result

```
Traceback (most recent call last):
  File "/usr/local/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/cli.py", line 850, in graph
    do_graph(bare=bare, json=json, reverse=reverse)
  File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 2410, in do_graph
    python_path = which('python')
  File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 121, in which
    location = project.virtualenv_location or os.environ.get('VIRTUAL_ENV')
  File "/usr/local/lib/python3.6/site-packages/pipenv/project.py", line 314, in virtualenv_location
    if not self.is_venv_in_project():
  File "/usr/local/lib/python3.6/site-packages/pipenv/project.py", line 219, in is_venv_in_project
    os.path.exists(os.path.join(self.project_directory, '.venv'))
  File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/posixpath.py", line 80, in join
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType
```

##### Steps to replicate

• As noob install `pip3 install pipenv` (python3 from home-brew)
• Run `pipenv graph`



Discussion:
Urrgh, I *hate* functions that returns `None` on error. Thanks for the report, will look into it.
What it was trying (and failed) to tell you is that you don’t have a Pipenv project to graph against. You need to create a Pipfile before you can use `graph`.
P.s. pipenv doesn’t do anything besides throw errors until you try to install things. 
Ps this one isn’t just about a pipfile but also having an environment created — pipenv graph looks in the virtualenv so if it can’t find one I guess this is what you see. Should add an error message on that function anyway, that causes most of our issues 
Hey, just wanted to add that this error occurs also with the command `pipenv --py`, in the same conditions (no environment in current project). Some commands, like `pipenv --venv` work as expected.

Resolving patch:
diff --git a/pipenv/project.py b/pipenv/project.py
--- a/pipenv/project.py
+++ b/pipenv/project.py
@@ -216,8 +216,8 @@ def requirements_exists(self):
         return bool(self.requirements_location)
 
     def is_venv_in_project(self):
-        return (
-            PIPENV_VENV_IN_PROJECT or
+        return PIPENV_VENV_IN_PROJECT or (
+            self.project_directory and
             os.path.exists(os.path.join(self.project_directory, '.venv'))
         )
 


Test patch: