会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 133532个问题

'''
    坦克大战

新增功能:
    1.实惠坦克之前的碰撞检测
        我方坦克主动碰撞敌方坦克
            我方坦克停下stay()
        敌方坦克主动碰撞我方坦克
            敌方坦克停下stay()

'''
# 导入pygame模块
import pygame
import time
import random
SCREEN_WIDTH=800
SCREEN_HEIGHT=600
BG_COLOR=pygame.Color(0,0,0)
TEXT_COLOR=pygame.Color(255,0,0)


class MainGame():
    window=None
    my_tank=None
    # 存储敌方坦克列表
    enemyTanklist=[]
    # 定义敌方坦克生成的数量
    enemyTankCount=5
    # 存储我立子弹列表
    Bullet_list=[]
    # 存储敌方子弹列表
    enemybullet_list=[]
    # 爆炸效果列表
    Explode_list=[]
    # 墙壁列表
    wall_list=[]
    # 初始化方法
    def __init__(self):
        pass

    # 开始游戏
    def startGame(self):
        # 加载主窗口
        # 初始化窗口
        pygame.display.init()
        # 设置窗口大小及显示
        MainGame.window = pygame.display.set_mode([SCREEN_WIDTH, SCREEN_HEIGHT])
        self.createMyTank()
        # 初始化我方坦克
        MainGame.my_tank=MyTank(350,350)
        # 初始化敌方坦克,并将敌方坦克添加到列表中
        self.createEnemyTank()
        # 创建墙壁
        self.createWall()
        # 设置窗口标题
        pygame.display.set_caption("坦克大战")
        while True:
            # 使坦克移动速度降慢
            # time单位为秒
            time.sleep(0.02)
            # 设置窗口填充色
            MainGame.window.fill(BG_COLOR)
            # 获取事件
            self.getEvent()
            # 绘制文字
            MainGame.window.blit(self.getTextSurface("敌方坦克剩余数量%d"%len(MainGame.enemyTanklist)),(10,10))
            # 调用展示墙壁的方法
            self.blitwall()
            if MainGame.my_tank and MainGame.my_tank.live:
                # 调用坦克显示方法
                MainGame.my_tank.displayTank()
            else:
                del MainGame.my_tank
                MainGame.my_tank=None
            # 循环遍历敌方坦克列表,展示敌方坦克
            self.blitEnemyTank()
            # 调用移动方法
            # 如果坦克移动开关开启才能移动
            if MainGame.my_tank and MainGame.my_tank.live:
                if not MainGame.my_tank.stop:
                    MainGame.my_tank.move()
                    # 调用碰撞墙壁方法
                    MainGame.my_tank.TankHitWall()
                    # 调用我方坦克碰到敌方坦克方法
                    MainGame.my_tank.hitEnemyTank()
            # 调用我方子弹列表的方法
            self.blitBullet()
            # 调用敌方子弹列表的方法
            self.blitenemybullet()
            # 展示爆炸效果
            self.displayExplodes()
            pygame.display.update()

    # 创建我方坦克方法
    def createMyTank(self):
        MainGame.my_tank = MyTank(350, 350)

    # 初始化方坦克,并将敌方坦克添加到列表中
    def createEnemyTank(self):
        top=100
        # 循环生成敌方坦克
        for i in range(MainGame.enemyTankCount):
            left = random.randint(0,600)
            speed = random.randint(1,4)
            enemy=EnemyTank(left,top,speed)
            MainGame.enemyTanklist.append(enemy)

    # 创建墙壁方法
    def createWall(self):
        for i in range(0,5):
            wall = Wall(150*i, 230)
            MainGame.wall_list.append(wall)

    def blitwall(self):
        for wall in MainGame.wall_list:
            if wall.live:
                wall.displayWall()
            else:
                MainGame.wall_list.remove(wall)

    # 循环遍历敌方坦克列表,展示敌方坦克
    def blitEnemyTank(self):
        for enemyTank in MainGame.enemyTanklist:
            if enemyTank.live:
                enemyTank.displayTank()
                #enemyTank.move()
                enemyTank.randMove()
                # 调用敌方坦克与墙壁的碰撞方法
                enemyTank.TankHitWall()
                # 调用敌方坦克碰撞我方坦克方法
                enemyTank.ehitMyTank()
                # 调用敌方坦克的射击
                enemybullet = enemyTank.shot()
                # 如果子弹为NONE,不加入到列表
                if enemybullet:
                    # 将子弹存储到敌方子弹列表中
                    MainGame.enemybullet_list.append(enemybullet)
            else:
                MainGame.enemyTanklist.remove(enemyTank)

    # 将我方子弹加载到窗口中
    def blitBullet(self):
        for bullet in MainGame.Bullet_list:
            # 如果子弹还在,绘制出来,否则直接从列表中移除
            if bullet.live:
                bullet.displayBullet()
                bullet.bulletmove()
                # 调用我方子弹与敌方坦克的碰撞方法
                bullet.hitEnemyTank()
                # 调用判断我方子弹是否碰撞墙壁
                bullet.hitWall()
            else:
                # 让子弹移动
                MainGame.Bullet_list.remove(bullet)

    # 将敌方子弹加入到窗口中
    def blitenemybullet(self):
        for enemybullet in MainGame.enemybullet_list:
            # 如果子弹还在,绘制出来,否则直接从列表中移除
            if enemybullet.live:
                enemybullet.displayBullet()
                enemybullet.bulletmove()
                # 调用敌方子弹是否碰撞墙壁
                enemybullet.hitWall()
                if MainGame.my_tank and MainGame.my_tank.live:
                    enemybullet.hitMyTank()
            else:
                # 让子弹移动
                MainGame.enemybullet_list.remove(enemybullet)

    # 展示爆炸效果列表
    def displayExplodes(self):
        for explode in MainGame.Explode_list:
            if explode.live:
                explode.displayExplode()
            else:
                # 在爆炸列表中移除
                MainGame.Explode_list.remove(explode)

    # 结束游戏
    def endGame(self):
        print("谢谢")
        exit()

    # 左上角文字绘制
    def getTextSurface(self,text):
        # 查看所有字体名称
        #print(pygame.font.get_fonts())
        # 初始化字体模块
        pygame.font.init()
        # 获取字体Font对象
        font = pygame.font.SysFont("kaiti", 18)
        # 绘制文字信息
        textSurface = font.render(text, True, TEXT_COLOR)
        return textSurface

    # 获取事件
    def getEvent(self):
        eventList = pygame.event.get()
        # 遍历事件
        for event in eventList:
            # 判断按下的键是关闭还是键盘按下
            # 判断是否关闭窗口
            if event.type == pygame.QUIT:
                self.endGame()
            # 判断键盘输入
            if event.type == pygame.KEYDOWN:
                if not (MainGame.my_tank and MainGame.my_tank.live):
                    # 点击ESC按键,重生
                    #esc按键27或pygame.K_ESCAPE
                    if event.key == 27:
                        self.createMyTank()
                #print(event.key)
                if MainGame.my_tank and MainGame.my_tank.live:
                    # 判断键盘上下左右键
                    if event.key == pygame.K_LEFT:
                        # 切换方向
                        MainGame.my_tank.direction="L"
                        # 修改坦克的移动开关
                        MainGame.my_tank.stop=False
                        # MainGame.my_tank.move()
                        print("坦克向左")
                    elif event.key == pygame.K_RIGHT:
                        MainGame.my_tank.direction = "R"
                        MainGame.my_tank.stop = False
                        # MainGame.my_tank.move()
                        print("坦克向右")
                    elif event.key == pygame.K_UP:
                        MainGame.my_tank.direction = "U"
                        MainGame.my_tank.stop = False
                        # MainGame.my_tank.move()
                        print("坦克向上")
                    elif event.key == pygame.K_DOWN:
                        MainGame.my_tank.direction = "D"
                        MainGame.my_tank.stop = False
                        # MainGame.my_tank.move()
                        print("坦克向下")
                    elif event.key ==pygame.K_SPACE:
                        print("发射子弹")
                        if len(MainGame.Bullet_list) < 3:
                            # 产生一颗子弹
                            m = Bullet(MainGame.my_tank)
                            # 将子弹加入子弹列表
                            MainGame.Bullet_list.append(m)
                        else:
                            print("子弹数量不足")
                        print("当前屏幕中数量为:%d" %len(MainGame.Bullet_list))
                # 松开方向键停止移动,修改坦克移动开关状态
            if event.type==pygame.KEYUP:
                # 判断松开的键是方向键才停止移动
                if event.key ==pygame.K_UP or event.key==pygame.K_LEFT or event.key==pygame.K_DOWN or event.key==pygame.K_RIGHT:
                    if MainGame.my_tank and MainGame.my_tank.live:
                        MainGame.my_tank.stop=True

