首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >未能安装python:"UnboundLocalError:赋值前引用的局部变量'distclass‘“

未能安装python:"UnboundLocalError:赋值前引用的局部变量'distclass‘“
EN

Stack Overflow用户
提问于 2016-04-01 17:20:21
回答 1查看 145关注 0票数 0

我正在尝试安装python-chess (Windows7上的Python2.7)。

我得到以下错误:

代码语言:javascript
复制
C:\Users\Jeroen>pip install python-chess
Collecting python-chess
c:\python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\util\ssl_.py:315: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may caus
e the server to present an incorrect TLS certificate, which can cause validation failures. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning.
  SNIMissingWarning
c:\python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\util\ssl_.py:120: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL con
nections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Using cached python-chess-0.13.2.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "c:\users\jeroen\appdata\local\temp\pip-build-2eph1o\python-chess\setup.py", line 91, in <module>
        "Topic :: Software Development :: Libraries :: Python Modules",
      File "c:\python27\lib\distutils\core.py", line 98, in setup
        klass = distclass
    UnboundLocalError: local variable 'distclass' referenced before assignment

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in c:\users\jeroen\appdata\local\temp\pip-build-2eph1o\python-chess\

当我再次重新运行pip install python-chess时,SNIMissingWarning不再出现,但是UnboundLocalError仍然存在。

编辑

对评论中的问题的答复:

代码语言:javascript
复制
Python 2.7.3 |EPD_free 7.3-2 (32-bit)| (default, Apr 12 2012, 14:30:37) [MSC v.1500 32 bit (Intel)] on win32
Type "credits", "demo" or "enthought" for more information.
>>> import distutils
>>> print distutils.__version__
2.7.3
>>>

第90行附近的C:\Python27\Lib\distutils\core.py如下所示:

代码语言:javascript
复制
global _setup_stop_after, _setup_distribution

# Determine the distribution class -- either caller-supplied or
# our Distribution (see below).
klass = distclass
if klass:
    del distclass
else:
    klass = Distribution

if 'script_name' not in attrs:
    script_name = os.path.basename(sys.argv[0])
if 'script_args' not in attrs:
    script_args = sys.argv[1:]
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-04-01 17:49:52

正如Martijn Pieters在注释中正确推断的那样,我的Python安装以某种方式损坏。我安装了Python的最新版本(2.7.11),现在一切正常。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36362253

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档