当前位置: 首页 > 工具软件 > py2deb > 使用案例 >

【Python问题】“python setup.py egg_info“ failed with error code 1

连德义
2023-12-01

“python setup.py egg_info” failed with error code 1

前言

学习python就是要解决基本工作需要,开始解决办公需要,excel,world,ppt等问题;所以尝试使用pandas,基本可以解决一些问题;

当我安装pandas时后,发现如下问题:

cooper@cooper:~$ pip install pandas
Collecting pandas
  Downloading https://files.pythonhosted.org/packages/58/58/b729eda34f78060e14cb430c91d4f7ba3cf1e34797976877a3a1125ea5b2/pandas-1.3.4.tar.gz (4.7MB)
    100% |████████████████████████████████| 4.7MB 285kB/s 
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-cFeCgz/pandas/setup.py", line 249
        f"{extension}-source file '{sourcefile}' not found.\n"
                                                             ^
    SyntaxError: invalid syntax
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-cFeCgz/pandas/
You are using pip version 8.1.1, however version 21.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

安装失败,然后尝试提示的命令,依然失败

cooper@cooper:~$ pip install --upgrade pip
Collecting pip
  Using cached https://files.pythonhosted.org/packages/00/5f/d6959d6f25f202e3e68e3a53b815af42d770c829c19382d0acbf2c3e2112/pip-21.3.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-PQleJF/pip/setup.py", line 7
        def read(rel_path: str) -> str:
                         ^
    SyntaxError: invalid syntax
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-PQleJF/pip/
You are using pip version 8.1.1, however version 21.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

重新安装pip

cooper@cooper:~$ curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1863k  100 1863k    0     0  2768k      0 --:--:-- --:--:-- --:--:-- 2768k
cooper@cooper:~$ sudo python get-pip.py --force-reinstall
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
WARNING: The directory '/home/cooper/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pip<21.0
  Downloading pip-20.3.4-py2.py3-none-any.whl (1.5 MB)
     |████████████████████████████████| 1.5 MB 1.1 MB/s 
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 8.1.1
    Uninstalling pip-8.1.1:
      Successfully uninstalled pip-8.1.1
Successfully installed pip-20.3.4

安装成功后,查看一下pip --verison 找不到;

cooper@cooper:~$ pip --version
bash: /usr/bin/pip: No such file or directory
cooper@cooper:~$ hash -r
cooper@cooper:~$ sudo apt-get update
Get:1 http://packages.microsoft.com/repos/code stable InRelease [10.4 kB]
Hit:2 http://dl.google.com/linux/chrome/deb stable InRelease                                                                                                      
Get:3 http://packages.microsoft.com/repos/code stable/main amd64 Packages [50.9 kB]                                                                        
Get:4 http://packages.microsoft.com/repos/code stable/main arm64 Packages [51.8 kB]                                                    
Get:5 http://packages.microsoft.com/repos/code stable/main armhf Packages [51.6 kB]
Hit:6 http://cn.archive.ubuntu.com/ubuntu xenial InRelease                                            
Get:7 http://security.ubuntu.com/ubuntu xenial-security InRelease [109 kB]
Get:8 http://cn.archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB]        
Get:9 http://security.ubuntu.com/ubuntu xenial-security/main amd64 DEP-11 Metadata [93.6 kB]
Get:10 http://cn.archive.ubuntu.com/ubuntu xenial-backports InRelease [107 kB]
Get:11 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 DEP-11 Metadata [130 kB]
Get:12 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 DEP-11 Metadata [327 kB]
Get:13 https://esm.ubuntu.com/infra/ubuntu xenial-infra-security InRelease [7,509 B]
Get:14 http://security.ubuntu.com/ubuntu xenial-security/multiverse amd64 DEP-11 Metadata [2,468 B]                     
Get:15 https://esm.ubuntu.com/infra/ubuntu xenial-infra-updates InRelease [7,475 B]                                 
Get:16 http://cn.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 DEP-11 Metadata [281 kB]
Get:17 http://cn.archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 DEP-11 Metadata [5,964 B]  
Get:18 http://cn.archive.ubuntu.com/ubuntu xenial-backports/main amd64 DEP-11 Metadata [3,328 B]
Get:19 http://cn.archive.ubuntu.com/ubuntu xenial-backports/universe amd64 DEP-11 Metadata [6,608 B]
Fetched 1,355 kB in 2s (514 kB/s)                                            
Reading package lists... Done
cooper@cooper:~$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done

*The following packages could receive security updates with UA Infra: ESM service enabled:
  libpam0g libdjvulibre-text bluez libwebp5 libqpdf21 gstreamer1.0-alsa intel-microcode linux-libc-dev vim-common libx11-xcb-dev libcurl3 libxml2-utils libgrilo-0.2-1 gstreamer1.0-plugins-base-apps libpam-modules openssl bluez-cups ntfs-3g git-man libsystemd0 linux-image-generic-hwe-16.04 libgd3 libavahi-glib1 binutils squashfs-tools linux-signed-generic-hwe-16.04 linux-generic-hwe-16.04 libavahi-common-data libavahi-common3 libpython3.5 python3.5 git python3.5-minimal udev gstreamer1.0-plugins-base libpam-runtime isc-dhcp-common libx11-6 libudev1 libwebpdemux1 libavahi-ui-gtk3-0 libaspell15 apport python3-apport avahi-daemon systemd-sysv libavahi-core7 libgcrypt20 vim-runtime liblz4-1 vim libpam-systemd libgstreamer-plugins-base1.0-0 distro-info-data libsndfile1 gstreamer1.0-x systemd gir1.2-gst-plugins-base-1.0 libssl-dev libssl-doc libwebpmux1 libpam-modules-bin libx11-data aspell libopenexr22 openssh-client avahi-autoipd libx11-dev qpdf libx11-doc bluez-obexd libdjvulibre21 apport-gtk libxml2 ca-certificates vim-tiny avahi-utils linux-headers-generic-hwe-16.04 libpython3.5-stdlib libbluetooth3 libexiv2-14 libpython3.5-minimal libavahi-client3 curl isc-dhcp-client git-core python3-problem-report libcurl3-gnutls libx11-xcb1 libssl1.0.0
Learn more about UA Infra: ESM service for Ubuntu 16.04 at https://ubuntu.com/16-04

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
cooper@cooper:~$ pip --version
pip 20.3.4 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)
cooper@cooper:~$ 

pip 重新安装成功,然后安装pandas

cooper@cooper:~$ pip install pandas
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pandas in /usr/lib/python2.7/dist-packages (0.17.1)
Requirement already satisfied: python-dateutil in /usr/lib/python2.7/dist-packages (from pandas) (2.4.2)
Requirement already satisfied: pytz>=2011k in /usr/lib/python2.7/dist-packages (from pandas) (2014.10)
Requirement already satisfied: numpy>=1.7.0 in /usr/lib/python2.7/dist-packages (from pandas) (1.11.0)
cooper@cooper:~$ 

结束

方法总比困难多,找对方法就可以解决当前的问题;

 类似资料: