在" pip安装加密"期间缺少pyconfig.h

时间:2016-10-14 08:09:52

标签: python cryptography centos scrapy pip

我想设置scrapy集群,请点击此链接scrapy-cluster,在运行此命令之前一切正常:

GUID *guidScheme;
bool bResult = false;
byte enableFunction= 0x1; //Set 0x0 to disable
bResult = PowerGetActiveScheme(NULL, &guidScheme);
if (bResult != ERROR_SUCCESS){
    //error message
}

GUID guidSubVideo = { 0x7516b95f, 0xf776, 0x4464, 0x8c, 0x53, 0x06, 0x16, 0x7f, 0x40, 0xcc, 0x99 };
GUID guidAdaptBright = { 0xfbd9aa66, 0x9553, 0x4097, 0xba, 0x44, 0xed, 0x6e, 0x9d, 0x65, 0xea, 0xb8 };

bResult = PowerWriteDCValueIndex(NULL, guidScheme, &guidSubVideo, &guidAdaptBright, enableFunction);
if (bResult != ERROR_SUCCESS){
    //error message
}

requirements.txt看起来像:

pip install -r requirements.txt

我猜上面的命令意味着在requirements.txt中安装软件包。但是我不想让它指定版本,所以我把它更改为:

cffi==1.2.1
characteristic==14.3.0
ConcurrentLogHandler>=0.9.1
cryptography==0.9.1
...

安装加密时,它会给我错误:

cat requirements.txt | while read line; do pip install ${line%%[>=]*} --user;done

我不知道如何解决这个问题,我尝试了很多方法,但都失败了。我的系统是centos 7,python的版本是2.7.5(默认)。 此外,是否有任何其他scrapy框架适用于大量的网址。提前致谢

5 个答案:

答案 0 :(得分:32)

对于Ubuntu,python2

apt-get install python-dev 

对于Ubuntu,python3

apt-get install python3-dev

答案 1 :(得分:16)

我自己解决了这个问题。对于centos的默认python,在usr / include / python2.7 /中只有一个名为pyconfg-64.h的文件,所以运行命令

yum install python-devel

然后它有效。

答案 2 :(得分:6)

for python3.6,

apt-get install python3.6-dev

apt-get install libssl-dev libffi-dev

答案 3 :(得分:0)

我在ubuntu上使用python 2并在安装加密时遇到了同样的问题。 我运行此命令后

apt-get install python-dev libssl-dev libffi-dev

然后它有效。

答案 4 :(得分:0)

