pipenv not compatible with virtualenv and miniconda

Created on 24 Mar 2017  路  5Comments  路  Source: pypa/pipenv

I have both virtualenv and miniconda installed.

When I run pipenv install it generates a Pipefile but returns error:

Creating a Pipfile for this project...
Creating a virtualenv for this project...
鉅婾sing base prefix '/Users/<my_username>/miniconda3'
New python executable in /Users/<my_username>/.virtualenvs/AIND-Pacman-pIsSzxmg/bin/python
dyld: Library not loaded: @rpath/libpython3.6m.dylib
  Referenced from: /Users/<my_username>/.virtualenvs/AIND-Pacman-pIsSzxmg/bin/python
  Reason: image not found
ERROR: The executable /Users/<my_username>/.virtualenvs/AIND-Pacman-pIsSzxmg/bin/python is not functioning
ERROR: It thinks sys.prefix is '/Users/<my_username>/.virtualenvs' (should be '/Users/<my_username>/.virtualenvs/AIND-Pacman-pIsSzxmg')
ERROR: virtualenv is not compatible with this system or executable

Virtualenv location: 
No package provided, installing all dependencies.
Pipfile found at /Users/<my_username>/code/aind-projects/AIND-Pacman/Pipfile. Considering this to be the project home.
Creating a virtualenv for this project...
鉅橴sing base prefix '/Users/<my_username>/miniconda3'
New python executable in /Users/<my_username>/.virtualenvs/AIND-Pacman-pIsSzxmg/bin/python
dyld: Library not loaded: @rpath/libpython3.6m.dylib
  Referenced from: /Users/<my_username>/.virtualenvs/AIND-Pacman-pIsSzxmg/bin/python
  Reason: image not found
ERROR: The executable /Users/<my_username>/.virtualenvs/AIND-Pacman-pIsSzxmg/bin/python is not functioning
ERROR: It thinks sys.prefix is '/Users/<my_username>/.virtualenvs' (should be '/Users/<my_username>/.virtualenvs/AIND-Pacman-pIsSzxmg')
ERROR: virtualenv is not compatible with this system or executable

Virtualenv location: 
Pipfile.lock not found, creating...
Traceback (most recent call last):
  File "/Users/<my_username>/miniconda3/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File "/Users/<my_username>/miniconda3/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/Users/<my_username>/miniconda3/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/Users/<my_username>/miniconda3/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/<my_username>/miniconda3/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/<my_username>/miniconda3/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/Users/<my_username>/miniconda3/lib/python3.6/site-packages/pipenv/cli.py", line 755, in install
    do_init(dev=dev, allow_global=system, ignore_hashes=ignore_hashes)
  File "/Users/<my_username>/miniconda3/lib/python3.6/site-packages/pipenv/cli.py", line 560, in do_init
    do_lock(no_hashes=no_hashes)
  File "/Users/<my_username>/miniconda3/lib/python3.6/site-packages/pipenv/cli.py", line 409, in do_lock
    do_purge(downloads=True, bare=True)
  File "/Users/<my_username>/miniconda3/lib/python3.6/site-packages/pipenv/cli.py", line 506, in do_purge
    shutil.rmtree(project.download_location)
  File "/Users/<my_username>/miniconda3/lib/python3.6/site-packages/pipenv/project.py", line 92, in download_location
    mkdir_p(self._download_location)
  File "/Users/<my_username>/miniconda3/lib/python3.6/site-packages/pipenv/utils.py", line 149, in mkdir_p
    os.mkdir(newdir)
PermissionError: [Errno 13] Permission denied: '/downloads'

And when when I instead run sudo pipenv install it returns:

