【问题标题】:Unable to load urllib python package无法加载 urllib python 包
【发布时间】:2015-04-10 00:34:18
【问题描述】:

我一直没有问这个问题,因为我觉得我一定犯了一些脑残的错误。经过几周的努力,我仍然无法解决这个问题。

当我尝试导入 urllib 时,我收到 500 内部服务器错误。

我将 urllib 添加到了我的 requirements.txt 文件中。

“git push -a”找不到urllib:

. . .
    remote: Activating virtenv
    remote: Checking for pip dependency listed in requirements.txt file..
. . .
    remote: Collecting urllib (from -r /var/lib/openshift/54c89da2fcf9334d3e00000f/app-root/runtime/repo/requirements.txt (line 1))
    remote:   DEPRECATION: Failed to find 'urllib' at http://mirror1.ops.rhcloud.com/mirror/python/web/simple/urllib/. It is suggested to upgrade your index to support normalized names as the name in /simple/{name}.
    remote:   Could not find any downloads that satisfy the requirement urllib (from -r /var/lib/openshift/54c89da2fcf9334d3e00000f/app-root/runtime/repo/requirements.txt (line 1))
    remote:   No distributions at all found for urllib (from -r /var/lib/openshift/54c89da2fcf9334d3e00000f/app-root/runtime/repo/requirements.txt (line 1))

我已经按照以下说明配置了 virtualenv: https://developers.openshift.com/en/python-getting-started.html#step3

virtenv = os.environ['OPENSHIFT_PYTHON_DIR'] + '/virtenv/'
virtualenv = os.path.join(virtenv, 'bin/activate_this.py')
try:
  # Multi-Line for Python v3.3:
  exec_namespace = dict(__file__=virtualenv)
  with open(virtualenv, 'rb') as exec_file:
    file_contents = exec_file.read()
  compiled_code = compile(file_contents, virtualenv, 'exec')
  exec(compiled_code, exec_namespace)
except IOError:
  pass

非常感谢任何帮助!

【问题讨论】:

    标签: python package push virtualenv


    【解决方案1】:

    在 Python 3.x+ 中,urllib 被分离为 urllib.request、urllib.error 等。这可能是你的问题。

    【讨论】:

    • 感谢 flyjam。沿着这些思路,我刚刚尝试从 urllib 更改为 urllib3,现在它可以工作了!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-11
    • 2019-10-16
    相关资源
    最近更新 更多