question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Homebrew-installed Pipenv defaults to Homebrew-created virtualenv Python

See original GitHub issue

As following log, it will use /usr/local/Cellar/pipenv/2018.5.18/libexec/bin/python3.6, instead of use system installed python

🚀  pipenv install --dev
Warning: the environment variable LANG is not set!
We recommend setting this in ~/.profile (or equivalent) for proper expected behavior.
Creating a virtualenv for this project…
Using /usr/local/Cellar/pipenv/2018.5.18/libexec/bin/python3.6 (3.6.5) to create virtualenv…
⠋Already using interpreter /usr/local/Cellar/pipenv/2018.5.18/libexec/bin/python3.6
Using real prefix '/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6'
New python executable in /Users/aweimeow/pipenv/.venv/bin/python3.6
Also creating executable in /Users/aweimeow/pipenv/.venv/bin/python
Installing setuptools, pip, wheel...done.

Virtualenv location: /Users/aweimeow/pipenv/.venv
Installing dependencies from Pipfile.lock (ae475c)…
Ignoring colorama: markers 'sys_platform == "win32"' don't match your environment
Ignoring configparser: markers 'python_version < "3.2"' don't match your environment
Ignoring enum34: markers 'python_version < "3.4"' don't match your environment
Ignoring funcsigs: markers 'python_version < "3.0"' don't match your environment
Ignoring stdeb: markers 'sys_platform == "linux"' don't match your environment
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 55/55 — 00:00:42
To activate this project's virtualenv, run the following:
 $ pipenv shell

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
alpercommented, Dec 28, 2018

@nathanielford Side note: Personally I strongly discourage using Homebrew to install Python packages, or install any Python packages against the Homebrew Python using pip (or otherwise). It is just not a good idea.

Please then remove brew install pipenv out of the documentation. I had the same thing where I had to go back to python3.6 and now my homebrew pipenv is broken. If pip install is the preferred way, I’m perfectly happy to do that.

1reaction
nathanielfordcommented, Aug 21, 2018

I’m having a related issue, I think, wherein Homebrew has installed both 3.6.5 and 3.7.0. With the latter active, running pipenv against the former yields an error:

nford@Nathaniels-MacBook-Pro:~/repos/deploy-apps $ pipenv --python /usr/local/Cellar/python/3.6.5/bin/python3.6
Creating a virtualenv for this project...
Pipfile: /Users/nmford/repos/deploy-apps/Pipfile
Using /usr/local/Cellar/python/3.6.5/bin/python3.6 (3.6.5) to create virtualenv...
⠋Running virtualenv with interpreter /usr/local/Cellar/python/3.6.5/bin/python3.6
Using base prefix '/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6'
New python executable in /Users/nmford/.local/share/virtualenvs/deploy-apps-sdEHSK2F/bin/python3.6
Traceback (most recent call last):
  File "/usr/local/Cellar/pipenv/2018.7.1/libexec/lib/python3.7/site-packages/virtualenv.py", line 2343, in <module>
    main()
  File "/usr/local/Cellar/pipenv/2018.7.1/libexec/lib/python3.7/site-packages/virtualenv.py", line 712, in main
    symlink=options.symlink)
  File "/usr/local/Cellar/pipenv/2018.7.1/libexec/lib/python3.7/site-packages/virtualenv.py", line 927, in create_environment
    site_packages=site_packages, clear=clear, symlink=symlink))
  File "/usr/local/Cellar/pipenv/2018.7.1/libexec/lib/python3.7/site-packages/virtualenv.py", line 1233, in install_python
    shutil.copyfile(executable, py_executable)
  File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/shutil.py", line 120, in copyfile
    with open(src, 'rb') as fsrc:
FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/opt/python/bin/python3.6'

Virtualenv location:
Traceback (most recent call last):
  File "/usr/local/Cellar/pipenv/2018.7.1/libexec/bin/pipenv", line 11, in <module>
    load_entry_point('pipenv==2018.7.1', 'console_scripts', 'pipenv')()
  File "/usr/local/Cellar/pipenv/2018.7.1/libexec/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/Cellar/pipenv/2018.7.1/libexec/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/Cellar/pipenv/2018.7.1/libexec/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 1043, in invoke
    return Command.invoke(self, ctx)
  File "/usr/local/Cellar/pipenv/2018.7.1/libexec/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/Cellar/pipenv/2018.7.1/libexec/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/Cellar/pipenv/2018.7.1/libexec/lib/python3.7/site-packages/pipenv/vendor/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/Cellar/pipenv/2018.7.1/libexec/lib/python3.7/site-packages/pipenv/cli.py", line 294, in cli
    three=three, python=python, warn=True, site_packages=site_packages, pypi_mirror=pypi_mirror
  File "/usr/local/Cellar/pipenv/2018.7.1/libexec/lib/python3.7/site-packages/pipenv/core.py", line 614, in ensure_project
    path_to_python = which('python') or which('py')
  File "/usr/local/Cellar/pipenv/2018.7.1/libexec/lib/python3.7/site-packages/pipenv/core.py", line 115, in which
    p = os.path.join(location, 'bin', command)
  File "/usr/local/Cellar/pipenv/2018.7.1/libexec/bin/../lib/python3.7/posixpath.py", line 80, in join
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType

Given the way Homebrew handles this (it unlinks the files in /usr/local/opt/python/bin/) I’m not sure there is a good way around the matter. I tried installing brew install pipenv under python 3.6, but it just used homebrew to install and switch to 7, so trying to keep things manually aligned didn’t work either.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Setting up python environment in macOS using Homebrew ...
After stumbling with this problem, I found a perfect solution using two awesome libraries — Pyenv and Pipenv. Pyenv is to manage Python...
Read more >
Set python version when creating virtualenv using pipenv
Using a Raspberry Pi using Debian 4.14.34-v7+, I am trying to get pipenv set up with Python 3.6.5 as the default version of...
Read more >
Install Python 3.8, Virtual Environments using Pipenv, Django ...
After the installer downloads, open it, and install all the defaults. Verify Installation: Open up Terminal in ( Applications/Utilities/Terminal ) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found