ModuleNotFoundError:在Py 3.8.0中没有名为“ _ctypes”的模块

时间:2020-10-03 08:05:11

标签: python compiler-errors

我正在尝试安装python reactjs项目的要求。依赖关系存在于requirements.in文件中。

Py版本:3.8.0

我已经参考了其他类似的问题并安装了libffi-dev,但仍然无法解决该错误

sudo apt-get install libffi-dev

libffi-dev版本

dpkg-query -l | grep libffi-dev

输出

ii  libffi-dev:amd64                                            3.2.1-8

我的makefile文件

ARG := $(word 2, $(MAKECMDGOALS) )

clean:
    @find . -name "*.pyc" -exec rm -rf {} \;
    @find . -name "__pycache__" -delete

test:
    python backend/manage.py test $(ARG) --parallel --keepdb

dockertest:
    docker-compose run backend python backend/manage.py test $(ARG) --parallel --keepdb

testreset:
    python backend/manage.py test $(ARG) --parallel

dockertestreset:
    docker-compose run backend python backend/manage.py test $(ARG) --parallel

backend_format:
    black backend

upgrade: ## update the *requirements.txt files with the latest packages satisfying *requirements.in
    pip install -U -q pip-tools
    pip-compile --upgrade -o dev-requirements.txt dev-requirements.in
    pip-compile --upgrade -o requirements.txt requirements.in
    # Make everything =>, not ==
    sed 's/==/>=/g' requirements.txt > requirements.tmp
    mv requirements.tmp requirements.txt

clean_examples:
    # Remove the tables specific for the example app
    python manage.py migrate exampleapp zero
    # Removing backend example app files
    rm -rf ./backend/exampleapp
    # Removing frontend example app files
    rm -rf ./frontend/js/app/example-app
    # Removing example templates files
    rm -rf ./backend/templates/exampleapp

compile_install_requirements:
    @echo 'Installing pip-tools...'
    export PIP_REQUIRE_VIRTUALENV=true; \
    pip install pip-tools
    @echo 'Compiling requirements...'
    pip-compile requirements.in > requirements.txt
    pip-compile dev-requirements.in > dev-requirements.txt
    @echo 'Installing requirements...'
    pip install -r requirements.txt && pip install -r dev-requirements.txt

Requirements.in文件

django<3
celery[redis]
django-model-utils
django-webpack-loader
django-js-reverse
django-import-export
python-decouple
psycopg2
brotlipy
django-log-request-id
dj-database-url
gunicorn
whitenoise
psutil
ipython
sentry-sdk

错误

make compile_install_requirements
Installing pip-tools...
export PIP_REQUIRE_VIRTUALENV=true; \
pip install pip-tools
Requirement already satisfied: pip-tools in /home/joel/.virtualenvs/pro1/lib/python3.8/site-packages (5.3.1)
Requirement already satisfied: pip>=20.0 in /home/joel/.virtualenvs/pro1/lib/python3.8/site-packages (from pip-tools) (20.2.3)
Requirement already satisfied: six in /home/joel/.virtualenvs/pro1/lib/python3.8/site-packages (from pip-tools) (1.15.0)
Requirement already satisfied: click>=7 in /home/joel/.virtualenvs/pro1/lib/python3.8/site-packages (from pip-tools) (7.1.2)
Compiling requirements...
pip-compile requirements.in > requirements.txt
      ERROR: Command errored out with exit status 1:
       command: /home/joel/.virtualenvs/pro1/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-resolver-xcdrz9mh/psutil/setup.py'"'"'; __file__='"'"'/tmp/pip-resolver-xcdrz9mh/psutil/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-_s_8s792
           cwd: /tmp/pip-resolver-xcdrz9mh/psutil/
      Complete output (11 lines):
      Traceback (most recent call last):
        File "<string>", line 1, in <module>
        File "/home/joel/.virtualenvs/pro1/lib/python3.8/site-packages/setuptools/__init__.py", line 18, in <module>
          from setuptools.dist import Distribution
        File "/home/joel/.virtualenvs/pro1/lib/python3.8/site-packages/setuptools/dist.py", line 32, in <module>
          from setuptools import windows_support
        File "/home/joel/.virtualenvs/pro1/lib/python3.8/site-packages/setuptools/windows_support.py", line 2, in <module>
          import ctypes
        File "/home/joel/.pyenv/versions/3.8.0/lib/python3.8/ctypes/__init__.py", line 7, in <module>
          from _ctypes import Union, Structure, Array
      ModuleNotFoundError: No module named '_ctypes'
      ----------------------------------------
Traceback (most recent call last):
  File "/home/joel/.virtualenvs/pro1/bin/pip-compile", line 8, in <module>
    sys.exit(cli())
  File "/home/joel/.virtualenvs/pro1/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/joel/.virtualenvs/pro1/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/joel/.virtualenvs/pro1/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/joel/.virtualenvs/pro1/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/joel/.virtualenvs/pro1/lib/python3.8/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/joel/.virtualenvs/pro1/lib/python3.8/site-packages/piptools/scripts/compile.py", line 458, in cli
    results = resolver.resolve(max_rounds=max_rounds)
  File "/home/joel/.virtualenvs/pro1/lib/python3.8/site-packages/piptools/resolver.py", line 173, in resolve
    has_changed, best_matches = self._resolve_one_round()
  File "/home/joel/.virtualenvs/pro1/lib/python3.8/site-packages/piptools/resolver.py", line 278, in _resolve_one_round
    their_constraints.extend(self._iter_dependencies(best_match))
  File "/home/joel/.virtualenvs/pro1/lib/python3.8/site-packages/piptools/resolver.py", line 388, in _iter_dependencies
    dependencies = self.repository.get_dependencies(ireq)
  File "/home/joel/.virtualenvs/pro1/lib/python3.8/site-packages/piptools/repositories/local.py", line 75, in get_dependencies
    return self.repository.get_dependencies(ireq)
  File "/home/joel/.virtualenvs/pro1/lib/python3.8/site-packages/piptools/repositories/pypi.py", line 231, in get_dependencies
    self._dependencies_cache[ireq] = self.resolve_reqs(
  File "/home/joel/.virtualenvs/pro1/lib/python3.8/site-packages/piptools/repositories/pypi.py", line 184, in resolve_reqs
    results = resolver._resolve_one(reqset, ireq)
  File "/home/joel/.virtualenvs/pro1/lib/python3.8/site-packages/pip/_internal/resolution/legacy/resolver.py", line 388, in _resolve_one
    abstract_dist = self._get_abstract_dist_for(req_to_install)
  File "/home/joel/.virtualenvs/pro1/lib/python3.8/site-packages/pip/_internal/resolution/legacy/resolver.py", line 340, in _get_abstract_dist_for
    abstract_dist = self.preparer.prepare_linked_requirement(req)
  File "/home/joel/.virtualenvs/pro1/lib/python3.8/site-packages/pip/_internal/operations/prepare.py", line 482, in prepare_linked_requirement
    abstract_dist = _get_prepared_distribution(
  File "/home/joel/.virtualenvs/pro1/lib/python3.8/site-packages/pip/_internal/operations/prepare.py", line 91, in _get_prepared_distribution
    abstract_dist.prepare_distribution_metadata(finder, build_isolation)
  File "/home/joel/.virtualenvs/pro1/lib/python3.8/site-packages/pip/_internal/distributions/sdist.py", line 40, in prepare_distribution_metadata
    self.req.prepare_metadata()
  File "/home/joel/.virtualenvs/pro1/lib/python3.8/site-packages/pip/_internal/req/req_install.py", line 555, in prepare_metadata
    self.metadata_directory = self._generate_metadata()
  File "/home/joel/.virtualenvs/pro1/lib/python3.8/site-packages/pip/_internal/req/req_install.py", line 530, in _generate_metadata
    return generate_metadata_legacy(
  File "/home/joel/.virtualenvs/pro1/lib/python3.8/site-packages/pip/_internal/operations/build/metadata_legacy.py", line 70, in generate_metadata
    call_subprocess(
  File "/home/joel/.virtualenvs/pro1/lib/python3.8/site-packages/pip/_internal/utils/subprocess.py", line 242, in call_subprocess
    raise InstallationError(exc_msg)
pip._internal.exceptions.InstallationError: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Makefile:41: recipe for target 'compile_install_requirements' failed
make: *** [compile_install_requirements] Error 1

0 个答案:

没有答案