使用 virtualenvwrapper 创建 python2.7,2.5 版本的虚拟环境均报错 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
SimWit
V2EX    Python

使用 virtualenvwrapper 创建 python2.7,2.5 版本的虚拟环境均报错

  •  
  •   SimWit 2020-01-08 15:49:34 +08:00 3229 次点击
    这是一个创建于 2161 天前的主题,其中的信息可能已经有所发展或是发生改变。

    环境

    virtualenv 16.7.9 virtualenvwrapper-win 1.2.5 

    报错信息

    2.5

    Running virtualenv with interpreter E:\Software\Python\Python25\python.exe e:\software\python\python38\lib\site-packages\virtualenv.py:432: Warning: 'with' will become a reserved keyword in Python 2.6 File "e:\software\python\python38\lib\site-packages\virtualenv.py", line 432 with open(dest, "wb") as f: ^ SyntaxError: invalid syntax 

    2.7

    Cleaning up... Removed build tracker 'c:\\users\\\xb9\xf9\xea\xbb\xc7\xbf\\appdata\\local\\temp\\pip-req-tracker-dd3usp' ERROR: Exception: Traceback (most recent call last): File "e:\software\python\python38\lib\site-packages\virtualenv_support\pip-19.3.1-py2.py3-none-any.whl\pip\_internal\cli\base_command.py", line 153, in _main status = self.run(options, args) File "e:\software\python\python38\lib\site-packages\virtualenv_support\pip-19.3.1-py2.py3-none-any.whl\pip\_internal\commands\install.py", line 382, in run resolver.resolve(requirement_set) File "e:\software\python\python38\lib\site-packages\virtualenv_support\pip-19.3.1-py2.py3-none-any.whl\pip\_internal\legacy_resolve.py", line 201, in resolve self._resolve_one(requirement_set, req) File "e:\software\python\python38\lib\site-packages\virtualenv_support\pip-19.3.1-py2.py3-none-any.whl\pip\_internal\legacy_resolve.py", line 365, in _resolve_one abstract_dist = self._get_abstract_dist_for(req_to_install) File "e:\software\python\python38\lib\site-packages\virtualenv_support\pip-19.3.1-py2.py3-none-any.whl\pip\_internal\legacy_resolve.py", line 311, in _get_abstract_dist_for req.populate_link(self.finder, upgrade_allowed, self.require_hashes) File "e:\software\python\python38\lib\site-packages\virtualenv_support\pip-19.3.1-py2.py3-none-any.whl\pip\_internal\req\req_install.py", line 225, in populate_link self.link = finder.find_requirement(self, upgrade) File "e:\software\python\python38\lib\site-packages\virtualenv_support\pip-19.3.1-py2.py3-none-any.whl\pip\_internal\index.py", line 879, in find_requirement req.name, specifier=req.specifier, hashes=hashes, File "e:\software\python\python38\lib\site-packages\virtualenv_support\pip-19.3.1-py2.py3-none-any.whl\pip\_internal\index.py", line 861, in find_best_candidate candidates = self.find_all_candidates(project_name) File "e:\software\python\python38\lib\site-packages\virtualenv_support\pip-19.3.1-py2.py3-none-any.whl\pip\_internal\index.py", line 791, in find_all_candidates collected_links = self._link_collector.collect_links(project_name) File "e:\software\python\python38\lib\site-packages\virtualenv_support\pip-19.3.1-py2.py3-none-any.whl\pip\_internal\collector.py", line 509, in collect_links self.find_links, expand_dir=True, File "e:\software\python\python38\lib\site-packages\virtualenv_support\pip-19.3.1-py2.py3-none-any.whl\pip\_internal\collector.py", line 408, in group_locations sort_path(os.path.join(path, item)) File "e:\software\python\python38\lib\site-packages\virtualenv_support\pip-19.3.1-py2.py3-none-any.whl\pip\_internal\collector.py", line 389, in sort_path if mimetypes.guess_type(url, strict=False)[0] == 'text/html': File "E:\Software\Python\Python27\Lib\mimetypes.py", line 297, in guess_type init() File "E:\Software\Python\Python27\Lib\mimetypes.py", line 358, in init db.read_windows_registry() File "E:\Software\Python\Python27\Lib\mimetypes.py", line 258, in read_windows_registry for subkeyname in enum_types(hkcr): File "E:\Software\Python\Python27\Lib\mimetypes.py", line 249, in enum_types ctype = ctype.encode(default_encoding) # omit in 3.x! UnicodeDecodeError: 'ascii' codec can't decode byte 0xb1 in position 9: ordinal not in range(128) -------------------------------------------------------------------------- ...Installing setuptools, pip, wheel...done. Traceback (most recent call last): File "e:\software\python\python38\lib\site-packages\virtualenv.py", line 2634, in <module> main() File "e:\software\python\python38\lib\site-packages\virtualenv.py", line 870, in main symlink=options.symlink, File "e:\software\python\python38\lib\site-packages\virtualenv.py", line 1179, in create_environment install_wheel(to_install, py_executable, search_dirs, download=download) File "e:\software\python\python38\lib\site-packages\virtualenv.py", line 1023, in install_wheel _install_wheel_with_search_dir(download, project_names, py_executable, search_dirs) File "e:\software\python\python38\lib\site-packages\virtualenv.py", line 1116, in _install_wheel_with_search_dir call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=script) File "e:\software\python\python38\lib\site-packages\virtualenv.py", line 963, in call_subprocess raise OSError("Command {} failed with error code {}".format(cmd_desc, proc.returncode)) OSError: Command E:\Software\Python\E...7\Scripts\python.exe - setuptools pip wheel failed with error code 2 
    6 条回复    2020-01-13 11:25:10 +08:00
    nznd
        1
    nznd  
       2020-01-08 17:14:54 +08:00
    拿 3.8 的 virtualenvwrapper 创建 2 的 env...
    建议换个版本试试(指 python2 的
    SimWit
        2
    SimWit  
    OP
       2020-01-08 18:14:22 +08:00
    @nznd 谢谢。问题好像不在于此。通过查找 2.7 的问题在于字符集的问题。解决办法来自:“https://www.cnblogs.com/ingd/p/6185347.html”。
    2.5 的话,根据官网,对于 virtualenvwrapper 测试范围为 2.6~3.6 没有问题,所以很有可能是不支持创建 2.5 版本的虚拟环境。但是我使用的是 virtualenvwrapper-win 好像有些不一样。
    而针对版本来说,我使用 python2.7.17,安装 virtualenvwrapper,创建 2.5 的环境,仍报相同的错误。
    kayseen
        3
    kayseen  
       2020-01-08 20:22:45 +08:00
    这个工具我之前也遇到过类似的问题,后来建环境直接使用`python -m`也挺方便
    dxySheldon
        4
    dxySheldon  
       2020-01-08 20:28:03 +08:00 via Android
    要不试试 anaconda 创建虚拟环境
    mailmac
        5
    mailmac  
       2020-01-09 08:44:59 +08:00 via Android   1
    python -m venv .
    解君愁!! 早都不用 virtual 了。
    SimWit
        6
    SimWit  
    OP
       2020-01-13 11:25:10 +08:00 via Android
    谢谢,我之前不知道 venv,让我了解一下
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     1582 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 45ms UTC 00:00 PVG 08:00 LAX 16:00 JFK 19:00
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86