【问题标题】:No module named setuptools没有名为 setuptools 的模块
【发布时间】:2014-04-27 04:52:24
【问题描述】:

我想安装 twilio 的安装文件。当我通过给定的命令安装它时,它给了我一个错误:

没有名为 setuptools 的模块。

你能告诉我该怎么做吗?

我正在使用python 2.7

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Python27>python D:\test\twilio-twilio-python-26f6707\setup.py install
Traceback (most recent call last):
  File "D:\test\twilio-twilio-python-26f6707\setup.py", line 2, in <module>
    from setuptools import setup, find_packages
ImportError: No module named setuptools

【问题讨论】:

  • ...但是标题很容易用谷歌搜索...我最喜欢的答案目前是this one
  • 我投票支持重新打开,因为我在 Ubuntu 14.04 上遇到了这个问题,这不是由于安装程序的 x86 / x64 冲突。简而言之,我只需要安装 pip - sudo apt-get install python-pip
  • 对于其他有同样问题的人:我在尝试为 Azure walinuxagent 运行 setup.py 脚本时遇到了这个问题。

标签: python python-2.7 setup.py


【解决方案1】:

安装setuptools,然后重试。

尝试命令:

sudo apt-get install -y python-setuptools

【讨论】:

  • 我本来打算投票给您,因为您没有提供安装 setuptools 的命令,但您确实需要访问该 URL 以查看如何在您的特定系统上安装它。
  • Debian/ubuntu: apt-get install -y python-setuptools
  • 使用apt install --no-install-recommends ...优化 docker 构建文件时出现此问题
【解决方案2】:

对于 ubuntu 用户,可能会出现此错误,因为 setuptool 未在系统范围内安装。只需使用以下命令安装 setuptool:

sudo apt-get install -y python-setuptools

对于python3:

sudo apt-get install -y python3-setuptools

之后,再次正常安装你的包,使用

sudo python setup.py install

就是这样。

【讨论】:

  • 对于 Python 3,使用 sudo apt-get install -y python3-setuptools
  • 我仍然收到“ImportError: No module named setuptools”。我还打开了一个新的命令外壳。
【解决方案3】:

对于 Python 运行此命令

apt-get install -y python-setuptools

对于 Python 3。

apt-get install -y python3-setuptools

【讨论】:

    【解决方案4】:

    用于安装和管理 Python 包的PyPA recommended 工具是pippip 包含在 Python 3.4 (PEP 453) 中,但对于旧版本,这里是 how to install 它(在 Windows 上,使用 Python 3.3):

    下载https://bootstrap.pypa.io/get-pip.py

    >c:\Python33\python.exe get-pip.py
    Downloading/unpacking pip
    Downloading/unpacking setuptools
    Installing collected packages: pip, setuptools
    Successfully installed pip setuptools
    Cleaning up...
    

    示例用法:

    >c:\Python33\Scripts\pip.exe install pymysql
    Downloading/unpacking pymysql
    Installing collected packages: pymysql
    Successfully installed pymysql
    Cleaning up...
    

    在你的情况下是这样的(似乎pip 缓存独立于 Python 版本):

    C:\Python27>python.exe \code\Python\get-pip.py
    Requirement already up-to-date: pip in c:\python27\lib\site-packages
    Collecting wheel
      Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
        100% |################################| 69kB 255kB/s
    Installing collected packages: wheel
    Successfully installed wheel-0.29.0
    
    C:\Python27>cd Scripts
    
    C:\Python27\Scripts>pip install twilio
    Collecting twilio
      Using cached twilio-5.3.0.tar.gz
    Collecting httplib2>=0.7 (from twilio)
      Using cached httplib2-0.9.2.tar.gz
    Collecting six (from twilio)
      Using cached six-1.10.0-py2.py3-none-any.whl
    Collecting pytz (from twilio)
      Using cached pytz-2015.7-py2.py3-none-any.whl
    Building wheels for collected packages: twilio, httplib2
      Running setup.py bdist_wheel for twilio ... done
      Stored in directory: C:\Users\Cees.Timmerman\AppData\Local\pip\Cache\wheels\e0\f2\a7\c57f6d153c440b93bd24c1243123f276dcacbf43cc43b7f906
      Running setup.py bdist_wheel for httplib2 ... done
      Stored in directory: C:\Users\Cees.Timmerman\AppData\Local\pip\Cache\wheels\e1\a3\05\e66aad1380335ee0a823c8f1b9006efa577236a24b3cb1eade
    Successfully built twilio httplib2
    Installing collected packages: httplib2, six, pytz, twilio
    Successfully installed httplib2-0.9.2 pytz-2015.7 six-1.10.0 twilio-5.3.0
    

    【讨论】:

      【解决方案5】:

      对于python3是:

      sudo apt-get install -y python3-setuptools
      

      【讨论】:

        【解决方案6】:

        问题提到了 Windows,并且接受的答案也适用于 Ubuntu,但对于那些发现这个问题来自 Redhat 风格的 Linux 的人来说,这就是诀窍:

        sudo yum install -y python-setuptools
        

        【讨论】:

          【解决方案7】:

          安装特定版本:

          pip install python-setuptools
          

          升级 python-setuptools

          sudo pip3 install --upgrade python-setuptools
          

          在 Window 10 中出现依赖错误 使用代码:easy_install 而不是 pip install

          easy_install python-setuptools 
          

          使用简易安装升级

          sudo easy_install --upgrade  python-setuptools
          

          在 OSX 系统上安装模块: 使用代码:brew install 而不是 pip install

          brew install python-setuptools 
          

          不使用点子:

           sudo apt-get install -y python-setuptools 
          

          在 CentOS7 或 Linux Fedora 上:

          yum -y install python-setuptools 
          

          或者在 Fedora 上试试

          sudo dnf install python-setuptools 
          

          如果 Homebrew 在 macOS 上搞砸了你的路径,则命令:

          python -m pip install python-setuptools 
          

          适用于 Python3 MacOs Homebrew 螺丝

          python3 -m pip install python-setuptools
          

          从列表 MacO 中验证模块

          pip freeze | grep  python-setuptools
          

          在 Anaconda 上作为你的 python 包管理器执行

           conda install -c anaconda python-setuptools 
          

          【讨论】:

            猜你喜欢
            • 2020-02-24
            • 2017-11-12
            • 2022-11-10
            • 1970-01-01
            • 2013-01-03
            • 1970-01-01
            • 1970-01-01
            • 2018-07-12
            • 2018-07-13
            相关资源
            最近更新 更多