class BaseItem(pygame.sprite.Sprite):
    def __init__(self):
        pygame.sprite.Sprite.__init__(self)


class Tank(BaseItem):
    # 初始化方法
    # 距离左边left, 距离上边left
    def __init__(self, left, top):
        # 保存加载图片
        self.images={
            "U":pygame.image.load("img/p1tankU.gif"),
            "D":pygame.image.load("img/p1tankD.gif"),
            "L":pygame.image.load("img/p1tankL.gif"),
            "R":pygame.image.load("img/p1tankR.gif"),
        }
        # 方向
        self.direction = "U"
        # 根据当前图片的方向获取图片 返回surface
        self.image=self.images[self.direction]
        # 根据图片获取区域
        self.rect=self.image.get_rect()
        # 设置区域left和top
        self.rect.left=left
        self.rect.top=top
        # 速度  决定移动快慢
        self.speed=5
        # 坦克移动开关
        self.stop=True
        # 记录坦克是否存活
        self.live=True
        # 记录坦克移动之前的坐标(用于坐标还原时使用)
        self.oldLeft = self.rect.left
        self.oldTop = self.rect.top

    # 移动
    def move(self):
        # 先记录移动之前的坐标
        self.oldLeft = self.rect.left
        self.oldTop = self.rect.top
        # 判断坦克方向进行移动
        if self.direction == "L":
            if self.rect.left > 0:
                self.rect.left -= self.speed
        elif self.direction == "U":
            if self.rect.top>0:
                self.rect.top -= self.speed
        elif self.direction == "D":
            if self.rect.top+self.rect.height < SCREEN_HEIGHT:
                self.rect.top += self.speed
        elif self.direction == "R":
            if self.rect.left+self.rect.height < SCREEN_WIDTH:
                self.rect.left += self.speed

    def stay(self):
        self.rect.left = self.oldLeft
        self.rect.top = self.oldTop

    # 碰撞墙壁的方法
    def TankHitWall(self):
        for wall in MainGame.wall_list:
            if pygame.sprite.collide_rect(wall,self):
                self.stay()

    # 射击
    def shot(self):
        return Bullet(self)

    # 展示坦克
    def displayTank(self):
        # 获取展示的对象
        self.image = self.images[self.direction]
        # 调用blit方法展示
        MainGame.window.blit(self.image, self.rect)

