8wDlpd.png
8wDFp9.png
8wDEOx.png
8wDMfH.png
8wDKte.png

docker-python 错误:ModuleNotFoundError:没有名为“_distutils_hack”的模块

OoDeLally 2月前

121 0

我正在使用 docker 和 apache2 运行一个 python/django 应用程序,它运行得很好,但是当我尝试再次运行时突然出现此错误:Traceback(最近一次调用最后一次):文件 \'...

我正在使用 docker 和 apache2 运行一个 python/django 应用程序,它运行良好,但是当我尝试再次运行时突然出现此错误:

  Traceback (most recent call last):
    File "<frozen site>", line 201, in addpackage
    File "<string>", line 1, in <module>
  ModuleNotFoundError: No module named '_distutils_hack'

Remainder of file ignored
  Traceback (most recent call last):
    File "<frozen site>", line 201, in addpackage
    File "<string>", line 1, in <module>
  ModuleNotFoundError: No module named '_distutils_hack'

Remainder of file ignored
Error processing line 1 of /usr/lib/python3/dist-packages/distutils-precedence.pth:

  Traceback (most recent call last):
    File "<frozen site>", line 201, in addpackage
    File "<string>", line 1, in <module>
  ModuleNotFoundError: No module named '_distutils_hack'

Remainder of file ignored
[Wed May 29 15:43:45.395312 2024] [wsgi:error] [pid 26:tid 132520276391616] [client 172.27.0.1:40422] mod_wsgi (pid=26): Failed to exec Python script file '/var/www/html/demo_app/water_maps/wsgi.py'.
[Wed May 29 15:43:45.395343 2024] [wsgi:error] [pid 26:tid 132520276391616] [client 172.27.0.1:40422] mod_wsgi (pid=26): Exception occurred processing WSGI script '/var/www/html/demo_app/water_maps/wsgi.py'.
[Wed May 29 15:43:45.395501 2024] [wsgi:error] [pid 26:tid 132520276391616] [client 172.27.0.1:40422] Traceback (most recent call last):
[Wed May 29 15:43:45.401671 2024] [wsgi:error] [pid 26:tid 132520276391616] [client 172.27.0.1:40422]   File "/var/www/html/demo_app/water_maps/wsgi.py", line 12, in <module>
[Wed May 29 15:43:45.401687 2024] [wsgi:error] [pid 26:tid 132520276391616] [client 172.27.0.1:40422]     from django.core.wsgi import get_wsgi_application
[Wed May 29 15:43:45.401704 2024] [wsgi:error] [pid 26:tid 132520276391616] [client 172.27.0.1:40422] ModuleNotFoundError: No module named 'django'

以下是项目中使用的文件的示例:

Dockerfile

FROM ubuntu

RUN apt-get update

# Avoid tzdata infinite waiting bug
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Africa/Cairo

RUN apt clean
RUN apt-get update
RUN apt-get install -y apt-utils vim curl apache2 apache2-utils git
RUN apt -y install software-properties-common
RUN apt update
RUN add-apt-repository ppa:deadsnakes/ppa
RUN apt -y install python3.10-full
# Optional: Set Python 3.9 as the default Python version
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1
# RUN apt-get -y install python3 libapache2-mod-wsgi-py3
RUN apt-get -y install libapache2-mod-wsgi-py3
RUN apt -y install certbot python3-certbot-apache
RUN apt-get -y install python3-pip
RUN apt update
# Check Python and pip versions
RUN python3 --version && \
    pip3 --version
#Add sf to avoid ln: failed to create hard link '/usr/bin/pip': File exists
RUN ln -sf /usr/bin/pip3 /usr/bin/pip
RUN pip install --upgrade pip --break-system-packages
RUN pip install django ptvsd --break-system-packages
RUN apt install wait-for-it
RUN pip install cffi --upgrade --break-system-packages
RUN pip install -U pip setuptools --break-system-packages
RUN apt-get -y install gettext
RUN apt-get -y install poppler-utils
RUN apt-get -y install redis-server
RUN apt-get install python3-pymysql
RUN a2enmod headers
RUN service apache2 restart
COPY www/demo_app/water_maps/requirements.txt requirements.txt
RUN python3 -m pip install --upgrade setuptools
RUN pip install -r requirements.txt --break-system-packages
ADD ./demo_site.conf /etc/apache2/sites-available/000-default.conf
EXPOSE 80 5432
WORKDIR /var/www/html/demo_app
#CMD ["apache2ctl", "-D", "FOREGROUND"]
#CMD ["python", "manage.py", "migrate", "--no-input"]