对于Debian上的Python 3.7,以下对我有用。

 private static void ReceiveCallBack(IAsyncResult AR)
        {
            Thread.Sleep(1000);
            Socket socket = null;
            string hostname = "";
            string ip_address = "";

            CopyChimpDB copychimp_db = new CopyChimpDB();
            try
            {
                socket = (Socket)AR.AsyncState;
                int received = socket.EndReceive(AR);

                ip_address = (socket.RemoteEndPoint as IPEndPoint).ToString().Split(':')[0];
                hostname = dict_host[ip_address];

                byte[] dataBuff = new byte[received];
                Array.Copy(_buffer, dataBuff, received);

                string message_to_client = "wait";

                if (Convert.ToDouble(Math.Round((DateTime.Now - Convert.ToDateTime(dict_cmd_lastsent[hostname])).TotalMinutes, 2)) >= dict_cmd_interval[hostname])
                {
                    var server_command = ServerCommand(hostname);

                    if (server_command.Trim() != "")
                    {
                        //string message_from_client = WebUtility.HtmlDecode(Encoding.ASCII.GetString(dataBuff));
                        message_to_client += "<DriveName>" + dict_drive[hostname] + "</DriveName>";
                        message_to_client += "<ServerCommand>" + ServerCommand(hostname) + "</ServerCommand>";

                        try
                        {
                            copychimp_db.PostCopyChimp("ConnectMachine", hostname, ip_address);
                        }
                        catch (Exception oraex)
                        {
                            ServerLogs(hostname + "--" + oraex.ToString());
                        }
                        dict_cmd_lastsent[hostname] = DateTime.Now;
                        //ServerLogs(hostname + " updated");
                    }


                }

                byte[] data = Encoding.ASCII.GetBytes(message_to_client);
                socket.BeginSend(data, 0, data.Length, SocketFlags.None, new AsyncCallback(SendCallback), socket);
                socket.BeginReceive(_buffer, 0, _buffer.Length, SocketFlags.None, new AsyncCallback(ReceiveCallBack), socket);
            }
            catch (SocketException ex)
            {
                try
                {
                    //_clientSockets.Remove(socket);
                    ServerLogs(hostname + " SocketException! " + ex.Message.ToString());
                    if (hostname != "")
                    {
                        try
                        {
                            copychimp_db.PostCopyChimp("DisconnectMachine", hostname, ip_address);
                        }
                        catch (Exception oraex)
                        {
                            ServerLogs(hostname + "--" + oraex.ToString());
                        }
                    }
                }
                catch (Exception ex_)
                {
                    ServerLogs(hostname + " DisconnectMachine error! " + ex_.ToString());
                }

            }
        }


   private static void AcceptCallback(IAsyncResult AR)
        {
            string hostname = "";
            try
            {
                CopyChimpDB copychimp_db = new CopyChimpDB();
                Socket socket = _serverSocket.EndAccept(AR);
                string ip_address = "";

                //hostname checking
                ip_address = (socket.RemoteEndPoint as IPEndPoint).ToString().Split(':')[0];
                try
                {
                    try
                    {
                        hostname = Dns.GetHostEntry(ip_address).HostName;
                    }
                    catch (Exception host_ex)
                    {
                        ServerLogs(ip_address + " GetHostEntry error: " + host_ex.Message.ToString());
                        DataTable dt_ip = copychimp_db.GetCopyChimp("GetHostnameByIpAddress", hostname, ip_address);
                        if (dt_ip.Rows.Count == 1)
                        {
                            hostname = dt_ip.Rows[0]["hostname"].ToString();
                            ServerLogs(ip_address + " GetHostnameByIpAddress : " + hostname);

                        }
                    }
                    DataTable dt_hostname = copychimp_db.GetCopyChimp("GetHostname", hostname, ip_address);
                    hostname = "";
                    if (dt_hostname.Rows.Count == 1)
                    {
                        hostname = dt_hostname.Rows[0]["hostname"].ToString();
                    }
                    else if (dt_hostname.Rows.Count > 1)
                    {
                        ServerLogs(hostname + " GetHostname error: Returns more than 1 row.");
                    }

                    if (hostname != "")
                    {

                        if (!_clientSockets.Contains(socket))
                        {
                            dict_host[ip_address] = hostname;
                            _clientSockets.Add(socket);

                            copychimp_db.PostCopyChimp("ConnectMachine", hostname, ip_address);
                            /*------------------------------------------------------------------------------------------------*/
                            dict_cmd_interval[hostname] = Convert.ToDouble(copychimp_db.GetCopyChimp("GetInterval", hostname, ip_address).Rows[0]["interval"].ToString());
                            /*------------------------------------------------------------------------------------------------*/
                            dict_cmd_lastsent[hostname] = Convert.ToDateTime(copychimp_db.GetCopyChimp("GetLastUpdate", hostname, ip_address).Rows[0]["lastupdate"]);
                            /*------------------------------------------------------------------------------------------------*/
                            dict_drive[hostname] = copychimp_db.GetCopyChimp("GetDriveName", hostname, ip_address).Rows[0]["drive_name"].ToString();
                            /*------------------------------------------------------------------------------------------------*/
                            thread = new Thread(() =>
                            {
                                socket.BeginReceive(_buffer, 0, _buffer.Length, SocketFlags.None, new AsyncCallback(ReceiveCallBack), socket);
                            });
                            thread.Start();

                            ServerLogs(hostname + " connected");
                        }
                    }
                }
                catch (Exception oraex)
                {
                    ServerLogs(hostname + "--" + oraex.ToString());
                }
                _serverSocket.BeginAccept(new AsyncCallback(AcceptCallback), null);
            }
            catch (SocketException ex)
            {
                ServerLogs("AcceptCallback SocketException " + hostname + ex.Message.ToString());
            }
        }

apt-get install python3.7-dev

您可能还需要:

apt-get install libssl-dev