web-dev-qa-db-ja.com

コンダとPipenv?

私はwin 10でvirtualenvsにAnacondaを使用しています。git-bashを使用しています。最近pipenvについて読んでいて、試してみることにしました。私はベースcondaにpipenvをインストールしましたpythonこれはpython 2.7のバージョンです:

pip install pipenv

python環境を簡単に作成できます

conda create --name py3 python=3.6

しかし、私は試しました:

$ pipenv install --three

与えた:

Warning: Python 3 was not found on your system…
You can specify specific versions of Python with:
  $ pipenv --python path\to\python
....\miniconda2\lib\site-packages\pipenv\_compat.py:86: ResourceWarning: Implicitly cleaning up <TemporaryDirectory 'c:\\users\\......\\appdata\\local\\temp\\pipenv-4_fzvq-requi
rements'>
  warnings.warn(warn_message, ResourceWarning)

2つのパッケージを一緒に使用することはできますか?

11
user61629

python 3.で初期化されたconda環境内にpipenvをインストールできます。

$ 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 — 00:00:00
To activate this project's virtualenv, run the following:
 $ pipenv Shell

これは私にはうまくいくようですが、私はそれを広範囲にテストしていません。また、私の基本conda pythonは3.6で、Ubuntu 16.04を使用しています。これでも問題が発生するかどうか聞きたいです。

9
kde8

CondaのPython実行可能ファイルおよびサイトパッケージディレクトリ(- ref )を使用するようにPipenvをセットアップできます。

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

PipenvでConda環境を実際に使用しているかどうかを確認できます。

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

NumPyはCondaを通じてインストールされますが、Pipenvではインストールされないため、PipenvがNumPyを検出していることがわかります。

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

Pipenvを介してNumPyをインストールすると、Condaによるパッケージのインストールがシャドウされます。

pipenv install numpy
pipenv run python
>>> import numpy as np
>>> np.__file__
# <path under your Pipenv environment>
2
anishpatel