# 我方坦克(继承自坦克类)
class MyTank(Tank):
    # 初始化方法
    def __init__(self, left, top):
        super(MyTank, self).__init__(left, top)

        # 我方坦克主动碰撞敌方坦克
    def hitEnemyTank(self):
        for enemytank in MainGame.enemyTanklist:
            if pygame.sprite.collide_rect(enemytank, self):
                self.stay()


# 敌方坦克(继承自坦克类)
class EnemyTank(Tank):
    # 初始化方法
    def __init__(self,left,top,speed):
        # 对父类初始化方法的调用
        super(EnemyTank, self).__init__(left,top)
        # 给自己方法加属性也可以
        #self.live=True
        # 加载敌方坦克图片
        self.images={
            "U": pygame.image.load("img/enemy1U.gif"),
            "D": pygame.image.load("img/enemy1D.gif"),
            "L": pygame.image.load("img/enemy1L.gif"),
            "R": pygame.image.load("img/enemy1R.gif")
        }

        # 随机生成敌方坦克方向
        self.direction=self.randomDirection()
        # 根据方向获取图片
        self.image=self.images[self.direction]
        # 区域
        self.rect=self.image.get_rect()
        # 对left和top赋值
        self.rect.left = left
        self.rect.top = top
        # 速度
        self.speed = speed
        # 移动开关
        self.flag = True
        # 新增一个步数变量 step
        self.step = 30

    def randomDirection(self):
        num=random.randint(1,4)
        if num == 1:
            return "U"
        elif num == 2:
            return "D"
        elif num == 3:
            return "L"
        elif num == 4:
            return "R"

    # 敌方坦克随机移动方法
    def randMove(self):
        if self.step <= 0:
            # 修改方向
            self.direction = self.randomDirection()
            self.step = random.randint(20, 80)
        else:
            self.move()
            # 让步数递减
            self.step -= 1

    def shot(self):
        num = random.randint(1,1000)
        if num < 25:
            return Bullet(self)

    # 敌方坦克碰撞我方坦克方法
    def ehitMyTank(self):
        if pygame.sprite.collide_rect(self, MainGame.my_tank):
            # 让敌方坦克停下
            self.stay()

# 子弹类
class Bullet(BaseItem):
    def __init__(self, tank):
        # 加载图片
        self.image = pygame.image.load("img/enemymissile.gif")
        # 坦克的方向决定子弹的方向
        self.direction = tank.direction
        # 获取区域
        self.rect = self.image.get_rect()
        # 子弹的left和top与方向有关
        if self.direction == "U":
            # 子弹left=tank.left+tank.rect.width/2-子弹.width/2
            self.rect.left = tank.rect.left + tank.rect.width / 2 - self.rect.width / 2
            # 子弹top=tank.top-子弹.height
            self.rect.top = tank.rect.top - self.rect.height
        elif self.direction == "L":
            self.rect.left = tank.rect.left - self.rect.width / 2 - self.rect.width / 2
            self.rect.top = tank.rect.top + tank.rect.width / 2 - self.rect.width / 2
        elif self.direction == "D":
            self.rect.left = tank.rect.left + tank.rect.width / 2 - self.rect.width / 2
            self.rect.top = tank.rect.top + tank.rect.height
        elif self.direction == "R":
            self.rect.left = tank.rect.left + tank.rect.width
            self.rect.top = tank.rect.top + tank.rect.width / 2 - self.rect.width / 2
        # 子弹的速度
        self.speed = 6
        # 用来记录子弹是否碰撞
        self.live = True

    # 子弹移动
    def bulletmove(self):
        if self.direction == "U":
            if self.rect.top > 0:
                self.rect.top -= self.speed
            else:
                # 修改子弹状态值
                self.live = False
        elif self.direction == "D":
            if self.rect.top < SCREEN_HEIGHT-self.rect.height:
                self.rect.top += self.speed
            else:
                # 修改子弹状态值
                self.live = False
        elif self.direction == "L":
            if self.rect.left > 0:
                self.rect.left -= self.speed
            else:
                # 修改子弹状态值
                self.live = False
        elif self.direction == "R":
            if self.rect.left < SCREEN_WIDTH-self.rect.height:
                self.rect.left += self.speed
            else:
                # 修改子弹状态值
                self.live = False

    # 展示子弹
    def displayBullet(self):
        # 将图片surface加载到窗口
        MainGame.window.blit(self.image, self.rect)

    # 我方子弹与敌方坦克碰撞的方法
    def hitEnemyTank(self):
        for enemyTank in MainGame.enemyTanklist:
            if pygame.sprite.collide_rect(enemyTank, self):
                # 产生爆炸效果
                explode = Explode(enemyTank)
                # 将爆炸效果加入到爆炸效果列表中
                MainGame.Explode_list.append(explode)
                self.live = False
                enemyTank.live = False

    # 敌方子弹与我方坦克碰撞的方法
    def hitMyTank(self):
        if pygame.sprite.collide_rect(self, MainGame.my_tank):
            # 产生爆炸效果, 并加入到爆炸效果列表中
            explode = Explode(MainGame.my_tank)
            MainGame.Explode_list.append(explode)
            # 修改子弹状态
            self.live = False
            # 修改我方坦克状态
            MainGame.my_tank.live = False

    # 子弹与墙壁碰撞
    def hitWall(self):
        for wall in MainGame.wall_list:
            if pygame.sprite.collide_rect(wall,self):
                # 修改子弹属性
                self.live = False
                wall.hp -= 1
                if wall.hp == 0:
                    wall.live = False


