英文:
Can't create virtual environment with python 2.7
问题
我尝试在CentOS服务器上使用自定义的Python 2.7.15创建虚拟环境,我按照这个网站的步骤进行操作(https://help.dreamhost.com/hc/en-us/articles/215489338-Installing-and-using-virtualenv-with-Python-2),但是当我使用virtualenv创建Python虚拟环境时出现了一些问题。以下是代码。
$ virtualenv -p /public/home/myname/opt/python-2.7.15/bin/python venv
RuntimeError: failed to query /public/home/myname/opt/python-2.7.15/bin/python with code 1 err: ' File "/public/home/myname/.local/lib/python3.8/site-packages/virtualenv/discovery/py_info.py", line 152\n os.path.join(base_dir, exe) for exe in (f"python{major}", f"python{major}.{minor}")\n ^\nSyntaxError: invalid syntax\n'
我在网上搜索了答案,但未能找到解决方法,有人可以解释发生了什么吗?是Anaconda阻止我创建虚拟环境吗?
我搜索了这个错误,但似乎没有人遇到与我相同的错误。
英文:
I' trying to create a virtual environment with a custom python 2.7.15 on a centOS server,I followed the steps from this website (https://help.dreamhost.com/hc/en-us/articles/215489338-Installing-and-using-virtualenv-with-Python-2),but when I use virtualenv to create a python virtual environment something happens.Here is the code.
$ virtualenv -p /public/home/myname/opt/python-2.7.15/bin/python venv
RuntimeError: failed to query /public/home/myname/opt/python-2.7.15/bin/python with code 1 err: ' File "/public/home/myname/.local/lib/python3.8/site-packages/virtualenv/discovery/py_info.py", line 152\n os.path.join(base_dir, exe) for exe in (f"python{major}", f"python{major}.{minor}")\n ^\nSyntaxError: invalid syntax\n'
I've searched the net for answer but I failed to reach one,can anyone explain what happened? Is the anaconda that prevents me from creating my virtual environment?
I searched the Error but it seems no one came across with the same error I met.
答案1
得分: 0
你必须使用已安装的 Python 2.7 版本的 virtualenv
。安装/升级工具:
$ /public/home/myname/opt/python-2.7.15/bin/python -m pip install --upgrade "pip<21.0"
$ /public/home/myname/opt/python-2.7.15/bin/python -m pip install --upgrade virtualenv
现在创建虚拟环境:
$ /public/home/myname/opt/python-2.7.15/bin/python -m virtualenv venv
英文:
You must use virtualenv
installed for Python 2.7. Install/upgrade tools:
$ /public/home/myname/opt/python-2.7.15/bin/python -m pip install --upgrade "pip<21.0"
$ /public/home/myname/opt/python-2.7.15/bin/python -m pip install --upgrade virtualenv
Now create the venv:
$ /public/home/myname/opt/python-2.7.15/bin/python -m virtualenv venv
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论