简体   繁体   English

无法创建python virtualenv

[英]Cannot create python virtualenv

I'm working on a legacy app that needs python2.6.2. 我正在开发需要python2.6.2的旧版应用程序。 I installed successfully python 2.6.2 and setuptools. 我已成功安装python 2.6.2和setuptools。 Now when I try to create a virtualenv using this version it gives me this error: 现在,当我尝试使用此版本创建virtualenv时,出现以下错误:

$ virtualenv --python=/usr/local/python2.6.2/bin/python mypythonnewapp
Running virtualenv with interpreter /usr/local/python2.6.2/bin/python
New python executable in /home/vagrant/mypythonnewapp/bin/python
Installing setuptools<37, pip, wheel<0.30...
  Complete output from command /home/vagrant/mypythonnewapp/bin/python - setuptools<37 pip wheel<0.30:
  DEPRECATION: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of pip will drop support for Python 2.6
Collecting setuptools<37
Exception:
Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/virtualenv_support/pip-9.0.3-py2.py3-none-any.whl/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/lib/python2.6/site-packages/virtualenv_support/pip-9.0.3-py2.py3-none-any.whl/pip/commands/install.py", line 324, in run
    requirement_set.prepare_files(finder)
  File "/usr/lib/python2.6/site-packages/virtualenv_support/pip-9.0.3-py2.py3-none-any.whl/pip/req/req_set.py", line 380, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "/usr/lib/python2.6/site-packages/virtualenv_support/pip-9.0.3-py2.py3-none-any.whl/pip/req/req_set.py", line 554, in _prepare_file
    require_hashes
  File "/usr/lib/python2.6/site-packages/virtualenv_support/pip-9.0.3-py2.py3-none-any.whl/pip/req/req_install.py", line 278, in populate_link
    self.link = finder.find_requirement(self, upgrade)
  File "/usr/lib/python2.6/site-packages/virtualenv_support/pip-9.0.3-py2.py3-none-any.whl/pip/index.py", line 465, in find_requirement
    all_candidates = self.find_all_candidates(req.name)
  File "/usr/lib/python2.6/site-packages/virtualenv_support/pip-9.0.3-py2.py3-none-any.whl/pip/index.py", line 423, in find_all_candidates
    for page in self._get_pages(url_locations, project_name):
  File "/usr/lib/python2.6/site-packages/virtualenv_support/pip-9.0.3-py2.py3-none-any.whl/pip/index.py", line 568, in _get_pages
    page = self._get_page(location)
  File "/usr/lib/python2.6/site-packages/virtualenv_support/pip-9.0.3-py2.py3-none-any.whl/pip/index.py", line 683, in _get_page
    return HTMLPage.get_page(link, session=self.session)
  File "/usr/lib/python2.6/site-packages/virtualenv_support/pip-9.0.3-py2.py3-none-any.whl/pip/index.py", line 792, in get_page
    "Cache-Control": "max-age=600",
  File "/usr/lib/python2.6/site-packages/virtualenv_support/pip-9.0.3-py2.py3-none-any.whl/pip/_vendor/requests/sessions.py", line 521, in get
    return self.request('GET', url, **kwargs)
  File "/usr/lib/python2.6/site-packages/virtualenv_support/pip-9.0.3-py2.py3-none-any.whl/pip/download.py", line 386, in request
    return super(PipSession, self).request(method, url, *args, **kwargs)
  File "/usr/lib/python2.6/site-packages/virtualenv_support/pip-9.0.3-py2.py3-none-any.whl/pip/_vendor/requests/sessions.py", line 508, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python2.6/site-packages/virtualenv_support/pip-9.0.3-py2.py3-none-any.whl/pip/_vendor/requests/sessions.py", line 618, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python2.6/site-packages/virtualenv_support/pip-9.0.3-py2.py3-none-any.whl/pip/_vendor/cachecontrol/adapter.py", line 37, in send
    cached_response = self.controller.cached_request(request)
  File "/usr/lib/python2.6/site-packages/virtualenv_support/pip-9.0.3-py2.py3-none-any.whl/pip/_vendor/cachecontrol/controller.py", line 111, in cached_request
    resp = self.serializer.loads(request, cache_data)
  File "/usr/lib/python2.6/site-packages/virtualenv_support/pip-9.0.3-py2.py3-none-any.whl/pip/_vendor/cachecontrol/serialize.py", line 114, in loads
    return getattr(self, "_loads_v{0}".format(ver))(request, data)
  File "/usr/lib/python2.6/site-packages/virtualenv_support/pip-9.0.3-py2.py3-none-any.whl/pip/_vendor/cachecontrol/serialize.py", line 196, in _loads_v2
    return self.prepare_response(request, cached)
  File "/usr/lib/python2.6/site-packages/virtualenv_support/pip-9.0.3-py2.py3-none-any.whl/pip/_vendor/cachecontrol/serialize.py", line 157, in prepare_response
    **cached["response"]
TypeError: __init__() keywords must be strings
----------------------------------------
...Installing setuptools<37, pip, wheel<0.30...done.
Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/virtualenv.py", line 2349, in <module>
    main()
  File "/usr/lib/python2.6/site-packages/virtualenv.py", line 712, in main
    symlink=options.symlink)
  File "/usr/lib/python2.6/site-packages/virtualenv.py", line 953, in create_environment
    download=download,
  File "/usr/lib/python2.6/site-packages/virtualenv.py", line 904, in install_wheel
    call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
  File "/usr/lib/python2.6/site-packages/virtualenv.py", line 796, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command /home/vagrant/mypythonnewapp/bin/python - setuptools<37 pip wheel<0.30 failed with error code 2

Any suggestions other than upgrading anything are welcome. 除了升级其他任何建议,我们都欢迎。

Thanks 谢谢

This seems like a bug in virtualenv . 这似乎是virtualenv的错误。 See how virtualenv.py limits versions of setuptools and wheel for Python 2.6, but not for pip . 请参阅virtualenv.py如何限制setuptoolswheel版本以用于Python 2.6,而不是pip It must limit pip to version '<10' for Py 2.6. 对于Py 2.6,必须将pip限制为版本“ <10”。 Please report the bug or better send a pull request. 请报告错误或更好地发送请求请求。

Meanwhile create a virtualenv with --no-pip and later install pip into the virtualenv manually. 同时,使用--no-pip创建一个virtualenv,然后手动将pip安装到virtualenv中。

Try using pyenv . 尝试使用pyenv At least it claims to support versions of Python back to 2.1.3 至少它声称支持Python版本回到2.1.3

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM