0

我正在尝试安装 yfinance “sudo -H pip install yfinance”,并在这篇文章的底部不断出现以下错误。我已经卸载/安装了 pip。我已经通过 pip 卸载/安装了 setuptools 并尝试了以下命令:

python3 -m ensurepip --upgrade

Requirement already up-to-date: setuptools in /usr/local/lib/python3.8/site-packages (49.2.0)

Requirement already up-to-date: pip in /usr/local/lib/python3.8/site-packages (20.1.1)

pip install --upgrade pip

Requirement already up-to-date: pip in /usr/local/lib/python3.8/site-packages (20.1.1)

pip install --upgrade setuptools

Requirement already up-to-date: setuptools in /usr/local/lib/python3.8/site-packages (49.2.0)

蟒蛇版本

python --version

Python 3.8.3

点子版本

pip --version

pip 20.1.1 from /usr/local/lib/python3.8/site-packages/pip (python 3.8)

系统更新检查

sudo apt-get upgrade
sudo apt-get update

下面是我运行“sudo -H pip install yfinance”时的实际错误代码

*****@*******:~/Desktop/Project$ sudo -H pip install yfinance

Collecting yfinance

  Using cached yfinance-0.1.54.tar.gz (19 kB)

    ERROR: Command errored out with exit status 1:

     command: /usr/local/bin/python3.8 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-xpuca0pe/yfinance/setup.py'"'"'; __file__='"'"'/tmp/pip-install-xpuca0pe/yfinance/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-1j4zanh6

         cwd: /tmp/pip-install-xpuca0pe/yfinance/

    Complete output (11 lines):

    Traceback (most recent call last):

      File "<string>", line 1, in <module>

      File "/usr/local/lib/python3.8/site-packages/setuptools/__init__.py", line 23, in <module>
        from setuptools.dist import Distribution

      File "/usr/local/lib/python3.8/site-packages/setuptools/dist.py", line 34, in <module>
        from setuptools import windows_support

      File "/usr/local/lib/python3.8/site-packages/setuptools/windows_support.py", line 2, in <module>
        import ctypes

      File "/usr/local/lib/python3.8/ctypes/__init__.py", line 7, in <module>
        from _ctypes import Union, Structure, Array

    ModuleNotFoundError: No module named '_ctypes'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

如何修复此错误?

4

1 回答 1

0

运行此命令后,它修复了错误。

参考:https ://packaging.python.org/tutorials/installing-packages/

sudo -H python -m pip install --upgrade pip setuptools wheel
于 2020-07-13T01:39:50.643 回答