如何使用python3创建虚拟环境

编程入门 行业动态 更新时间:2024-10-28 14:36:32
本文介绍了如何使用python3创建虚拟环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用 python 2.7 + virtualenv版本1.10.1 来运行myproject项目。由于其他一些项目要求,我必须使用其他版本的python( Python 3.5 )和 Django 1.9 。为此,我在用户目录中安装了python。另外,我已将virtualenv( version-15.1.0 )下载并安装到我的用户目录中。 但是每当我尝试创建虚拟环境时,都会出现以下错误

I am using python 2.7 + virtualenv version 1.10.1 for running myproject projects. Due to some other projects requirement I have to work with other version of python(Python 3.5) and Django 1.9. For this I have installed python in my user directory. Also I have dowloaded and installed virtualenv( version - 15.1.0) into my user directory. But whenever I am trying to create virtual env I am getting the below error

python virtualenv/virtualenv.py myproject

Using base prefix '/home/myuser/python3' New python executable in /home/mount/myuser/project_python3/myproject/bin/python ERROR: The executable /home/mount/myuser/project_python3/myproject/bin/python is not functioning ERROR: It thinks sys.prefix is '/home/myuser/python3' (should be '/home/mount/myuser/project_python3/myproject') ERROR: virtualenv is not compatible with this system or executable

有人可以告诉我我在做什么错事

Can anybody tell what I am doing wrong with this

推荐答案

在Python 3.6及更高版本中,不建议使用pyvenv模块。改为使用以下单线:

In Python 3.6+, the pyvenv module is deprecated. Use the following one-liner instead:

python3 -m venv <myenvname>

这是推荐的方式由Python社区创建虚拟环境。

This is the recommended way to create virtual environments by the Python community.

更多推荐

如何使用python3创建虚拟环境

本文发布于:2023-06-08 14:31:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/583117.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   环境

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!