“python setup.py egg_info”的底层问题是什么?是否存在通用修复?

时间:2017-06-16 17:16:08

标签: python python-3.x ubuntu-16.04

尝试在Ubuntu 16.04 LTS上安装某些Python软件包时出现以下错误。我已经google了一些修复程序,但到目前为止还没有工作,所有这些似乎都非常特定于特定的程序包。有没有一个普遍的解决方案,有人可以向我解释一下潜在的问题是什么吗?

  

命令“python setup.py egg_info”失败,错误代码为1   的/ tmp / PIP-积聚9w8mswlw / tsne /

最近一次是我运行Collecting tsne Using cached tsne-0.1.7.tar.gz Complete output from command python setup.py egg_info: Traceback (most recent call last): File "<string>", line 1, in <module> File "/tmp/pip-build-9w8mswlw/tsne/setup.py", line 18, in <module> from Cython.Distutils import build_ext ImportError: No module named 'Cython' ---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-9w8mswlw/tsne/

输出如下

#include <cstdint>

enum class CommandId : uint16_t {
    Command1 ,
    Command2 ,
};


#include <map>
#include <functional>
#include <string>

//#include "CommandId.h"

class Registry
{
public:
    static std::map<CommandId,std::function<void (std::string)>>& 
    GetCommands() {
        static std::map < CommandId, std::function<void(std::string)>> 
        theFunctionRegistry;
        return theFunctionRegistry;
    }
};

// #include "CommandId.h"
// #include "Registry.h"

// The general command execution interface
struct ICommand {
    virtual void Execute(const std::string& data) = 0;
    virtual ~ICommand() {}
};

template<typename Derived, CommandId CmdId>
class CommandBase : public ICommand
{
public:
    virtual ~CommandBase() {}
    void Register() {}
protected:
    // Dummy function to avoid abstract instantiations, should probably throw
    void Execute(const std::string& data) override {
    }

    // Protected constuctor meant for concrete command classes
    CommandBase(int& derivedRef) : derivedRef_(&derivedRef) {}

    // The static member that should perform the registation automagically
    static CommandBase<Derived, CmdId> registryAdder_;

    // This constructor is meant to be accessed from the above static member
    // instantiation only, and just register the lambda function 
    CommandBase() : derivedRef_(nullptr) {
        // Register a lambda function that ususe a concrete Derived instance
        Registry::GetCommands()[CmdId] = [](const std::string& data) {
            Derived derivedInstance;

            CommandBase<Derived, CmdId>* der = static_cast<CommandBase<Derived, CmdId>*>(&derivedInstance);
            // Manipulate the derived instances data and execute
            *(der->derivedRef_) = 42;
            der->Execute(data);
        };
    }

    // Provides access to the derived class instances data members and allows manipulation 
    int* derivedRef_;
};

template<typename Derived, CommandId CmdId>
CommandBase<Derived, CmdId> CommandBase<Derived, CmdId>::registryAdder_;

// #include "CommandBase.h"

class Command1 : public CommandBase<Command1, CommandId::Command1>
{
public:
    typedef CommandBase<Command1, CommandId::Command1> BaseClass;
    friend class CommandBase<Command1, CommandId::Command1>;

public:
    Command1(CommandId) {
        BaseClass::registryAdder_.Register();
    }
    virtual ~Command1() override {}

private:
    Command1() : BaseClass(member_)
    {
        BaseClass::registryAdder_.Register();
    }

    void Execute(const std::string& data) override {

    }
private:
    int member_;
};

// #include "CommandBase.h"

class Command2 : public CommandBase<Command2, CommandId::Command2>
{
public:
    typedef CommandBase<Command2, CommandId::Command2> BaseClass;
    friend class CommandBase<Command2, CommandId::Command2>;

public:
    Command2(CommandId) {
        BaseClass::registryAdder_.Register();
    }
    virtual ~Command2() override {}

private:
    Command2() : BaseClass(member_)
    {
        BaseClass::registryAdder_.Register();
    }

    void Execute(const std::string& data) override {

    }
private:
    int member_;
};

#include <iostream>
//#include "Command1.h"
//#include "Command2.h"
//#include "Registry.h"

int main()
{
    std::cout << "There are " << Registry::GetCommands().size() << " registered commands." << std::endl;
    return 0;
}

1 个答案:

答案 0 :(得分:2)

您需要安装Cython language compiler。这列在project page

  

一个用于Barnes-Hut-SNE又名快速通道的python(cython)包装器。

  

要求

     
      
  • numpy&gt; = 1.7.1
  •   
  • scipy&gt; = 0.12.0
  •   
  • cython&gt; = 0.19.1
  •   
  • cblas或openblas。测试版本为v0.2.5和v0.2.6(OSX不需要)。
  •   

您可以使用

安装Cython
pip install Cython

虽然tsne项目确实list Cython as a setuptools requirement,但遗憾的是它们没有将其列为设置要求,并假设它已经预先安装好。

我提交了bug report with that project;在未来的项目中setup_requires with Cython?,以便pip install project_depending_on_cython在安装时自动拉入Cython。