Pipenv with Conda?

后端 未结 2 880
既然无缘
既然无缘 2020-12-14 02:17

I\'m using Anaconda for my virtualenvs in win 10. I\'m using git-bash .I\'ve been reading about pipenv recently and decided to give it a try. I installed pipenv on my base c

相关标签:
2条回答
  • 2020-12-14 02:46

    You can setup Pipenv to use Conda's Python executable and site packages directory (ref).

    pipenv --python=$(conda run which python) --site-packages
    

    You can check if you are indeed using your Conda environment in Pipenv:

    pipenv run python
    >>> import sys
    >>> sys.executable, sys.path
    # <directories under your Conda environment>
    

    With NumPy installed through Conda, but not Pipenv, you can see that Pipenv will still find NumPy.

    conda install numpy
    pipenv run python
    >>> import numpy as np
    >>> np.__file__
    # <path under your Conda environment>
    

    When you install NumPy through Pipenv, it will shadow Conda's installation of the the package.

    pipenv install numpy
    pipenv run python
    >>> import numpy as np
    >>> np.__file__
    # <path under your Pipenv environment>
    
    0 讨论(0)
  • 2020-12-14 03:02

    You can install pipenv within a conda environment initialized with python 3.

    $ conda create -n pipenv-test python=3
    $ source activate pipenv-test
    (pipenv-test)$ pipenv install --python=/home/.../miniconda3/envs/pipenv-test/bin/python
    Creating a virtualenv for this project…
    Using /home/.../miniconda3/envs/pipenv-test/bin/python (3.6.5) to create virtualenv…
    ⠋Already using interpreter /home/.../miniconda3/envs/pipenv-test/bin/python
    Using base prefix '/home/.../miniconda3/envs/pipenv-test'
    New python executable in /home/.../.local/share/virtualenvs/wispy-j1ojliDY/bin/python
    Installing setuptools, pip, wheel...done.
    
    Virtualenv location: /home/.../.local/share/virtualenvs/wispy-j1ojliDY
    Creating a Pipfile for this project…
    Pipfile.lock not found, creating…
    Locking [dev-packages] dependencies…
    Locking [packages] dependencies…
    Updated Pipfile.lock (ca72e7)!
    Installing dependencies from Pipfile.lock (ca72e7)…
                                                                          
    0 讨论(0)
提交回复
热议问题