skywalking 实现收集基于python的Django项目链路追踪案例

2023-11-02

一、python3环境设置

1.1、安装python3

apt-get update
apt install python3-pip -y
pip install "apache-skywalking"
[root@skywalking-agent-07 ~]# pip install "apache-skywalking"

Collecting apache-skywalking
  WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<urllib3.connection.VerifiedHTTPSConnection object at 0x7f29f5b41880>, 'Connection to files.pythonhosted.org timed out. (connect timeout=15)')': /packages/3f/2a/8934d1a7d781ec3c16114bad1bc5376bcf506e261c42c6b6718c0418e5a9/apache_skywalking-0.8.0-py3-none-any.whl
  WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<urllib3.connection.VerifiedHTTPSConnection object at 0x7f29f5b41910>, 'Connection to files.pythonhosted.org timed out. (connect timeout=15)')': /packages/3f/2a/8934d1a7d781ec3c16114bad1bc5376bcf506e261c42c6b6718c0418e5a9/apache_skywalking-0.8.0-py3-none-any.whl
  Downloading apache_skywalking-0.8.0-py3-none-any.whl (168 kB)
     |████████████████████████████████| 168 kB 670 kB/s 
Collecting packaging
  Downloading packaging-21.3-py3-none-any.whl (40 kB)
     |████████████████████████████████| 40 kB 4.2 MB/s 
Collecting wrapt
  Downloading wrapt-1.14.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (81 kB)
     |████████████████████████████████| 81 kB 4.7 MB/s 
Collecting grpcio-tools
  Downloading grpcio_tools-1.49.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.4 MB)
     |████████████████████████████████| 2.4 MB 5.0 MB/s 
Collecting grpcio
  Downloading grpcio-1.49.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.7 MB)
     |████████████████████████████████| 4.7 MB 41.9 MB/s 
Collecting pyparsing!=3.0.5,>=2.0.2
  Downloading pyparsing-3.0.9-py3-none-any.whl (98 kB)
     |████████████████████████████████| 98 kB 7.3 MB/s 
Collecting protobuf<5.0dev,>=4.21.3
  Downloading protobuf-4.21.7-cp37-abi3-manylinux2014_x86_64.whl (408 kB)
     |████████████████████████████████| 408 kB 13.8 MB/s 
Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from grpcio-tools->apache-skywalking) (45.2.0)
Requirement already satisfied: six>=1.5.2 in /usr/lib/python3/dist-packages (from grpcio->apache-skywalking) (1.14.0)
Installing collected packages: pyparsing, packaging, wrapt, protobuf, grpcio, grpcio-tools, apache-skywalking
Successfully installed apache-skywalking-0.8.0 grpcio-1.49.1 grpcio-tools-1.49.1 packaging-21.3 protobuf-4.21.7 pyparsing-3.0.9 wrapt-1.14.1

1.2、导入模块,验证当前环境是否能正常注册到skywalking server

[root@skywalking-agent-07 ~]# python3