Creating a Pipfile for this project...
Creating a virtualenv for this project...
鉅婽raceback (most recent call last):
  File "/Users/<my_username>/miniconda3/bin/pew", line 11, in <module>
    sys.exit(pew())
  File "/Users/<my_username>/miniconda3/lib/python3.6/site-packages/pew/pew.py", line 737, in pew
    return command(sys.argv[2:])
  File "/Users/<my_username>/miniconda3/lib/python3.6/site-packages/pew/pew.py", line 253, in new_cmd
    args.requirements, rest)
  File "/Users/<my_username>/miniconda3/lib/python3.6/site-packages/pew/pew.py", line 215, in mkvirtualenv
    check_call(["virtualenv", envname] + rest, cwd=str(workon_home))
  File "/Users/<my_username>/miniconda3/lib/python3.6/subprocess.py", line 286, in check_call
    retcode = call(*popenargs, **kwargs)
  File "/Users/<my_username>/miniconda3/lib/python3.6/subprocess.py", line 267, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/Users/<my_username>/miniconda3/lib/python3.6/subprocess.py", line 707, in __init__
    restore_signals, start_new_session)
  File "/Users/<my_username>/miniconda3/lib/python3.6/subprocess.py", line 1326, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: '/Users/<my_username>/.local/share/virtualenvs'

Virtualenv location: 
No package provided, installing all dependencies.
Pipfile found at /Users/<my_username>/code/aind-projects/AIND-Pacman/Pipfile. Considering this to be the project home.
Creating a virtualenv for this project...
鉅橳raceback (most recent call last):
  File "/Users/<my_username>/miniconda3/bin/pew", line 11, in <module>
    sys.exit(pew())
  File "/Users/<my_username>/miniconda3/lib/python3.6/site-packages/pew/pew.py", line 737, in pew
    return command(sys.argv[2:])
  File "/Users/<my_username>/miniconda3/lib/python3.6/site-packages/pew/pew.py", line 253, in new_cmd
    args.requirements, rest)
  File "/Users/<my_username>/miniconda3/lib/python3.6/site-packages/pew/pew.py", line 215, in mkvirtualenv
    check_call(["virtualenv", envname] + rest, cwd=str(workon_home))
  File "/Users/<my_username>/miniconda3/lib/python3.6/subprocess.py", line 286, in check_call
    retcode = call(*popenargs, **kwargs)
  File "/Users/<my_username>/miniconda3/lib/python3.6/subprocess.py", line 267, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/Users/<my_username>/miniconda3/lib/python3.6/subprocess.py", line 707, in __init__
    restore_signals, start_new_session)
  File "/Users/<my_username>/miniconda3/lib/python3.6/subprocess.py", line 1326, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: '/Users/<my_username>/.local/share/virtualenvs'

Virtualenv location: 
Pipfile.lock not found, creating...
Locking [dev-packages] dependencies...
鉅糒ocking [packages] dependencies...
鉅pdated Pipfile.lock!
Installing dependencies from Pipfile.lock...
An error occured while installing!
/bin/sh: /bin/pip: No such file or directory

You can supply the --ignore-hashes option to 'pipenv install' to bypass this feature.

I am using OSX El Capitan 10.11.5, conda 4.3.11, and I try removing virtualenv from ~/.bash_profile and then running source ~/.bash_profile in terminal:

export WORKON_HOME=$HOME/.virtualenvs
source /Library/Frameworks/Python.framework/Versions/2.7/bin/virtualenvwrapper.sh

However, after doing so, when I run which virtualenv it returns /Users/<my_username>/miniconda3/bin/virtualenv, and when I try uninstalling virtualenv with with conda uninstall virtualenv it returns PackageNotFoundError: Package not found: '' no packages found to remove from environment: /Users/<my_username>/miniconda3

When I delete ~/.virtualenv with rm -rf ~/.virtualenvs it doesn't make any difference and I get the same errors.

Is pipenv a replacement for both virtualenv AND miniconda such that I need to remove both?

Most helpful comment

The main issue here is that virtualenv could not find the libpython3.6.m.dylib that is provided by miniconda and required by the python binary from miniconda.

There's a workaround on Linux with miniconda:

LD_LIBRARY_PATH=$HOME/miniconda3/lib pipenv --three
to allow creation of the virtualenv overriding the library path with miniconda lib path
and then

cp $HOME/miniconda3/lib/libpython3.6m.so.1.0 $(pipenv --venv)/lib
to copy the dynamic library to the virtual env directory so that the python binary can find it in ../lib

you could try
DYLD_LIBRARY_PATH or DYLD_FALLBACK_LIBRARY_PATH on Mac,
it might behave similar to the above.
https://stackoverflow.com/questions/3146274/is-it-ok-to-use-dyld-library-path-on-mac-os-x-and-whats-the-dynamic-library-s

from the look of it, virtualenv does not copy the shared library since the assumption is that the python binary it found is the one available globally in the system.

All 5 comments

Hey @ltfschoen, thanks for taking the time to open this issue. At first glance this definitely seems to be a misconfigured environment rather than an issue with pipenv.

Can you run a few tests for me?

  • What is /usr/bin/python linked to on your system?
  • What is the shebang at the top of /usr/bin/pip?
  • When you run pew workon AIND-Pacman-pIsSzxmg, what happens?
  • Similarly does virtualenv new test_project produce errors?
  • Have you used sudo on pip installs before? That can lead to a lot of funky issues.
  • Lastly, does pipenv run python --version and pipenv run pip --version return anything? If so, what?

Dot point 1 answer:

When I go to usr/bin directory run ls -al, it shows the following links for python:

pydoc2.6 -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/pydoc2.6
pydoc2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/pydoc2.7
python
python-config
python2.6 -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6
python2.6-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6-config
python2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
python2.7-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config
pythonw
pythonw2.6 -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/pythonw2.6
pythonw2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2.7

Also, please note the following:

When I run which python it returns: /Users/<my_username>/miniconda3/bin/python
When I run which python3 it returns: /Users/<my_username>/miniconda3/bin/python3
In my ~/.bash_profile I have set the path for Python 2.7 and 3.6:

export PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"

The following were included in ~/.bash_profile by the Miniconda3 4.3.11 installer:

export PATH="/Users/<my_username>/miniconda3/bin:$PATH"
export PATH="/usr/local/opt/qt5/bin:$PATH"

Dot point 2 answer:

The usr/bin/pip file does not exist.
When I run which pip it returns: /Users/<my_username>/miniconda3/bin/pip, and when I run cat /Users/<my_username>/miniconda3/bin/pip the shebang at the top of the file is #!/Users/<my_username>/miniconda3/bin/python

Dot point 3 answer:

Running pew workon AIND-Pacman-pIsSzxmg returns ERROR: Environment 'AIND-Pacman-pIsSzxmg' does not exist. Create it with 'pew new AIND-Pacman-pIsSzxmg'

And when I do what it suggests and run pew new AIND-Pacman-pIsSzxmg it returns:

Using base prefix '/Users/<my_username>/miniconda3'
New python executable in /Users/<my_username>/.virtualenvs/AIND-Pacman-pIsSzxmg/bin/python
dyld: Library not loaded: @rpath/libpython3.6m.dylib
  Referenced from: /Users/<my_username>/.virtualenvs/AIND-Pacman-pIsSzxmg/bin/python
  Reason: image not found
ERROR: The executable /Users/<my_username>/.virtualenvs/AIND-Pacman-pIsSzxmg/bin/python is not functioning
ERROR: It thinks sys.prefix is '/Users/<my_username>/.virtualenvs' (should be '/Users/<my_username>/.virtualenvs/AIND-Pacman-pIsSzxmg')
ERROR: virtualenv is not compatible with this system or executable

Dot point 4 answer:

When I create a virtualenv based on Python 2.7 it creates it successfully and activates that test_project virtual environment:

$ mkvirtualenv --no-site-packages -v --python=python2.7 test_project
Running virtualenv with interpreter /Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
Creating /Users/<my_username>/.virtualenvs/test_project/lib/python2.7
Symlinking Python bootstrap modules
  Symlinking /Users/<my_username>/.virtualenvs/test_project/lib/python2.7/config
  Symlinking /Users/<my_username>/.virtualenvs/test_project/lib/python2.7/lib-dynload
  Symlinking /Users/<my_username>/.virtualenvs/test_project/lib/python2.7/os.py
  Ignoring built-in bootstrap module: posix
  Symlinking /Users/<my_username>/.virtualenvs/test_project/lib/python2.7/posixpath.py
  Cannot import bootstrap module: nt
  Symlinking /Users/<my_username>/.virtualenvs/test_project/lib/python2.7/ntpath.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project/lib/python2.7/genericpath.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project/lib/python2.7/fnmatch.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project/lib/python2.7/locale.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project/lib/python2.7/encodings
  Symlinking /Users/<my_username>/.virtualenvs/test_project/lib/python2.7/codecs.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project/lib/python2.7/stat.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project/lib/python2.7/UserDict.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project/lib/python2.7/copy_reg.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project/lib/python2.7/types.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project/lib/python2.7/re.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project/lib/python2.7/sre.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project/lib/python2.7/sre_parse.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project/lib/python2.7/sre_constants.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project/lib/python2.7/sre_compile.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project/lib/python2.7/warnings.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project/lib/python2.7/linecache.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project/lib/python2.7/_abcoll.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project/lib/python2.7/abc.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project/lib/python2.7/_weakrefset.py
