我一直没有问这个问题,因为我觉得我一定是犯了一些脑残的错误。经过几个星期的努力,我仍然无法解决这个问题。
当我尝试导入 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 3.x+ 中,urllib 已被分离为 urllib.request、urllib.error 等。这可能是您的问题。