Python 3.8.10 (default, Jun 22 2022, 20:18:18) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from skywalking import agent, config
>>> config.init(collector_address='172.16.88.187:11800', service_name='python-app')
>>> agent.start()
skywalking [MainThread] [WARNING] plugin sw_aiohttp failed to install, please disregard this warning if the corresponding package was not used in your project
skywalking [MainThread] [WARNING] plugin sw_bottle failed to install, please disregard this warning if the corresponding package was not used in your project
skywalking [MainThread] [WARNING] plugin sw_celery failed to install, please disregard this warning if the corresponding package was not used in your project
skywalking [MainThread] [WARNING] plugin sw_django failed to install, please disregard this warning if the corresponding package was not used in your project
skywalking [MainThread] [WARNING] plugin sw_elasticsearch failed to install, please disregard this warning if the corresponding package was not used in your project
skywalking [MainThread] [WARNING] plugin sw_falcon failed to install, please disregard this warning if the corresponding package was not used in your project
skywalking [MainThread] [WARNING] plugin sw_fastapi failed to install, please disregard this warning if the corresponding package was not used in your project
skywalking [MainThread] [WARNING] plugin sw_flask failed to install, please disregard this warning if the corresponding package was not used in your project
skywalking [MainThread] [WARNING] plugin sw_kafka failed to install, please disregard this warning if the corresponding package was not used in your project
skywalking [MainThread] [WARNING] plugin sw_mysqlclient failed to install, please disregard this warning if the corresponding package was not used in your project
skywalking [MainThread] [WARNING] plugin sw_psycopg failed to install, please disregard this warning if the corresponding package was not used in your project
skywalking [MainThread] [WARNING] plugin sw_psycopg2 failed to install, please disregard this warning if the corresponding package was not used in your project
skywalking [MainThread] [WARNING] plugin sw_pymongo failed to install, please disregard this warning if the corresponding package was not used in your project
skywalking [MainThread] [WARNING] plugin sw_pymysql failed to install, please disregard this warning if the corresponding package was not used in your project
skywalking [MainThread] [WARNING] plugin sw_pyramid failed to install, please disregard this warning if the corresponding package was not used in your project
skywalking [MainThread] [WARNING] plugin sw_rabbitmq failed to install, please disregard this warning if the corresponding package was not used in your project
skywalking [MainThread] [WARNING] plugin sw_redis failed to install, please disregard this warning if the corresponding package was not used in your project
skywalking [MainThread] [WARNING] plugin sw_sanic failed to install, please disregard this warning if the corresponding package was not used in your project
skywalking [MainThread] [WARNING] plugin sw_tornado failed to install, please disregard this warning if the corresponding package was not used in your project
>>> 
>>> exit()
[root@skywalking-agent-07 ~]#

二、上传并部署django项目

2.1、上传项目并安装依赖包

[root@skywalking-agent-07 ~]# tar -xf django-test.tgz

[root@skywalking-agent-07 ~]# cd django-test/
[root@skywalking-agent-07 django-test]# ls
bin  include  lib  mysite  pyvenv.cfg  requirements.txt
[root@skywalking-agent-07 django-test]# cat requirements.txt 
apache-skywalking==0.7.0
asgiref==3.4.1
backports.zoneinfo==0.2.1
Django==4.0.1
grpcio==1.43.0
grpcio-tools==1.43.0
packaging==21.3
protobuf==3.19.3
PyMySQL==1.0.2
pyparsing==3.0.6
six==1.16.0
sqlparse==0.4.2
wrapt==1.13.3
[root@skywalking-agent-07 django-test]# pip3 install -r requirements.txt   #安装依赖包
Collecting apache-skywalking==0.7.0
  Downloading apache_skywalking-0.7.0-py3-none-any.whl (169 kB)
     |████████████████████████████████| 169 kB 610 kB/s 
Collecting asgiref==3.4.1
  Downloading asgiref-3.4.1-py3-none-any.whl (25 kB)
Collecting backports.zoneinfo==0.2.1
  Downloading backports.zoneinfo-0.2.1-cp38-cp38-manylinux1_x86_64.whl (74 kB)
     |████████████████████████████████| 74 kB 2.5 MB/s 
Collecting Django==4.0.1
  Downloading Django-4.0.1-py3-none-any.whl (8.0 MB)
     |████████████████████████████████| 8.0 MB 4.2 MB/s 
Collecting grpcio==1.43.0
  Downloading grpcio-1.43.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.1 MB)
     |████████████████████████████████| 4.1 MB 27.8 MB/s 
Collecting grpcio-tools==1.43.0
  Downloading grpcio_tools-1.43.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.4 MB)
     |████████████████████████████████| 2.4 MB 10.4 MB/s 
Requirement already satisfied: packaging==21.3 in /usr/local/lib/python3.8/dist-packages (from -r requirements.txt (line 7)) (21.3)
Collecting protobuf==3.19.3
  Downloading protobuf-3.19.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB)
     |████████████████████████████████| 1.1 MB 10.6 MB/s 
Collecting PyMySQL==1.0.2
  Downloading PyMySQL-1.0.2-py3-none-any.whl (43 kB)
     |████████████████████████████████| 43 kB 3.9 MB/s 
Collecting pyparsing==3.0.6
  Downloading pyparsing-3.0.6-py3-none-any.whl (97 kB)
     |████████████████████████████████| 97 kB 12.5 MB/s 
Collecting six==1.16.0
  Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting sqlparse==0.4.2
  Downloading sqlparse-0.4.2-py3-none-any.whl (42 kB)
     |████████████████████████████████| 42 kB 2.1 MB/s 
Collecting wrapt==1.13.3
  Downloading wrapt-1.13.3-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (84 kB)
     |████████████████████████████████| 84 kB 4.7 MB/s 
Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from grpcio-tools==1.43.0->-r requirements.txt (line 6)) (45.2.0)
ERROR: launchpadlib 1.10.13 requires testresources, which is not installed.
Installing collected packages: wrapt, six, grpcio, protobuf, grpcio-tools, apache-skywalking, asgiref, backports.zoneinfo, sqlparse, Django, PyMySQL, pyparsing
  Attempting uninstall: wrapt
    Found existing installation: wrapt 1.14.1
    Uninstalling wrapt-1.14.1:
      Successfully uninstalled wrapt-1.14.1
  Attempting uninstall: six
    Found existing installation: six 1.14.0
    Not uninstalling six at /usr/lib/python3/dist-packages, outside environment /usr
    Can't uninstall 'six'. No files were found to uninstall.
  Attempting uninstall: grpcio
    Found existing installation: grpcio 1.49.1
    Uninstalling grpcio-1.49.1:
      Successfully uninstalled grpcio-1.49.1
  Attempting uninstall: protobuf
    Found existing installation: protobuf 4.21.7
    Uninstalling protobuf-4.21.7:
      Successfully uninstalled protobuf-4.21.7
  Attempting uninstall: grpcio-tools
    Found existing installation: grpcio-tools 1.49.1
    Uninstalling grpcio-tools-1.49.1:
      Successfully uninstalled grpcio-tools-1.49.1
  Attempting uninstall: apache-skywalking
    Found existing installation: apache-skywalking 0.8.0
    Uninstalling apache-skywalking-0.8.0:
      Successfully uninstalled apache-skywalking-0.8.0
  Attempting uninstall: pyparsing
    Found existing installation: pyparsing 3.0.9
    Uninstalling pyparsing-3.0.9:
      Successfully uninstalled pyparsing-3.0.9
Successfully installed Django-4.0.1 PyMySQL-1.0.2 apache-skywalking-0.7.0 asgiref-3.4.1 backports.zoneinfo-0.2.1 grpcio-1.43.0 grpcio-tools-1.43.0 protobuf-3.19.3 pyparsing-3.0.6 six-1.16.0 sqlparse-0.4.2 wrapt-1.13.3
[root@skywalking-agent-07 django-test]# pip3 install -r requirements.txt #再次确认是否遗漏少装
Requirement already satisfied: apache-skywalking==0.7.0 in /usr/local/lib/python3.8/dist-packages (from -r requirements.txt (line 1)) (0.7.0)
Requirement already satisfied: asgiref==3.4.1 in /usr/local/lib/python3.8/dist-packages (from -r requirements.txt (line 2)) (3.4.1)
Requirement already satisfied: backports.zoneinfo==0.2.1 in /usr/local/lib/python3.8/dist-packages (from -r requirements.txt (line 3)) (0.2.1)
Requirement already satisfied: Django==4.0.1 in /usr/local/lib/python3.8/dist-packages (from -r requirements.txt (line 4)) (4.0.1)
Requirement already satisfied: grpcio==1.43.0 in /usr/local/lib/python3.8/dist-packages (from -r requirements.txt (line 5)) (1.43.0)
Requirement already satisfied: grpcio-tools==1.43.0 in /usr/local/lib/python3.8/dist-packages (from -r requirements.txt (line 6)) (1.43.0)
Requirement already satisfied: packaging==21.3 in /usr/local/lib/python3.8/dist-packages (from -r requirements.txt (line 7)) (21.3)
Requirement already satisfied: protobuf==3.19.3 in /usr/local/lib/python3.8/dist-packages (from -r requirements.txt (line 8)) (3.19.3)
Requirement already satisfied: PyMySQL==1.0.2 in /usr/local/lib/python3.8/dist-packages (from -r requirements.txt (line 9)) (1.0.2)
Requirement already satisfied: pyparsing==3.0.6 in /usr/local/lib/python3.8/dist-packages (from -r requirements.txt (line 10)) (3.0.6)
Requirement already satisfied: six==1.16.0 in /usr/local/lib/python3.8/dist-packages (from -r requirements.txt (line 11)) (1.16.0)
Requirement already satisfied: sqlparse==0.4.2 in /usr/local/lib/python3.8/dist-packages (from -r requirements.txt (line 12)) (0.4.2)
Requirement already satisfied: wrapt==1.13.3 in /usr/local/lib/python3.8/dist-packages (from -r requirements.txt (line 13)) (1.13.3)
Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from grpcio-tools==1.43.0->-r requirements.txt (line 6)) (45.2.0)
[root@skywalking-agent-07 django-test]# 

2.2、创建django项目mysite

[root@skywalking-agent-07 django-test]# rm -fr mysite/
[root@skywalking-agent-07 django-test]# django-admin startproject mysite

2.3、创建应用

[root@skywalking-agent-07 django-test]# cd mysite/
[root@skywalking-agent-07 mysite]# python3 manage.py startapp myapp

2.4、初始化数据库

[root@skywalking-agent-07 mysite]# python3 manage.py makemigrations
[root@skywalking-agent-07 mysite]# python3 manage.py migrate

2.5、创建管理员, 用于登录

[root@skywalking-agent-07 mysite]# python3 manage.py createsuperuser

[root@skywalking-agent-07 mysite]# python3 manage.py createsuperuser
Username (leave blank to use 'root'): root
Email address: admin123@qq.com
Password: 
Password (again): 
This password is too common.
Bypass password validation and create user anyway? [y/N]: y
Superuser created successfully.
[root@skywalking-agent-07 mysite]# 

用户密码:root  1qaz@WSX

2.6、运行项目

设置相关环境变量
[root@skywalking-agent-07 mysite]# export SW_AGENT_NAME='python-app1'
[root@skywalking-agent-07 mysite]# export SW_AGENT_NAMESPACE='python-app1'
[root@skywalking-agent-07 mysite]# export SW_AGENT_COLLECTOR_BACKEND_SERVICES='172.16.88.187:11800'
[root@skywalking-agent-07 mysite]# vi mysite/settings.py

28    ALLOWED_HOSTS = ['127.0.0.1','172.16.88.194']

启动项目

[root@skywalking-agent-07 mysite]# sw-python -d run python3 manage.py runserver 172.16.88.194:80