Creating /Users/<my_username>/.virtualenvs/test_project/lib/python2.7/site-packages
Writing /Users/<my_username>/.virtualenvs/test_project/lib/python2.7/site.py
Writing /Users/<my_username>/.virtualenvs/test_project/lib/python2.7/orig-prefix.txt
Writing /Users/<my_username>/.virtualenvs/test_project/lib/python2.7/no-global-site-packages.txt
Creating parent directories for /Users/<my_username>/.virtualenvs/test_project/include
Symlinking /Users/<my_username>/.virtualenvs/test_project/include/python2.7
Creating /Users/<my_username>/.virtualenvs/test_project/bin
New python executable in /Users/<my_username>/.virtualenvs/test_project/bin/python
Changed mode of /Users/<my_username>/.virtualenvs/test_project/bin/python to 0755
Symlinking /Users/<my_username>/.virtualenvs/test_project/.Python
Testing executable with /Users/<my_username>/.virtualenvs/test_project/bin/python -c "import sys;out=sys.stdout;getattr(out, "buffer", out).write(sys.prefix.encode("utf-8"))"
Got sys.prefix result: u'/Users/<my_username>/.virtualenvs/test_project'
Creating /Users/<my_username>/.virtualenvs/test_project/lib/python2.7/distuti<my_username>
Writing /Users/<my_username>/.virtualenvs/test_project/lib/python2.7/distuti<my_username>/__init__.py
Writing /Users/<my_username>/.virtualenvs/test_project/lib/python2.7/distuti<my_username>/distuti<my_username>.cfg
Installing setuptoo<my_username>, pip, wheel...
  Collecting setuptoo<my_username>
    Using cached setuptoo<my_username>-34.3.2-py2.py3-none-any.whl
  Collecting pip
  Collecting wheel
  Collecting six>=1.6.0 (from setuptoo<my_username>)
    Using cached six-1.10.0-py2.py3-none-any.whl
  Collecting appdirs>=1.4.0 (from setuptoo<my_username>)
    Using cached appdirs-1.4.3-py2.py3-none-any.whl
  Collecting packaging>=16.8 (from setuptoo<my_username>)
    Using cached packaging-16.8-py2.py3-none-any.whl
  Collecting pyparsing (from packaging>=16.8->setuptoo<my_username>)
    Using cached pyparsing-2.2.0-py2.py3-none-any.whl
  Installing collected packages: six, appdirs, pyparsing, packaging, setuptoo<my_username>, pip, wheel
  Successfully installed appdirs-1.4.3 packaging-16.8 pip-9.0.1 pyparsing-2.2.0 setuptoo<my_username>-34.3.2 six-1.10.0 wheel-0.29.0
...Installing setuptoo<my_username>, pip, wheel...done.
Writing /Users/<my_username>/.virtualenvs/test_project/bin/activate
Writing /Users/<my_username>/.virtualenvs/test_project/bin/activate.fish
Writing /Users/<my_username>/.virtualenvs/test_project/bin/activate_this.py
Writing /Users/<my_username>/.virtualenvs/test_project/bin/activate.csh
Writing /Users/<my_username>/.virtualenvs/test_project/bin/python-config
Changed mode of /Users/<my_username>/.virtualenvs/test_project/bin/python-config to 0755
virtualenvwrapper.user_scripts creating /Users/<my_username>/.virtualenvs/test_project/bin/predeactivate
virtualenvwrapper.user_scripts creating /Users/<my_username>/.virtualenvs/test_project/bin/postdeactivate
virtualenvwrapper.user_scripts creating /Users/<my_username>/.virtualenvs/test_project/bin/preactivate
virtualenvwrapper.user_scripts creating /Users/<my_username>/.virtualenvs/test_project/bin/postactivate
virtualenvwrapper.user_scripts creating /Users/<my_username>/.virtualenvs/test_project/bin/get_env_detai<my_username>
Error: deactivate must be sourced. Run 'source deactivate'
instead of 'deactivate'.

But when I try to create a virtualenv based on Python 3 it fails:

$ mkvirtualenv --no-site-packages -v --python=python3 test_project2
Running virtualenv with interpreter /Users/<my_username>/miniconda3/bin/python3
Using base prefix '/Users/<my_username>/miniconda3'
Creating /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6
Symlinking Python bootstrap modules
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/config-3.6m-darwin
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/lib-dynload
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/os.py
  Ignoring built-in bootstrap module: posix
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/posixpath.py
  Cannot import bootstrap module: nt
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/ntpath.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/genericpath.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/fnmatch.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/locale.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/encodings
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/codecs.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/stat.py
  Cannot import bootstrap module: UserDict
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/readline.so
  Cannot import bootstrap module: copy_reg
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/types.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/re.py
  Cannot import bootstrap module: sre
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/sre_parse.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/sre_constants.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/sre_compile.py
  Cannot import bootstrap module: _abcoll
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/warnings.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/linecache.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/abc.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/io.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/_weakrefset.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/copyreg.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/tempfile.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/random.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/__future__.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/collections
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/keyword.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/tarfile.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/shutil.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/struct.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/copy.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/tokenize.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/token.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/functoo<my_username>.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/heapq.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/bisect.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/weakref.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/reprlib.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/base64.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/_dummy_thread.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/hashlib.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/hmac.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/imp.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/importlib
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/rlcompleter.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/operator.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/_collections_abc.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/_bootlocale.py
  Symlinking /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/enum.py
Creating /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/site-packages
Writing /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/site.py
Writing /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/orig-prefix.txt
Writing /Users/<my_username>/.virtualenvs/test_project2/lib/python3.6/no-global-site-packages.txt
Creating parent directories for /Users/<my_username>/.virtualenvs/test_project2/include
Symlinking /Users/<my_username>/.virtualenvs/test_project2/include/python3.6m
Creating /Users/<my_username>/.virtualenvs/test_project2/bin
New python executable in /Users/<my_username>/.virtualenvs/test_project2/bin/python3
Changed mode of /Users/<my_username>/.virtualenvs/test_project2/bin/python3 to 0o755
A<my_username>o creating executable in /Users/<my_username>/.virtualenvs/test_project2/bin/python
Changed mode of /Users/<my_username>/.virtualenvs/test_project2/bin/python to 0o755
Testing executable with /Users/<my_username>/.virtualenvs/test_project2/bin/python3 -c "import sys;out=sys.stdout;getattr(out, "buffer", out).write(sys.prefix.encode("utf-8"))"
dyld: Library not loaded: @rpath/libpython3.6m.dylib
  Referenced from: /Users/<my_username>/.virtualenvs/test_project2/bin/python3
  Reason: image not found
ERROR: The executable /Users/<my_username>/.virtualenvs/test_project2/bin/python3 is not functioning
ERROR: It thinks sys.prefix is '/Users/<my_username>/.virtualenvs' (should be '/Users/<my_username>/.virtualenvs/test_project2')
ERROR: virtualenv is not compatible with this system or executable

Dot point 5 answer:

When I run history to show the contents of /Users/<my_username>/.bash_history, it only shows that I used sudo pipenv install. I can't recall whether I used sudo pip install ___ prior to that. I always try to avoid using sudo, but I can't guarantee that I haven't.

Dot point 6 answer:

The both return similar responses. Running pipenv run python --version returns:

$ pipenv run python --version
Creating a virtualenv for this project...
鉅婾sing base prefix '/Users/<my_username>/miniconda3'
New python executable in /Users/<my_username>/.virtualenvs/AIND-Pacman-pIsSzxmg/bin/python
dyld: Library not loaded: @rpath/libpython3.6m.dylib
  Referenced from: /Users/<my_username>/.virtualenvs/AIND-Pacman-pIsSzxmg/bin/python
  Reason: image not found
ERROR: The executable /Users/<my_username>/.virtualenvs/AIND-Pacman-pIsSzxmg/bin/python is not functioning
ERROR: It thinks sys.prefix is '/Users/<my_username>/.virtualenvs' (should be '/Users/<my_username>/.virtualenvs/AIND-Pacman-pIsSzxmg')
ERROR: virtualenv is not compatible with this system or executable

Virtualenv location: 
The command (/bin/python) was not found within the virtualenv!

Whilst running pipenv run pip --version returns:

$ pipenv run pip --version
Creating a virtualenv for this project...
鉅婾sing base prefix '/Users/<my_username>/miniconda3'
New python executable in /Users/<my_username>/.virtualenvs/AIND-Pacman-pIsSzxmg/bin/python
dyld: Library not loaded: @rpath/libpython3.6m.dylib
  Referenced from: /Users/<my_username>/.virtualenvs/AIND-Pacman-pIsSzxmg/bin/python
  Reason: image not found
ERROR: The executable /Users/<my_username>/.virtualenvs/AIND-Pacman-pIsSzxmg/bin/python is not functioning
ERROR: It thinks sys.prefix is '/Users/<my_username>/.virtualenvs' (should be '/Users/<my_username>/.virtualenvs/AIND-Pacman-pIsSzxmg')
ERROR: virtualenv is not compatible with this system or executable

Virtualenv location: 
The command (/bin/pip) was not found within the virtualenv!

Great, this is all good stuff. So it definitely looks like there's something wrong with your virtualenv setup for python3 in microconda3. The fact that both pew and mkvirtualenv fail with python3 means this is outside of the scope of pipenv. When you don't explicitly create a new project, pipenv install will by default use python3 to create everything. This is why your setup seems to work with the standard python command but not pipenv.

So, my only advice here is to first attempt to see if pip3 or pip3.6 exists on your system. If it does, you can try installing pipenv there and that may possibly fix this issue. Otherwise, you either have a bad install of miniconda3, or there is a linking problem from minoconda3 to python3.6.
This line (dyld: Library not loaded: @rpath/libpython3.6m.dylib) makes me think it's probably the latter, but I can't say for sure.

Since this is out of the purview of pipenv I'm not sure there's much more we can do here. I'm going to close this out for now since it's not a defect in pipenv but please feel free to add any additional notes on things you find if you choose to debug your environment further. Thanks again for checking in on this.

Also, I guess I should note this too. You can probably initialize your environment with pipenv --two before running pipenv install. That may actually get things working with your current configuration, if Python 3.6 isn't a requirement. The best solution will be fixing your install though.

The main issue here is that virtualenv could not find the libpython3.6.m.dylib that is provided by miniconda and required by the python binary from miniconda.

There's a workaround on Linux with miniconda:

LD_LIBRARY_PATH=$HOME/miniconda3/lib pipenv --three
to allow creation of the virtualenv overriding the library path with miniconda lib path
and then

cp $HOME/miniconda3/lib/libpython3.6m.so.1.0 $(pipenv --venv)/lib
to copy the dynamic library to the virtual env directory so that the python binary can find it in ../lib

you could try
DYLD_LIBRARY_PATH or DYLD_FALLBACK_LIBRARY_PATH on Mac,
it might behave similar to the above.
https://stackoverflow.com/questions/3146274/is-it-ok-to-use-dyld-library-path-on-mac-os-x-and-whats-the-dynamic-library-s

from the look of it, virtualenv does not copy the shared library since the assumption is that the python binary it found is the one available globally in the system.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

konstin picture konstin  路  3Comments

erinxocon picture erinxocon  路  3Comments

bgjelstrup picture bgjelstrup  路  3Comments

fbender picture fbender  路  3Comments

jerzyk picture jerzyk  路  3Comments