docker-compose.yaml

version: "2"

services:

  db:
    image: postgres:14
    restart: always 
    volumes:
      - ./data/db:/var/lib/postgresql/data
      - ./www/:/var/www/html
      - ./www/demo_app/kml_files:/var/www/html/demo_app/kml_files
      - ./www/demo_app/temp_kml_file:/var/www/html/demo_app/temp_kml_file
      - ./www/demo_app/upload:/var/www/html/demo_app/upload
      - ./data/log:/var/log/apache2
    ports:
      - '5432:5432'
    environment:
      - POSTGRES_DB=database_innvoentiq
      - POSTGRES_USER=database_user_innvoentiq
      - POSTGRES_PASSWORD=Yahoo000@

  django-apache2:
    build: .
    container_name: water_maps
    restart: always 
    environment:
      - POSTGRES_DB=database_innvoentiq
      - POSTGRES_USER=database_user_innvoentiq
      - POSTGRES_PASSWORD=Yahoo000@
    ports:
      - 5000:80
      - 5001:443
      # - 80:80
      # - 443:443

    volumes:
      - ./www/:/var/www/html
      - ./www/demo_app/kml_files:/var/www/html/demo_app/kml_files
      - ./www/demo_app/temp_kml_file:/var/www/html/demo_app/temp_kml_file
      - ./www/demo_app/upload:/var/www/html/demo_app/upload
      - ./data/log:/var/log/apache2

      # - ./data/config/etc/apache2:/etc/apache2
    # command: sh -c 'python3 manage.py migrate && python3 manage.py loaddata the_db.json '
    command: sh -c 'wait-for-it db:5432 -- python3 manage.py makemigrations && python3 manage.py migrate && python3 manage.py collectstatic --noinput && python3 manage.py compilemessages && apache2ctl -D FOREGROUND'
    # command: sh -c 'wait-for-it db:5432 -- python manage.py migrate && python manage.py loaddata last.json && apache2ctl -D FOREGROUND'

    depends_on:
      - db

/demo_site.conf

WSGIPythonPath /var/www/html/demo_app

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com
        # ServerName test3.watermaps-eg.com
        # ServerAlias test3.watermaps-eg.com
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/



       Alias /static /var/www/html/demo_app/static
       Alias /en/upload  /var/www/html/demo_app/upload
       Alias /ar/upload  /var/www/html/demo_app/upload
       Alias /upload  /var/www/html/demo_app/upload

        WSGIScriptAlias / /var/www/html/demo_app/water_maps/wsgi.py
WSGIPassAuthorization On
        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn
<Directory /var/www/html/demo_app>
Require all granted
</Directory>
<Directory /var/www/html/demo_app/static>
Require all granted
</Directory>

<Directory /var/www/html/demo_app/upload>
Require all granted
</Directory>
<Directory /var/www/html/demo_app/water_maps>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Header add Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Headers "*"
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
        TimeOut 7200
</VirtualHost>
帖子版权声明 1、本帖标题:docker-python 错误:ModuleNotFoundError:没有名为“_distutils_hack”的模块
    本站网址:http://xjnalaquan.com/