skywalking-cli [DEBUG] Args received Namespace(command=['python3', 'manage.py', 'runserver', '172.16.88.194:80'], debug=True, option='run')
skywalking-cli [DEBUG] SkyWalking Python agent with CLI option 'run' and command ['python3', 'manage.py', 'runserver', '172.16.88.194:80']
skywalking-cli [DEBUG] SkyWalking Python agent `runner` received command ['python3', 'manage.py', 'runserver', '172.16.88.194:80']
skywalking-cli [DEBUG] Adding sitecustomize.py to PYTHONPATH
skywalking-cli [DEBUG] Updated PYTHONPATH - /usr/local/lib/python3.8/dist-packages/skywalking/bootstrap/loader
skywalking-cli [DEBUG] New process starting with file - `python3` args - `['python3', 'manage.py', 'runserver', '172.16.88.194:80']`
skywalking-loader [MainThread] [DEBUG] ---------------sitecustomize.py---------------
skywalking-loader [MainThread] [DEBUG] Successfully imported sitecustomize.py from `/usr/local/lib/python3.8/dist-packages/skywalking/bootstrap/loader/sitecustomize.py`
skywalking-loader [MainThread] [DEBUG] You are inside working dir - /root/django-test/mysite
skywalking-loader [MainThread] [DEBUG] Using Python version - 3.8.10 (default, Jun 22 2022, 20:18:18) 
[GCC 9.4.0] 
skywalking-loader [MainThread] [DEBUG] Using executable at - /usr/bin/python3
skywalking-loader [MainThread] [DEBUG] System Base Python executable location /usr
skywalking-loader [MainThread] [DEBUG] Original sitecustomize module not found, skipping.
skywalking-loader [MainThread] [DEBUG] SkyWalking Python Agent starting, loader finished.
skywalking [MainThread] [WARNING] failed to install plugin sw_aiohttp
skywalking [MainThread] [WARNING] failed to install plugin sw_celery
skywalking [MainThread] [WARNING] failed to install plugin sw_elasticsearch
skywalking [MainThread] [WARNING] failed to install plugin sw_falcon
skywalking [MainThread] [WARNING] failed to install plugin sw_flask
skywalking [MainThread] [WARNING] failed to install plugin sw_kafka
skywalking [MainThread] [WARNING] failed to install plugin sw_psycopg2
skywalking [MainThread] [WARNING] failed to install plugin sw_pymongo
skywalking [MainThread] [WARNING] failed to install plugin sw_pyramid
skywalking [MainThread] [WARNING] failed to install plugin sw_rabbitmq
skywalking [MainThread] [WARNING] failed to install plugin sw_redis
skywalking [MainThread] [WARNING] failed to install plugin sw_sanic
skywalking [MainThread] [WARNING] failed to install plugin sw_tornado
skywalking-loader [MainThread] [DEBUG] ---------------sitecustomize.py---------------
skywalking-loader [MainThread] [DEBUG] Successfully imported sitecustomize.py from `/usr/local/lib/python3.8/dist-packages/skywalking/bootstrap/loader/sitecustomize.py`
skywalking-loader [MainThread] [DEBUG] You are inside working dir - /root/django-test/mysite
skywalking-loader [MainThread] [DEBUG] Using Python version - 3.8.10 (default, Jun 22 2022, 20:18:18) 
[GCC 9.4.0] 
skywalking-loader [MainThread] [DEBUG] Using executable at - /usr/bin/python3
skywalking-loader [MainThread] [DEBUG] System Base Python executable location /usr
skywalking-loader [MainThread] [DEBUG] Original sitecustomize module not found, skipping.
skywalking-loader [MainThread] [DEBUG] SkyWalking Python Agent starting, loader finished.
skywalking [MainThread] [WARNING] failed to install plugin sw_aiohttp
skywalking [MainThread] [WARNING] failed to install plugin sw_celery
skywalking [MainThread] [WARNING] failed to install plugin sw_elasticsearch
skywalking [MainThread] [WARNING] failed to install plugin sw_falcon
skywalking [MainThread] [WARNING] failed to install plugin sw_flask
skywalking [MainThread] [WARNING] failed to install plugin sw_kafka
skywalking [MainThread] [WARNING] failed to install plugin sw_psycopg2
skywalking [MainThread] [WARNING] failed to install plugin sw_pymongo
skywalking [MainThread] [WARNING] failed to install plugin sw_pyramid
skywalking [MainThread] [WARNING] failed to install plugin sw_rabbitmq
skywalking [MainThread] [WARNING] failed to install plugin sw_redis
skywalking [MainThread] [WARNING] failed to install plugin sw_sanic
skywalking [MainThread] [WARNING] failed to install plugin sw_tornado
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
October 04, 2022 - 03:48:47
Django version 4.0.1, using settings 'mysite.settings'
Starting development server at http://172.16.88.194:80/
Quit the server with CONTROL-C.

2.7、检查并验证项目是否正常运行

2.8、验证skywalking server端数据采集

本文引用https://www.cnblogs.com/cyh00001/p/16753484.html

仅做个人学习记录使用

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