class Wall():
    def __init__(self,left,top):
        self.image = pygame.image.load("img/steels.gif")
        self.rect = self.image.get_rect()
        self.rect.left = left
        self.rect.top = top
        # 判断墙壁是不是应该在窗口中展示
        self.live = True
        # 记录墙壁的生命值
        self.hp = 3

    # 展示墙壁
    def displayWall(self):
        MainGame.window.blit(self.image, self.rect)


class Explode():
    def __init__(self, tank):
        # 爆炸位置=打中敌方坦克位置
        self.rect = tank.rect
        self.step = 0
        self.images = [
            pygame.image.load("img/blast0.gif"),
            pygame.image.load("img/blast1.gif"),
            pygame.image.load("img/blast2.gif"),
            pygame.image.load("img/blast3.gif"),
            pygame.image.load("img/blast4.gif")
        ]
        self.image = self.images[self.step]
        self.live = True

    # 爆炸效果
    def displayExplode(self):
        if self.step < len(self.images):
            MainGame.window.blit(self.image, self.rect)
            self.image=self.images[self.step]
            self.step += 1
        else:
            self.live = False
            self.step = 0


class Music():
    def __init__(self):
        pass

    # 播放音乐
    def play(self):
        pass


if __name__== "__main__":
    MainGame().startGame()
    #MainGame().getTextSurface()

Traceback (most recent call last):

  File "F:\Python\pythonProject\Tank\24.py", line 554, in <module>

    MainGame().startGame()

  File "F:\Python\pythonProject\Tank\24.py", line 76, in startGame

    self.blitEnemyTank()

  File "F:\Python\pythonProject\Tank\24.py", line 131, in blitEnemyTank

    enemyTank.ehitMyTank()

  File "F:\Python\pythonProject\Tank\24.py", line 404, in ehitMyTank

    if pygame.sprite.collide_rect(MainGame.my_tank, self):

  File "F:\Python\pythonProject\Tank\venv\lib\site-packages\pygame\sprite.py", line 1411, in collide_rect

    return left.rect.colliderect(right.rect)

AttributeError: 'NoneType' object has no attribute 'rect'


Process finished with exit code 1

老师帮忙看一下这个报错是什么原因, 我现在一被敌方坦克打中就报这个错, 其它功能好像都没问题, 但是之前敌方射击也OK的, 不知道什么情况.

Python 全系列/第二阶段:Python 深入与提高/游戏开发-坦克大战 13831楼
JAVA 全系列/第十一阶段:分布式RPC调用和分布式文件存储/Zookeeper 13832楼
Python 全系列/第九阶段:Flask百战电商后台系统/Flask百战电商后台项目 13834楼
Python 全系列/第一阶段:Python入门/编程基本概念 13836楼
JAVA 全系列/第十一阶段:分布式RPC调用和分布式文件存储/Zookeeper 13839楼
JAVA 全系列/第十五阶段:海量数据存储与查询/MyCat(旧) 13840楼

[root@bogon deploy_study]# pip3 install uwsgi==2.0.18 -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Collecting uwsgi==2.0.18
  Downloading http://pypi.doubanio.com/packages/e7/1e/3dcca007f974fe4eb369bf1b8629d5e342bb3055e2001b2e5340aaefae7a/uwsgi-2.0.18.tar.gz (801kB)
    100% |████████████████████████████████| 808kB 9.8MB/s 
