我正在使用 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>
我正在使用 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();
}
}
错误来自第一个脚本,但也许还需要第二个脚本来修复错误
我试着看看是否有拼写错误
我也尝试过在线搜索,但没有找到任何结果
也许该教程已经过时了