Python 和康达在一起?

Python 和康达在一起?,python,anaconda,git-bash,pipenv,Python,Anaconda,Git Bash,Pipenv,我在win 10中使用Anaconda作为我的虚拟人。我正在使用git bash。最近我一直在阅读关于pipenv的文章,并决定尝试一下。我在我的基础conda python上安装了pipenv,它是python 2.7的一个版本,使用: pip install pipenv 我可以使用 conda create --name py3 python=3.6 但我试过: $ pipenv install --three 其中给出: Warning: Python 3 was not foun

我在win 10中使用Anaconda作为我的虚拟人。我正在使用git bash。最近我一直在阅读关于pipenv的文章,并决定尝试一下。我在我的基础conda python上安装了pipenv,它是python 2.7的一个版本,使用:

pip install pipenv
我可以使用

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)
警告:在您的系统上找不到Python 3…
可以使用以下命令指定Python的特定版本:
$pipenv—python路径\到\ python
....\miniconda2\lib\site packages\pipenv\\u compat.py:86:ResourceWarning:隐式清理
警告。警告(警告消息,资源警告)

可以同时使用这两个软件包吗?

您可以在用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)…
  You can setup Pipenv to use Conda's Python executable and site packages directory (ref).

pipenv --python=$(conda run which python) --site-packages
$conda create-n pipenv test python=3
$source激活pipenv测试
(pipenv测试)$pipenv安装--python=/home/../miniconda3/envs/pipenv测试/bin/python
正在为此项目创建virtualenv…
使用/home/../miniconda3/envs/pipenv test/bin/python(3.6.5)创建virtualenv…
⠋已经在使用解释器/home/../miniconda3/envs/pipenv test/bin/python
使用基本前缀“/home/../miniconda3/envs/pipenv test”
/home/...local/share/virtualenvs/wispy-j1ojliDY/bin/python中的新python可执行文件
安装setuptools、pip、wheel…完成。
虚拟环境位置:/home/...local/share/virtualenvs/wispy-j1ojliDY
正在为此项目创建PIP文件…
找不到Pipfile.lock,正在创建…
正在锁定[开发包]依赖项…
正在锁定[程序包]依赖项…
更新了Pipfile.lock(ca72e7)!
正在从Pipfile.lock(ca72e7)安装依赖项…

您可以将Pipenv设置为使用Conda的Python可执行文件和站点包目录()

pipenv--python=$(conda运行哪个python)--站点包
您可以检查是否确实在Pipenv中使用Conda环境:

pipenv run python
>>> import sys
>>> sys.executable, sys.path
# <directories under your Conda environment>
pipenv运行python
>>>导入系统
>>>sys.executable,sys.path
# 
通过Conda安装了NumPy,但没有安装Pipenv,您可以看到Pipenv仍然可以找到NumPy

conda install numpy
pipenv run python
>>> import numpy as np
>>> np.__file__
# <path under your Conda environment>
conda安装numpy
pipenv运行python
>>>将numpy作为np导入
>>>np.\u文件__
# 
当您通过Pipenv安装NumPy时,它将隐藏Conda安装的包

pipenv install numpy
pipenv run python
>>> import numpy as np
>>> np.__file__
# <path under your Pipenv environment>
pipenv安装numpy
pipenv运行python
>>>将numpy作为np导入
>>>np.\u文件__
# 

你需要在你的路径上有
python3
或者显式地声明它。好的,我也读过,但是我的蟒蛇在基本路径中有一个python27,而不是python3。有没有办法在那里添加Python 3?我正在git bash中尝试您的命令。在pipenv测试conda env中,是否需要在“$pipenv install..miniconda\envs\pipenv test”之前运行pip install pipenv我做了“conda install pip”,但结果表明它是默认安装的。你可以用“康达列表”检查它是否在那里。但这可能是linux和Windows anaconda git bash之间的区别。您的步骤如何显示“您可以在用Python 3初始化的conda环境中安装pipenv”?这似乎意味着在环境中运行类似于
pip install pipenv
的东西,但是您的说明假设激活后pipenv已经可用。很抱歉回复太慢@rob3c你是对的,我忘了在我的原始答案中包括这一点。事实上,我确实首先在conda环境中安装了pipnv。