Installing collected packages: uwsgi
  Running setup.py install for uwsgi ... error
    Complete output from command /usr/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-_lm5vsy4/uwsgi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-g1ttlatt-record/install-record.txt --single-version-externally-managed --compile:
    /usr/lib64/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'descriptions'
      warnings.warn(msg)
    running install
    using profile: buildconf/default.ini
    detected include path: ['/usr/include', '/usr/local/include']
    Patching "bin_name" to properly install_scripts dir
    detected CPU cores: 2
    configured CFLAGS: -O2 -I. -Wall -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -DUWSGI_HAS_IFADDRS -DUWSGI_ZLIB -DUWSGI_LOCK_USE_MUTEX -DUWSGI_EVENT_USE_EPOLL -DUWSGI_EVENT_TIMER_USE_TIMERFD -DUWSGI_EVENT_FILEMONITOR_USE_INOTIFY -DUWSGI_VERSION="\"2.0.18\"" -DUWSGI_VERSION_BASE="2" -DUWSGI_VERSION_MAJOR="0" -DUWSGI_VERSION_MINOR="18" -DUWSGI_VERSION_REVISION="0" -DUWSGI_VERSION_CUSTOM="\"\"" -DUWSGI_YAML -DUWSGI_SSL -DUWSGI_PLUGIN_DIR="\".\"" -DUWSGI_DECLARE_EMBEDDED_PLUGINS="UDEP(python);UDEP(gevent);UDEP(ping);UDEP(cache);UDEP(nagios);UDEP(rrdtool);UDEP(carbon);UDEP(rpc);UDEP(corerouter);UDEP(fastrouter);UDEP(http);UDEP(ugreen);UDEP(signal);UDEP(syslog);UDEP(rsyslog);UDEP(logsocket);UDEP(router_uwsgi);UDEP(router_redirect);UDEP(router_basicauth);UDEP(zergpool);UDEP(redislog);UDEP(mongodblog);UDEP(router_rewrite);UDEP(router_http);UDEP(logfile);UDEP(router_cache);UDEP(rawrouter);UDEP(router_static);UDEP(sslrouter);UDEP(spooler);UDEP(cheaper_busyness);UDEP(symcall);UDEP(transformation_tofile);UDEP(transformation_gzip);UDEP(transformation_chunked);UDEP(transformation_offload);UDEP(router_memcached);UDEP(router_redis);UDEP(router_hash);UDEP(router_expires);UDEP(router_metrics);UDEP(transformation_template);UDEP(stats_pusher_socket);" -DUWSGI_LOAD_EMBEDDED_PLUGINS="ULEP(python);ULEP(gevent);ULEP(ping);ULEP(cache);ULEP(nagios);ULEP(rrdtool);ULEP(carbon);ULEP(rpc);ULEP(corerouter);ULEP(fastrouter);ULEP(http);ULEP(ugreen);ULEP(signal);ULEP(syslog);ULEP(rsyslog);ULEP(logsocket);ULEP(router_uwsgi);ULEP(router_redirect);ULEP(router_basicauth);ULEP(zergpool);ULEP(redislog);ULEP(mongodblog);ULEP(router_rewrite);ULEP(router_http);ULEP(logfile);ULEP(router_cache);ULEP(rawrouter);ULEP(router_static);ULEP(sslrouter);ULEP(spooler);ULEP(cheaper_busyness);ULEP(symcall);ULEP(transformation_tofile);ULEP(transformation_gzip);ULEP(transformation_chunked);ULEP(transformation_offload);ULEP(router_memcached);ULEP(router_redis);ULEP(router_hash);ULEP(router_expires);ULEP(router_metrics);ULEP(transformation_template);ULEP(stats_pusher_socket);"
    *** uWSGI compiling server core ***
    [thread 1][gcc -pthread] core/utils.o
    [thread 0][gcc -pthread] core/protocol.o
    [thread 0][gcc -pthread] core/socket.o
    [thread 0][gcc -pthread] core/logging.o
    [thread 1][gcc -pthread] core/master.o
    [thread 1][gcc -pthread] core/master_utils.o
    [thread 0][gcc -pthread] core/emperor.o
    [thread 1][gcc -pthread] core/notify.o
    [thread 0][gcc -pthread] core/mule.o
    [thread 1][gcc -pthread] core/subscription.o
    [thread 0][gcc -pthread] core/stats.o
    [thread 1][gcc -pthread] core/sendfile.o
    [thread 1][gcc -pthread] core/async.o
    [thread 0][gcc -pthread] core/master_checks.o
    [thread 1][gcc -pthread] core/fifo.o
    [thread 0][gcc -pthread] core/offload.o
    [thread 1][gcc -pthread] core/io.o
    [thread 0][gcc -pthread] core/static.o
    [thread 0][gcc -pthread] core/websockets.o
    [thread 1][gcc -pthread] core/spooler.o
    [thread 0][gcc -pthread] core/snmp.o
    [thread 1][gcc -pthread] core/exceptions.o
    [thread 0][gcc -pthread] core/config.o
    [thread 1][gcc -pthread] core/setup_utils.o
    [thread 1][gcc -pthread] core/clock.o
    [thread 0][gcc -pthread] core/init.o
    [thread 1][gcc -pthread] core/buffer.o
    [thread 0][gcc -pthread] core/reader.o
    [thread 1][gcc -pthread] core/writer.o
    [thread 0][gcc -pthread] core/alarm.o
    [thread 1][gcc -pthread] core/cron.o
    [thread 0][gcc -pthread] core/hooks.o
    [thread 1][gcc -pthread] core/plugins.o
    [thread 0][gcc -pthread] core/lock.o
    [thread 1][gcc -pthread] core/cache.o
    [thread 0][gcc -pthread] core/daemons.o
    [thread 0][gcc -pthread] core/errors.o
    [thread 0][gcc -pthread] core/hash.o
    [thread 1][gcc -pthread] core/master_events.o
    [thread 0][gcc -pthread] core/chunked.o
    [thread 1][gcc -pthread] core/queue.o
    [thread 0][gcc -pthread] core/event.o
    [thread 1][gcc -pthread] core/signal.o
    [thread 0][gcc -pthread] core/strings.o
    [thread 1][gcc -pthread] core/progress.o
    [thread 0][gcc -pthread] core/timebomb.o
    [thread 1][gcc -pthread] core/ini.o
    [thread 0][gcc -pthread] core/fsmon.o
    [thread 1][gcc -pthread] core/mount.o
    [thread 0][gcc -pthread] core/metrics.o
    [thread 1][gcc -pthread] core/plugins_builder.o
    [thread 1][gcc -pthread] core/sharedarea.o
    [thread 0][gcc -pthread] core/rpc.o
    [thread 1][gcc -pthread] core/gateway.o
    [thread 0][gcc -pthread] core/loop.o
    [thread 1][gcc -pthread] core/cookie.o
    [thread 0][gcc -pthread] core/querystring.o
    [thread 1][gcc -pthread] core/rb_timers.o
    [thread 0][gcc -pthread] core/transformations.o
    [thread 1][gcc -pthread] core/uwsgi.o
    [thread 0][gcc -pthread] proto/base.o
    [thread 0][gcc -pthread] proto/uwsgi.o
    [thread 0][gcc -pthread] proto/http.o
    [thread 0][gcc -pthread] proto/fastcgi.o
    [thread 0][gcc -pthread] proto/scgi.o
    [thread 1][gcc -pthread] proto/puwsgi.o
    [thread 0][gcc -pthread] lib/linux_ns.o
    [thread 1][gcc -pthread] core/zlib.o
    [thread 0][gcc -pthread] core/yaml.o
    [thread 1][gcc -pthread] core/ssl.o
    [thread 0][gcc -pthread] core/legion.o
    [thread 1][gcc -pthread] core/dot_h.o
    [thread 1][gcc -pthread] core/config_py.o
    *** uWSGI compiling embedded plugins ***
    [thread 1][gcc -pthread] plugins/python/python_plugin.o
    In file included from plugins/python/python_plugin.c:1:
    plugins/python/uwsgi_python.h:2:10: 致命错误:Python.h:没有那个文件或目录
     #include <Python.h>
              ^~~~~~~~~~
    编译中断。
    
    ----------------------------------------
Command "/usr/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-_lm5vsy4/uwsgi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-g1ttlatt-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-_lm5vsy4/uwsgi/



图片.png


图片.png


老师,我在安装uwsgi时,出现编译终止,然后报错,我在网上也搜不到

Python 全系列/第十二阶段:Python_Django3框架/Django高级 13841楼
JAVA 全系列/第二阶段:JAVA 基础深化和提高/容器 13842楼
Python 全系列/第十一阶段:重量级Web框架-Django/Django高级 13844楼
JAVA 全系列/第十一阶段:智能家居项目(旧)/至尊智能家居第二天 13845楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637