skywalking 实现收集基于python的Django项目链路追踪案例 的相关文章

  • Scrapy 在抓取一长串 url 时陷入困境

    我正在抓取一个大的 url 列表 1000 左右 并且在设定的时间后 爬虫程序会以 0 页 分钟的速度爬行 爬行时问题总是出现在同一个位置 url 列表是从 MySQL 数据库检索的 我对 python 和 scrapy 相当陌生 所以我不
  • 如何关闭python服务器

    使用此代码来运行 python 服务器 import os from http server import SimpleHTTPRequestHandler HTTPServer os chdir c users owner desktop
  • Redis - 错误:值不是有效的浮点数

    我在 Redis 中有一个排序集 我试图通过在Python代码中使用zincrby来更新特定元素的计数器值 例如 conn zincrby usersSet float 1 user1 但它显示错误为 错误 值不是有效的浮点数 我在 cli
  • 不能在jinja2宏中使用current_user?

    我使用 Flask Login 它提供了current user模板中的对象 我想编写一个宏来显示评论表单或登录链接 具体取决于用户是否登录 如果我直接在模板中使用此代码 它会起作用 if current user is authentic
  • Ubuntu Python shebang 线不工作

    无法让 shebang 线在 Ubuntu 中为 python 脚本工作 我每次只收到命令未找到错误 test py usr bin env python print Ran which python usr bin python 在 sh
  • 插入多行并返回主键时 Sqlalchemy 的奇怪行为

    插入多行并返回主键时 我注意到一些奇怪的事情 如果我在 isert 查询中添加使用参数值 我会得到预期的行为 但是当将值传递给游标时 不会返回任何内容 这可能是一个错误还是我误解了什么 我的sqlachemy版本是0 9 4 下面如何重现错
  • 尽管 ioff() 和 matplotlib.use('Agg'),Pyplot“无法连接到 X 服务器 localhost:10.0”

    我有一段代码 它被不同的函数调用 为我执行一些计算 然后将输出绘制到文件中 鉴于整个脚本可能需要一段时间才能运行更大的数据集 并且由于我可能想在给定时间分析多个数据集 所以我开始它screen然后断开连接并关闭我的腻子会话 并在第二天再检查
  • Python 3.4.3 subprocess.Popen 在没有管道的情况下获取命令的输出?

    我试图将命令的输出分配给变量 而不让命令认为它正在通过管道传输 原因是 如果正在通过管道传输 则相关命令会给出未格式化的文本作为输出 但如果从终端运行 则会给出颜色格式化的文本 我需要获取这种颜色格式的文本 到目前为止我已经尝试了一些事情
  • 如何解决错误 EGL 驱动程序消息(错误)eglQueryDeviceAttribEXT:使用 Selenium 和 Python 的错误属性

    我从 selenium 收到随机错误消息 即使它们都与我正在运行的确切 Web 驱动程序命令无关 据我所知 此错误不会中断程序 它只是添加不需要的警报 使我的打印件难以阅读 Chrome 版本 75 0 3770 100 官方版本 64 位
  • 生产环境的 Flask-Login 与 Flask-Security

    我正在构建一个功能 供用户注册 登录 验证和授权自己 特别是使用 Python Flask 作为后端 我找到了一些解决方案 例如flask login and flask security 据我了解 flask login实际上并没有进行任
  • Python控制台默认十六进制显示

    我在 Python 控制台中做了很多工作 其中大部分都涉及地址 我更喜欢以十六进制形式查看地址 So if a 0xBADF00D 当我简单地输入Python gt a进入控制台查看其值 我更喜欢 python 回复0xBADF00D代替1
  • 在 PyCharm 中运行命令行命令

    你好 我正在使用Python 但之前从未真正使用过它 我收到一些命令 需要在终端中运行 基本上 python Test py GET feeds 我正在使用 PyCharm 我想知道是否有办法从该 IDE 中运行这些相同的命令 按 Alt
  • Python:动态向对象添加字段

    我想知道是否可以动态向对象添加字段 例如 我希望能够添加如下内容 user object user first name John user last name Smith 当我在 Python 命令行解释器中执行该命令时 我得到 Attr
  • Pandas:向量化局部范围操作([i:i+2] 行的最大值和总和)

    我希望在数据帧中的每一行的局部范围内进行计算 同时避免速度缓慢for环形 例如 对于下面数据中的每一行 我想找到未来 3 天内 包括当天 的最高气温以及未来 3 天内的总降雨量 Day Temperature Rain 0 30 4 1 3
  • Numba jitclass 不适用于 python 列表

    我在用python 3 6 and numba 0 36 这个问题有一个sister https stackoverflow com questions 48159360 numba custom stack class and pop f
  • 如何在 Flask 中获取 POSTed JSON?

    我正在尝试使用 Flask 构建一个简单的 API 现在我想在其中读取一些 POSTed JSON 我使用 Postman Chrome 扩展进行 POST 我 POST 的 JSON 很简单 text lalala 我尝试使用以下方法读取
  • Flask APScheduler + Gunicorn 工作人员 - 在套接字修复后仍在运行任务两次

    我有一个 Flask 应用程序 我使用 Flask APScheduler 在我的数据库上运行计划查询并通过 cron 作业发送电子邮件 我通过 Gunicorn 使用以下配置运行我的应用程序并通过主管进行控制 program myapp
  • 检测计算机何时解锁 Windows

    我用过这个优秀的方法 https stackoverflow com questions 20733441 lock windows workstation using python 20733443锁定 Windows 计算机 那部分工作
  • 有效积累稀疏 scipy 矩阵的集合

    我有一个 O N NxN 的集合scipy sparse csr matrix 每个稀疏矩阵都有 N 个元素集 我想将所有这些矩阵加在一起以获得一个常规的 NxN numpy 数组 N 约为 1000 矩阵内非零元素的排列使得所得总和肯定不
  • Pymongo 批量插入

    我正在尝试批量插入文档 但批量插入时不会插入超过 84 个文档 给我这个错误 in insert pymongo errors InvalidOperation cannot do an empty bulk insert 是否可以批量插入

随机推荐

  • 面经-阿里电话面试

    又是一年面试季节 闲来无事看看市面上都在找那些技术 查缺补漏弥补不足 当然如果能够找到不错的去处也是好的 说来惭愧 第一次接到阿里电话时正在外边跟同事吃饭 环境实在是不允许 冒昧的给推迟到第二天了 第二次 是第二天的下午开会中 由于手机静音
  • VLC相关参数中文说明!

    用法 vlc 选项 流 您可以在命令行中指定多个流 它们将被加入播放列表队列 指定的首个项目将被首先播放 选项样式 选项 用于设置程序执行期间的全局选项 选项 单字母版本的全局 选项 选项 一个仅在流之前应用的选项 且将覆盖先前的设置 流
  • 探索Java中的反射机制:解析类的信息与执行动态操作

    探索Java中的反射机制 解析类的信息与执行动态操作 引言 在Java编程领域中 反射机制是一项强大的工具 它使得我们能够在运行时动态地获取 使用类的信息 甚至可以对类进行修改 通过反射 我们可以在编译时未知类的情况下 通过获取类的构造方法
  • 为什么 Java 中只有值传递?

    开始之前 我们先来搞懂下面这两个概念 形参 实参 值传递 引用传递 形参 实参 方法的定义可能会用到 参数 有参的方法 参数在程序语言中分为 实参 实际参数 用于传递给函数 方法的参数 必须有确定的值 形参 形式参数 用于定义函数 方法 接
  • python中函数返回值为func 和func() 的区别

    今天看书注意到一个问题 就是有些函数的返回值是直接return func 有些则是return func 看不清其区别 所以自己探究了一下 首先定义一个foo函数 def foo pass 察看type foo 得到
  • fabric2.X以上系统用test-network环境测试自己的链码

    首先 我们需要安装好fabric2 X的环境 具体参考我之前的文章 这里默认已经有了fabric2 X的环境 进入test network文件夹 在开始测试之前 先把gopath项目路径全部解锁 sudo chmod R 777 GOPAT
  • 时间复杂度以及空间复杂度——程序的性能分析

    什么是时间复杂度 算法的渐进时间复杂度T n O f n 其中f n 表示每行代码执行次数之和 而 O 表示正比例关系 大O符号表示法并不是用于来真实代表算法的执行时间的 它是用来表示代码执行时间的增长变化趋势的 时间复杂度是一种用于衡量算
  • 使用MATLAB实现对信号的EMD分解

    文章目录 0 前言 1 经验模式分解EMD 2 希尔伯特变换HT 3 希尔伯特 黄变换HHT 4 基于EMD的语音信号处理 5 MATLAB实现对信号的EMD分解 5 1 对构造的信号进行EMD 5 2 对实际的信号进行EMD 6 参考文献
  • python pyecharts的基础使用

    python pyecharts的基础使用 导包 from pyecharts charts import Line from pyecharts options import TitleOpts LegendOpts ToolboxOpt
  • 如何用springboot实现发送通知给用户的功能

    可以使用 Spring Boot 中的 Spring Boot Starter Mail 来实现发送通知给用户的功能 首先需要在项目的 pom xml 文件中添加对 spring boot starter mail 的依赖 然后在 appl
  • 【程序人生】5个月从职场打杂到月薪14000的女测试工程师逆袭之路

    大家好 我是来自湖南的一位辣妹子 毕业于一所工业大学 大学的专业是软件与工程 其实也算是本专业 大学期间掌握的知识也算比较广 各个方面都会一丢丢 就是不是特别深入 之所以这么说 是因为一直以来我觉得自己还不错 但毕业设计的时候 怎么也做不出
  • Audition报错:“无法应用设备设置,因为发生了以下错误:MME设备内部错误“

    今天打开AU提示有一个错误如下 打开设置以后就这样显示三条都不可用 查找了相关资料发现都不能解决 后来自己尝试几个地方设置才得以解决 问题出在如下 没有选对相应输入输出设备
  • AF_PACKET套接字解密 --- 02

    AF PACKET套接字解密 02 2012 05 23 22 36 57 分类 LINUX 当AF PACKET套接字注册了prot hook后 怎样进行监听呢 先来看发送 当协议栈准备将数据交给net device发送时 它将调用dev
  • (一维数组)输入N个数,然后逆序输出

    一维数组 1 输入N个数 例题6个数 然后逆序输出 define N 6 include stdio h void main int i a N t for i 0 i
  • 网络安全-js安全知识点与XSS常用payloads

    目录 简介 用法 JS必备知识 输出与注释 输出 注释 语法 函数 字符串方法 事件 表单 Cookie 代码执行 伪协议 XSS常用payload 普通 双写绕过 编码绕过 html标签绕过正则 参考 写给和我一样学习安全的小白 简介 J
  • eMMC分区管理

    目录 0 概述 FLASH分区类型 分区大小 分区编址 1 Boot Area Partitions 1 1 容量大小 1 2 从 Boot Area 启动 1 2 1 Original Boot Operation 1 2 2 Alter
  • 递归与回溯的理解

    递归 程序调用自身的编程技巧称为递归 recursion 递归做为一种算法在程序设计语言中广泛应用 一个过程或函数在其定义或说明中有直接或间接调用自身的一种方法 它通常把一个大型复杂的问题层层转化为一个与原问题相似的规模 较小的问题来求解
  • 忘了高高在上的Chatgpt吧,更香的Claude和Bard来了

    最近LLM这一领域近年来进步神速 新的产品层出不穷 给我们的生活和工作带来了巨大便利 也引发了广泛关注 首当其冲的 就数OpenAI研发的ChatGPT ChatGPT是一款基于GPT模型打造的对话AI系统 被业内公认为目前进展最快 实力最
  • 大多数女生为什么不适合当程序员?

    最重要的一点 逻辑思维能力 女程序员最大的问题不是压力大而是思维方式切换的挑战 从抽象到具象 平常需要将问题抽象出来 运用抽象思维解决工作上的困难 生活中间又要很具象 很感性地和人交往 这是非常难以达到的一件事 加上工作压力一大 就容易崩溃
  • skywalking 实现收集基于python的Django项目链路追踪案例

    一 python3环境设置 1 1 安装python3 apt get update apt install python3 pip y pip install apache skywalking root skywalking agent