title: pip install requirements.txt fails with AssertionError: Egg-link does not match installed location
body: <p>I'm working on a Python/C++ project that's both a library and and Application. I'm having the problem that running</p>
  
  <pre><code>$ pip install -r requirements.txt
  </code></pre>
  
  <p>twice gives me the following error (this is the second run):</p>
  
  <pre><code>$ pip install -r requirements.txt
  Obtaining file:///Users/aaragon/Local/myproject (from -r requirements.txt (line 3))
  Requirement already satisfied: numpy in /Users/aaragon/.virtualenvs/test/lib/python3.5/site-packages (from myproject ==0.21.0-&gt;-r requirements.txt (line 3))
  Requirement already satisfied: scipy in /Users/aaragon/.virtualenvs/test/lib/python3.5/site-packages (from myproject ==0.21.0-&gt;-r requirements.txt (line 3))
  Requirement already satisfied: Sphinx in /Users/aaragon/.virtualenvs/test/lib/python3.5/site-packages (from myproject ==0.21.0-&gt;-r requirements.txt (line 3))
  Requirement already satisfied: pytest in /Users/aaragon/.virtualenvs/test/lib/python3.5/site-packages (from myproject ==0.21.0-&gt;-r requirements.txt (line 3))
  Requirement already satisfied: matplotlib in /Users/aaragon/.virtualenvs/test/lib/python3.5/site-packages (from myproject ==0.21.0-&gt;-r requirements.txt (line 3))
  Requirement already satisfied: dill in /Users/aaragon/.virtualenvs/test/lib/python3.5/site-packages (from myproject ==0.21.0-&gt;-r requirements.txt (line 3))
  Requirement already satisfied: alabaster&lt;0.8,&gt;=0.7 in /Users/aaragon/.virtualenvs/test/lib/python3.5/site-packages (from Sphinx-&gt; myproject ==0.21.0-&gt;-r requirements.txt (line 3))
  Requirement already satisfied: setuptools in /Users/aaragon/.virtualenvs/test/lib/python3.5/site-packages (from Sphinx-&gt; myproject ==0.21.0-&gt;-r requirements.txt (line 3))
  Requirement already satisfied: docutils&gt;=0.11 in /Users/aaragon/.virtualenvs/test/lib/python3.5/site-packages (from Sphinx-&gt; myproject ==0.21.0-&gt;-r requirements.txt (line 3))
  Requirement already satisfied: snowballstemmer&gt;=1.1 in /Users/aaragon/.virtualenvs/test/lib/python3.5/site-packages (from Sphinx-&gt; myproject ==0.21.0-&gt;-r requirements.txt (line 3))
  Requirement already satisfied: six&gt;=1.5 in /Users/aaragon/.virtualenvs/test/lib/python3.5/site-packages (from Sphinx-&gt; myproject ==0.21.0-&gt;-r requirements.txt (line 3))
  Requirement already satisfied: babel!=2.0,&gt;=1.3 in /Users/aaragon/.virtualenvs/test/lib/python3.5/site-packages (from Sphinx-&gt; myproject ==0.21.0-&gt;-r requirements.txt (line 3))
  Requirement already satisfied: Pygments&gt;=2.0 in /Users/aaragon/.virtualenvs/test/lib/python3.5/site-packages (from Sphinx-&gt; myproject ==0.21.0-&gt;-r requirements.txt (line 3))
  Requirement already satisfied: requests&gt;=2.0.0 in /Users/aaragon/.virtualenvs/test/lib/python3.5/site-packages (from Sphinx-&gt; myproject ==0.21.0-&gt;-r requirements.txt (line 3))
  Requirement already satisfied: sphinxcontrib-websupport in /Users/aaragon/.virtualenvs/test/lib/python3.5/site-packages (from Sphinx-&gt; myproject ==0.21.0-&gt;-r requirements.txt (line 3))
  Requirement already satisfied: Jinja2&gt;=2.3 in /Users/aaragon/.virtualenvs/test/lib/python3.5/site-packages (from Sphinx-&gt; myproject ==0.21.0-&gt;-r requirements.txt (line 3))
  Requirement already satisfied: imagesize in /Users/aaragon/.virtualenvs/test/lib/python3.5/site-packages (from Sphinx-&gt; myproject ==0.21.0-&gt;-r requirements.txt (line 3))
  Requirement already satisfied: py&gt;=1.4.33 in /Users/aaragon/.virtualenvs/test/lib/python3.5/site-packages (from pytest-&gt; myproject ==0.21.0-&gt;-r requirements.txt (line 3))
  Requirement already satisfied: pytz in /Users/aaragon/.virtualenvs/test/lib/python3.5/site-packages (from matplotlib-&gt; myproject ==0.21.0-&gt;-r requirements.txt (line 3))
  Requirement already satisfied: python-dateutil&gt;=2.0 in /Users/aaragon/.virtualenvs/test/lib/python3.5/site-packages (from matplotlib-&gt; myproject ==0.21.0-&gt;-r requirements.txt (line 3))
  Requirement already satisfied: cycler&gt;=0.10 in /Users/aaragon/.virtualenvs/test/lib/python3.5/site-packages (from matplotlib-&gt; myproject ==0.21.0-&gt;-r requirements.txt (line 3))
  Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,&gt;=2.0.1 in /Users/aaragon/.virtualenvs/test/lib/python3.5/site-packages (from matplotlib-&gt; myproject ==0.21.0-&gt;-r requirements.txt (line 3))
  Requirement already satisfied: urllib3&lt;1.23,&gt;=1.21.1 in /Users/aaragon/.virtualenvs/test/lib/python3.5/site-packages (from requests&gt;=2.0.0-&gt;Sphinx-&gt; myproject ==0.21.0-&gt;-r requirements.txt (line 3))
  Requirement already satisfied: certifi&gt;=2017.4.17 in /Users/aaragon/.virtualenvs/test/lib/python3.5/site-packages (from requests&gt;=2.0.0-&gt;Sphinx-&gt; myproject ==0.21.0-&gt;-r requirements.txt (line 3))
  Requirement already satisfied: idna&lt;2.7,&gt;=2.5 in /Users/aaragon/.virtualenvs/test/lib/python3.5/site-packages (from requests&gt;=2.0.0-&gt;Sphinx-&gt; myproject ==0.21.0-&gt;-r requirements.txt (line 3))
  Requirement already satisfied: chardet&lt;3.1.0,&gt;=3.0.2 in /Users/aaragon/.virtualenvs/test/lib/python3.5/site-packages (from requests&gt;=2.0.0-&gt;Sphinx-&gt; myproject ==0.21.0-&gt;-r requirements.txt (line 3))
  Requirement already satisfied: MarkupSafe&gt;=0.23 in /Users/aaragon/.virtualenvs/test/lib/python3.5/site-packages (from Jinja2&gt;=2.3-&gt;Sphinx-&gt; myproject ==0.21.0-&gt;-r requirements.txt (line 3))
  Installing collected packages: myproject
    Found existing installation: myproject 0.21.0
  Exception:
  Traceback (most recent call last):
    File "/Users/aaragon/.virtualenvs/test/lib/python3.5/site-packages/pip/basecommand.py", line 215, in main
  status = self.run(options, args)
    File "/Users/aaragon/.virtualenvs/test/lib/python3.5/site-packages/pip/commands/install.py", line 342, in run
  prefix=options.prefix_path,
    File "/Users/aaragon/.virtualenvs/test/lib/python3.5/site-packages/pip/req/req_set.py", line 778, in install
  requirement.uninstall(auto_confirm=True)
    File "/Users/aaragon/.virtualenvs/test/lib/python3.5/site-packages/pip/req/req_install.py", line 703, in uninstall
  '(at %s)' % (link_pointer, self.name, dist.location)
  AssertionError: Egg-link /Users/aaragon/Local/myproject does not match installed location of myproject (at /Users/aaragon/Local/myproject/src)
  </code></pre>
  
  <p>I need to run it as many times as possible because the <code>pip install</code> will be part of a Makefile or easing the life of end users of the application.
  I found only <a href="https://stackoverflow.com/questions/43177200/assertionerror-egg-link-does-not-match-installed-location-of-reviewboard-at">one post</a> with this issue but no path to a solution.</p>