Python 如何在conda环境中用克隆的GitHub版本替换libprotobuf的conda包

Python 如何在conda环境中用克隆的GitHub版本替换libprotobuf的conda包,python,anaconda,conda,protobuf-c,Python,Anaconda,Conda,Protobuf C,我正在尝试在conda环境中安装caffeCaffe需要谷歌的protobuf软件包。我已经git clone'dprotobuf,并将其放在我的\usr目录中。但是,当我尝试在conda环境中安装caffe时,安装的libprotobuf版本无法将proto文件正确转换为c++代码 考虑以下代码: syntax = "proto2"; package test1; message Datum { optional int32 channels = 1; } 当我尝试从我的基本环境中

我正在尝试在
conda
环境中安装
caffe
Caffe
需要谷歌的
protobuf
软件包。我已经
git clone
'd
protobuf
,并将其放在我的
\usr
目录中。但是,当我尝试在conda环境中安装caffe时,安装的
libprotobuf
版本无法将
proto
文件正确转换为
c++
代码

考虑以下代码:

syntax = "proto2";

package test1;


message Datum {
  optional int32 channels = 1;
}
当我尝试从我的
基本环境中翻译它时,一切都很好:

(base) me@balin:~/Projects/caffe$ make clean
(base) me@balin:~/Projects/caffe$ make superclean
Deleting the following generated files:
./temp5.pb.cc
./temp5.pb.h
(base) me@balin:~/Projects/caffe$ protoc --cpp_out=. temp5.proto
(base) me@balin:~/Projects/caffe$ g++ temp5.pb.cc -c
(base) me@balin:~/Projects/caffe$ 
然而,当我在我想要用于
caffe
的环境中尝试相同的事情时,我得到了以下结果:

(dnn_track5) me@balin:~/Projects/caffe$ make clean
(dnn_track5) me@balin:~/Projects/caffe$ make superclean
Deleting the following generated files:
./temp5.pb.cc
(dnn_track5) me@balin:~/Projects/caffe$ protoc --cpp_out=. temp5.proto
(dnn_track5) me@balin:~/Projects/caffe$ g++ temp5.pb.cc -c
temp5.pb.cc: In member function ‘virtual const char* test1::Datum::_InternalParse(const char*, google::protobuf::internal::ParseContext*)’:
temp5.pb.cc:150:58: error: ‘ReadVarint’ is not a member of ‘google::protobuf::internal’
           channels_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr);
                                                          ^~~~~~~~~~
temp5.pb.cc:150:58: note: suggested alternative: ‘ReadVarint32’
           channels_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr);
                                                          ^~~~~~~~~~
                                                          ReadVarint32
我所能做的就是将
conda
安装的
~\anaconda2\envs\dnn\u track5
子目录中的每个文件替换为我从
GitHub
克隆构建
protobuf
时安装的文件。我说得对吗(我怀疑)


如何创建一个conda环境,在这个环境中我可以使用
caffe
,并且仍然有一个工作的
protobuf

没有直接的方法使用conda直接从github repo安装,所以值得一看为什么您的代码不能在
caffe
环境中工作

自2019年10月起,以下各项之间存在区别:

::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64

当您
conda安装caffe
时,它会下载(至少对我来说)
libprotobuf-3.11.2
,这是2019年12月以来的最新版本,因此作为
caffe
的依赖项下载的版本实际上比您试图在代码中使用的版本要新

您现在有几个选项:

  • 请求具有要使用的API的protobuf的特定版本。即3.10.0,自2019年10月3日起:

    conda create-n caffe-c conda forge python=3.7 caffe libprotobuf=3.10.0

  • 创建一个自定义conda频道,并在其中放入您自己的
    libprotobuf.tar.bz2

  • 调整代码以使用最新的
    libprotobuf
    API

  • 没有直接的方法可以使用conda直接从github repo安装,因此有必要了解一下为什么您的代码不能在
    caffe
    env中工作

    自2019年10月起,以下各项之间存在区别:

    ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64
    

    当您
    conda安装caffe
    时,它会下载(至少对我来说)
    libprotobuf-3.11.2
    ,这是2019年12月以来的最新版本,因此作为
    caffe
    的依赖项下载的版本实际上比您试图在代码中使用的版本要新

    您现在有几个选项:

  • 请求具有要使用的API的protobuf的特定版本。即3.10.0,自2019年10月3日起:

    conda create-n caffe-c conda forge python=3.7 caffe libprotobuf=3.10.0

  • 创建一个自定义conda频道,并在其中放入您自己的
    libprotobuf.tar.bz2

  • 调整代码以使用最新的
    libprotobuf
    API

  • 您从github克隆的版本有多大?安装的是哪个版本。我不建议弄乱conda手动安装的文件您从github克隆的版本有多旧,以及安装的是哪个版本。我不建议弄乱康达手动安装的文件