2、本网站的资源部分来源于网络,如有侵权,请联系站长进行删除处理。
3、会员发帖仅代表会员个人观点,并不代表本站赞同其观点和对其真实性负责。
4、本站一律禁止以任何方式发布或转载任何违法的相关信息,访客发现请向站长举报
5、站长邮箱:yeweds@126.com 除非注明,本帖由OoDeLally在本站《ubuntu》版块原创发布, 转载请注明出处!
最新回复 (0)
  • 我正在尝试使用 Ubuntu 最新映像设置新的 Docker 容器,并使用 PyEnv 安装多个 Python 版本。虽然我成功安装了 Python 3.8.10,但遇到了问题...

    我正在尝试使用 Ubuntu 最新映像设置新的 Docker 容器,并使用 PyEnv 安装多个 Python 版本。虽然我成功安装了 Python 3.8.10,但在尝试安装 Python 3.6.8 时遇到了问题。

    重现步骤:

    1. 启动 Docker 容器: docker run -it --label 'python-envs' -v ~/Desktop/python-envs/:/workspace/python-envs:rw --hostname python --name python-envs ubuntu:latest

    系统信息 uname -a Linux python 6.5.0-35-generic #35~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue May 7 09:00:52 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

    1. 已安装的 pyenv: curl https://pyenv.run | bash

    验证已安装的 Python 版本,我 3.8.10 之前安装过版本并成功: pyenv versions

    输出: * system (set by /root/.pyenv/version) 3.8.10

    1. 安装所需的库:

    apt install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev

    1. 尝试安装 Python 3.6.8:

    pyenv install 3.6.8

    遇到错误:

    Downloading Python-3.6.8.tar.xz...
    -> https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tar.xz
    Installing Python-3.6.8...
    /root/.pyenv/plugins/python-build/bin/python-build: line 1863: 30193 Segmentation fault      (core dumped) "$PYTHON_BIN" -c "import $1"
    WARNING: The Python ctypes extension was not compiled. Missing the libffi lib?
    /root/.pyenv/plugins/python-build/bin/python-build: line 2089: 30200 Segmentation fault      (core dumped) "$PYTHON_BIN" $python_opts -m ensurepip ${ensurepip_opts} > /dev/null 2>&1
    Installing pip from https://bootstrap.pypa.io/pip/3.6/get-pip.py...
    /root/.pyenv/plugins/python-build/bin/python-build: line 2065: 30204 Segmentation fault      (core dumped) "${PYTHON_BIN}" -s "${get_pip}" ${GET_PIP_OPTS} 1>&4 2>&1
    error: failed to install pip via get-pip.py
    
    BUILD FAILED (Ubuntu 24.04 using python-build 20180424)
    
    Inspect or clean up the working tree at /tmp/python-build.20240612063012.18758
    Results logged to /tmp/python-build.20240612063012.18758.log
    
    Last 10 log lines:
                    install|*) ensurepip="" ;; \
            esac; \
            LD_LIBRARY_PATH=/tmp/python-build.20240612063012.18758/Python-3.6.8 ./python -E -m ensurepip \
                    $ensurepip --root=/ ; \
    fi
    Looking in links: /tmp/tmpm_fdsrq7
    Collecting setuptools
    Collecting pip
    Installing collected packages: setuptools, pip
    Successfully installed pip-18.1 setuptools-40.6.2
    

    清除以前的尝试: pyenv uninstall 3.6.8

    使用环境变量来调整构建配置:

    CFLAGS="-O2 -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fno-plt \
    -Wformat -Werror=format-security -fPIC" \
    LDFLAGS="-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed" \
    

    这些步骤都无法解决问题。使用 PyEnv 安装 Python 3.6.8 时,什么原因导致分段错误?我需要考虑其他步骤或配置吗?

    任何见解或建议都将不胜感激!

  • 你是否有充分的理由尝试安装 2.5 年内没有安全支持的 Python 版本?(它很可能与 Ubuntu 24.04 不兼容。)

  • @AKX 我工作的环境需要对一些内部应用程序进行特殊处理。如果它与 Ubuntu 24.03 不兼容,我应该使用哪个版本?

  • 我正在使用 Natty gamedev 的教程,在第一个教程中遇到了这个问题,我使用的是最新推荐的 unity 版本,我对 gamedev 和 unity 也比较陌生,确切的错误我...

    我正在使用 Natty gamedev 的教程,在第一个教程中遇到了这个问题,我正在使用最新推荐的 unity 版本

    我对游戏开发和 Unity 也还很陌生

    确切的错误消息是Assets/Scripts/PlayerMotor.cs(26,33):错误CS1061:'Vector2'不包含't'的定义,并且找不到接受'Vector2'类型第一个参数的可访问扩展方法't'(您是否缺少using指令或程序集引用?)

    我的代码如下,正在使用 YouTube 教程

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    
    public class NewBehaviourScript : MonoBehaviour
    {
        private CharacterController Controller;
        private Vector3 PlayerVelocity;
        public float speed = 5f;
        // Start is called before the first frame update
        void Start()
        {
            Controller = GetComponent<CharacterController>();
        }
    
        // Update is called once per frame
        void Update()
        {
            
        }
        //recieve the inputs for our InputManager.cs and apply them to out character controller.
        public void ProcessMove(Vector2 input)
        {
            Vector3 MoveDirection = Vector3.zero;
            MoveDirection.x = input.x;
            MoveDirection.z = input.t;
            Controller.Move(transform.TransformDirection(MoveDirection) * speed * Time.deltaTime);
        }
    }
    
    

    我的第二个脚本是

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.InputSystem;
    
    public class InputManager : MonoBehaviour
    {
        private PlayerInput PlayerInput;
        private PlayerInput.OnFootActions OnFoot;
        // Start is called before the first frame update
        void Awake()
        {
           PlayerInput = new PlayerInput();
           OnFoot = PlayerInput.OnFoot;
           motor = GetComponent<PlayerMotor>();
        }
    
        // Update is called once per frame
        void FixedUpdate() 
        {
            //tell the playermotor to move using the value from our movement action.
            motor.ProcessMove(Onfoot.Movement.ReadValue<Vector2>()); 
        }
        private void OnEnable() 
        {
            OnFoot.Enable();
        }
        private void OnDisable() 
        {
           OnFoot.Disable();
        }
    }
    
    

    错误来自第一个脚本,但也许还需要第二个脚本来修复错误

    我试着看看是否有拼写错误

    我也尝试过在线搜索,但没有找到任何结果

    也许该教程已经过时了

  • 我不明白计算线性方程组时的错误是什么。我需要使用 C 中的 Scilab API 来求解线性方程组,但我得到的值太小了。

    我不明白计算线性方程组时的错误是什么。我需要使用 C ,但我得到的值太小了。检查了解决方案,答案应该是: [0;1] .Free 被特别注释,因为程序会立即崩溃。

    我以为错误出在 dgesv_ ,但这很奇怪,因为它是一个 Scilab 函数,为什么它解析不正确。也许输出有问题?

    代码:

    #include "api_scilab.h"
    #include "Scierror.h"
    #include "BOOL.h"
    #include "localization.h"
    
    extern void dgesv_(int* n, int* nrhs, double* A, int* lda, int* ipiv, double* b, int* ldb, int* info);
    
    static const char fname[] = "foo6";
    
    int sci_foo6(scilabEnv env, int nin, scilabVar* in, int nopt, scilabOpt* opt, int nout, scilabVar* out)
    {
        int i = 0;
        int n = 0; // System dimension
        double* A = NULL; // Coefficient matrix
        double* b = NULL; // Right-hand side vector
        double* x = NULL; // Solution
        int info = 0;
    
        /* Check the number of input and output arguments */
        if (nin != 2 || nout != 1) {
            Scierror(77, _("%s: Wrong number of input or output arguments: 2 inputs and 1 output expected.\n"), fname);
            return 1;
        }
    
        /* Check the types of input arguments */
        if (scilab_isDouble(env, in[0]) == 0 || scilab_isMatrix2d(env, in[0]) == 0 ||
            scilab_isComplex(env, in[0]) == 1 || scilab_isDouble(env, in[1]) == 0 ||
            scilab_isMatrix2d(env, in[1]) == 0 || scilab_isComplex(env, in[1]) == 1) {
            Scierror(999, _("%s: Wrong type for input arguments. Double matrices expected.\n"), fname);
            return 1;
        }
    
        /* Get the dimension of the coefficient matrix */
        int rowA = 0, colA = 0, rowB = 0, colB = 0;
        scilab_getDim2d(env, in[0], &rowA, &colA);
        scilab_getDim2d(env, in[1], &rowB, &colB);
        if (rowA != colA || rowB != rowA || colB != 1) {
            Scierror(999, _("%s: Incorrect dimensions. Coefficient matrix should be square and vector should be a column vector of the same size.\n"), fname);
            return 1;
        }
        n = rowA;
    
        /* Get data from input arguments */
        scilab_getDoubleArray(env, in[0], &A);
        scilab_getDoubleArray(env, in[1], &b);
    
        /* Solve the system of linear equations */
        x = (double*)malloc(n * sizeof(double));
        dgesv_(&n, &n, A, &n, b, x, &n, &info);
        if (info != 0) {
            Scierror(999, _("%s: LAPACK dgesv function failed with error code %d.\n"), fname, info);
            free(x);
            return 1;
        }
    
        /* Create the output argument and copy the result */
        out[0] = scilab_createDoubleMatrix2d(env, 1, n, 0);
        double* xPtr = NULL;
        scilab_getDoubleArray(env, out[0], &xPtr);
    
        for (i = 0; i < n; i++) {
            xPtr[i] = x[i];
        }
    
        //free(x);
        return 0;
    }
    

    结论:

    --> A = [2, 1; -1, 2]; 
     
    --> b = [1; 2]; 
     
    --> x = foo6(A, b); 
     
    --> disp(x); 
     
       5.27D-314   2.64D-314
    

    尝试通过 Scilab API 解决 SLAU,但收效甚微。我不确定我做得对不对。

  • 考虑在 scilab.discourse.group 上发布有关 Scilab 的更多问题,谢谢。

  • 请参阅下面已修复的代码,上面的代码有几个问题:

    1. dgesv 的第二个参数必须等于一
    2. 缺少整数枢轴数组
    3. 右边的 b 被解决方案覆盖,因此您必须将初始 b 复制到 x 中。
    #include "api_scilab.h"
    #include "Scierror.h"
    #include "BOOL.h"
    #include "localization.h"
    
    extern void dgesv_(int* n, int* nrhs, double* A, int* lda, int* ipiv, double* b, int* ldb, int* info);
    
    static const char fname[] = "foo6";
    
    int sci_foo6(scilabEnv env, int nin, scilabVar* in, int nopt, scilabOpt* opt, int nout, scilabVar* out)
    {
        int i = 0;
        int n = 0; // System dimension
        int iOne = 1;
        double* A = NULL; // Coefficient matrix
        double* b = NULL; // Right-hand side vector
        double* x = NULL; // Solution
        int* iPiv = NULL;
        int info = 0;
    
        /* Check the number of input and output arguments */
        if (nin != 2 || nout != 1) {
            Scierror(77, _("%s: Wrong number of input or output arguments: 2 inputs and 1 output expected.\n"), fname);
            return 1;
        }
    
        /* Check the types of input arguments */
        if (scilab_isDouble(env, in[0]) == 0 || scilab_isMatrix2d(env, in[0]) == 0 ||
            scilab_isComplex(env, in[0]) == 1 || scilab_isDouble(env, in[1]) == 0 ||
            scilab_isMatrix2d(env, in[1]) == 0 || scilab_isComplex(env, in[1]) == 1) {
            Scierror(999, _("%s: Wrong type for input arguments. Double matrices expected.\n"), fname);
            return 1;
        }
    
        /* Get the dimension of the coefficient matrix */
        int rowA = 0, colA = 0, rowB = 0, colB = 0;
        scilab_getDim2d(env, in[0], &rowA, &colA);
        scilab_getDim2d(env, in[1], &rowB, &colB);
        if (rowA != colA || rowB != rowA || colB != 1) {
            Scierror(999, _("%s: Incorrect dimensions. Coefficient matrix should be square and vector should be a column vector of the same size.\n"), fname);
            return 1;
        }
        n = rowA;
    
        /* Get data from input arguments */
        scilab_getDoubleArray(env, in[0], &A);
        scilab_getDoubleArray(env, in[1], &b);
    
        /* Solve the system of linear equations */
        x = (double*)malloc(n * sizeof(double));
        for (i = 0; i < n; i++) {
            x[i] = b[i];
        }
    
        iPiv = (int*)malloc(n * sizeof(int));
        dgesv_(&n, &iOne, A, &n, iPiv, x, &n, &info);
        if (info != 0) {
            Scierror(999, _("%s: LAPACK dgesv function failed with error code %d.\n"), fname, info);
            free(x);
            free(iPiv);
            return 1;
        }
    
        /* Create the output argument and copy the result */
        out[0] = scilab_createDoubleMatrix2d(env, 1, n, 0);
        double* xPtr = NULL;
        scilab_getDoubleArray(env, out[0], &xPtr);
    
        for (i = 0; i < n; i++) {
            xPtr[i] = x[i];
        }
    
        free(x);
        free(iPiv);
        return 0;
    }
    

    没有给出编译和链接的说明(上面的源代码应该保存在 sci_foo6.c ):

     ilib_build('foo6',['foo6','sci_foo6','csci6'],"sci_foo6.c",[]);
     exec loader.sce
    

    然后正确计算出解决方案:

    --> A = [2, 1; -1, 2]; 
    
    --> b = [1;2];
    
    --> x = foo6(A,b)
     x  = 
    
       0.   1.
    
  • 我使用 Netcode for GameObjects (NGO) 开发了一款多人纸牌游戏,并计划通过托管在 Web 服务器上的 WebGL 版本部署客户端。然而,我遇到了重大

    我使用 Netcode for GameObjects (NGO) 开发了一款多人纸牌游戏,并计划通过托管在 Web 服务器上的 WebGL 版本部署客户端。然而,我在实现这一目标时遇到了很大困难。

    我正在寻求有关当前项目设计可行性的建议,如果可行的话,寻求一些关于克服我所面临的问题的指导。

    我目前所做的:

    A. 研究和文档:我阅读了各种论坛和 Unity 文档,它们表明 Unity Transport 2.1+ 支持 WebGL 构建。

    B. 条件编译:用 #if UNITY_SERVER || UNITY_EDITOR 包围多播 sdk 代码,实现 #if SERVER 作为多播代码根本无法导出到 Android 版本。如本 discussion

    C.最小项目结构来隔离问题:

    -Player and Player Manager scripts.
    -Network Manager object with NetworkManager comp.
    -Server Startup
    -MatchmakerClient script - with simply pool rules to ensure functionality.
    

    当我添加 Transport 2.1 并添加条件编译时,我不断遇到错误。每次我解决一个错误时,就会出现另一个错误。该项目在本地运行。构建 NGO 测试分配成功。但是,生成包含多人功能的功能齐全的 WebGL 构建一直难以实现。我可以创建一个没有多人设计的 WebGL 构建,但集成所有内容却没有成功。我为此度过了几个漫长的夜晚,我想知道继续撞墙是否是前进的正确方法……

    我的问题正是:

    1. p9

    2. p10

    3. p11

    任何见解、建议或相关资源的参考都将不胜感激。感谢您的时间和帮助。

  • 当然可以。唯一的区别是您需要选择 wss(我认为例如不是 udp 或 tcp)作为传输方式。我不确定您为什么会遇到问题,我第一次使用时就成功了,我唯一的问题是您的服务器在哪里?

  • 感谢您的评论。您似乎强烈支持这个想法,这很好。但是我没有找到任何相关文档。如果我使用 Unity NGO 服务器,加载 webgl 构建(即条件编译)会非常困难。到目前为止,我还有一些未解决的问题,例如 CORS 和 web-socket 缺乏与 NGO 云服务器的连接。问题不是我在开发过程中撞墙了……这是意料之中的事,但我找不到相关文档。您能否分享有关此设计确认基础的更多信息?

  • 我会给你网址,但我的基础服务器已关闭。因为我这样做只是为了证明我能做到。所以。老实说,我唯一要做的就是将传输设置为 websockets。除此之外,它工作正常。虽然不清楚有一件事你可能从你的写作中不知道,那就是它是 webgl 客户端而不是服务器。现在,我确实相信你可以用 webgl 实现服务器,但我没有尝试过。最初,为了保存整个类型 ip 或代码或其他任何东西,我在启动时将代码发送到网页并允许客户端获取它。然后我改为中继。但一切都正常。

  • JRB 2月前 0 只看Ta
    引用 13

    我需要安装 MongoDB 7.0 的最新版本。大家好,我需要安装 MongoDb 7 的最新版本。echo \'deb [ arch=amd64,arm64signed-by=/usr/share/keyrings/mongodb-server-7.0....

    我需要安装 MongoDB 7.0 的最新版本

    大家好,我需要安装 MongoDb 7 的最新版本。

    echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list
    

    但是当我尝试更新时:

    sudo apt-get update
    

    Linux 终端给出这个错误:

    sudo apt-get update Hit:1 http://it.archive.ubuntu.com/ubuntu noble InRelease Hit:2 http://it.archive.ubuntu.com/ubuntu noble-updates InRelease               Hit:3 http://it.archive.ubuntu.com/ubuntu noble-backports InRelease             Ign:4 https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 InRelease Hit:5 http://security.ubuntu.com/ubuntu noble-security InRelease Ign:6 https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/8.0 InRelease Get:7 https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 Release [2,090 B] Err:8 https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/8.0 Release   404  Not Found [IP: 52.84.45.6 443] Get:9 https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 Release.gpg [866 B] Ign:9 https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 Release.gpg Reading package lists... Done E: The repository 'https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/8.0 Release' does not have a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details. W: GPG error: https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 160D26BB1785BA38 E: The repository 'https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 Release' is not signed. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details.
    

    现在我正在使用 Ubuntu 24.04 LTS。

    有什么解决办法吗?

  • JDev 2月前 0 只看Ta
    引用 14

    我正在尝试创建一个问答游戏,就像 Jeopardy 的工作原理一样。现在,我试图让顶行的文本对象分别显示来自字符串的不同项目,该字符串列出了所有

    我正在尝试创建一个问答游戏,就像 Jeopardy 的工作原理一样。现在,我试图让顶行中的每个文本对象都显示来自字符串的不同项目,该字符串列出了所有类别,如果我能做到这一点,它将有助于为下一步提供思路,即从预制件中获取文本,以根据玩家选择的按钮显示一组问题和答案。

    Tl Dr:行(父对象)>单元格(子对象),文本作为单元格的子对象/行的直接子对象

    文本对象 1 - 6

    --------------->

    字符串项目 1 - 6

    文本 1 表示项目/类别 1,文本 2 表示项目/类别 2,等等

    就实践而言,我已经能够使顶行的各个面板显示单个数字。

    public class CategoryRow : MonoBehaviour {
    
        public ClueCell[] cells { get; private set; }
    
            public int Size => cells.Length;
    
            public TextMeshProUGUI category_;
    
            public Text Categories;
    
        public void Awake() {
            cells = GetComponentsInChildren<ClueCell>();
        }
    
        public void Start() {
            int number = 1;
            category_.text = "Category " + number.ToString();
    
            Categories.text = "Category " + number.ToString();
        }
    }
    

    但如果我尝试做这样的事情:

    public class CategoryRow : MonoBehaviour
    {
        public ClueCell[] cells { get; private set; }
        public int Size => cells.Length;
    
        public TextMeshProUGUI category_;
        public Text Categories;
    
        public int[] CategoryNum = { 1, 2, 3, 4, 5, 6 };
    
        public void Awake()
        {
            cells = GetComponentsInChildren<ClueCell>();
        }
    
        public void Start()
        {
            //int number = 1;
            for(int x = 1; x < cells.Length; x++)
            {
                category_.text = "Category " + CategoryNum[x].ToString();
                Categories.text = "Category " + CategoryNum[x].ToString();
            }
        }
    }
    

    它停止工作了。此时,我的大脑已经完全崩溃了,试图查看其他相关的帖子和​​指南,我感觉我遗漏了一些东西,并且将代码行(包括我在这里发布的内容)从许多不同的尝试中混淆了。如果有一种方法可以做到这一点而不必去,文本 1 = \'\',文本 2 = \'\',等等,我非常想知道。

  • 引用 15

    欢迎新用户。只需从文本文件中读取它们即可。搜索“在 Unity 中从文件读取测试”或提出其他问题!

返回
作者最近主题: