export WORKON_HOME=$HOME/.virtualenvsexport PROJECT_HOME=$HOME/django_projects #Not very important -- mkproject command uses this#Added the following based on:#http://stackoverflow.com/questions/19665327/virtualenvwrapper-installation-snow-leopard-pythonexport VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python2.7#source /usr/local/bin/virtualenvwrapper.shsource /Library/Frameworks/Python.framework/Versions/2.7/bin/virtualenvwrapper.sh
$ mkvirtualenv -p /usr/local/bin/python3.2 my_envRunning virtualenv with interpreter /usr/local/bin/python3New python executable in my_env/bin/pythonInstalling setuptools, pip...done.Usage: source deactivate
removes the 'bin' directory of the environment activated with 'sourceactivate' from PATH.
venv/bin/python
Python 3.5.1 (v3.5.1:37a07cee5969, Dec 5 2015, 21:12:44)[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwinType "help", "copyright", "credits" or "license" for more information.>>>
MacBook-Pro-2:~ admin$ virtualenv venv3 --python=`which python3`Running virtualenv with interpreter /usr/local/bin/python3Using base prefix '/Library/Frameworks/Python.framework/Versions/3.6'New python executable in /Users/admin/venv3/bin/python3Also creating executable in /Users/admin/venv3/bin/pythonInstalling setuptools, pip, wheel...done.MacBook-Pro-2:~ admin$MacBook-Pro-2:~ admin$ ls venv3/bin/activate easy_install pip3.6 python3.6activate.csh easy_install-3.6 python wheelactivate.fish pip python-configactivate_this.py pip3 python3MacBook-Pro-2:~ admin$
检查Python安装位置
MacBook-Pro-2:~ admin$ which python2/usr/local/bin/python2MacBook-Pro-2:~ admin$MacBook-Pro-2:~ admin$ which python3/usr/local/bin/python3MacBook-Pro-2:~ admin$
以下是如何在Visual Studio Code文件夹中创建虚拟环境的分步操作:我使用Powershell(管理员模式): 1.我创建了一个VSCode文件夹-“D:\Code_Python_VE”,我想在其中创建虚拟环境。 2.接下来,我键入命令-"Pip3安装虚拟环境"。(D:\Code_Python_VE>Pip3安装虚拟环境)3. D:\Code_Python_VE>python3-m venvproject_env 4. D:\Code_Python_VE>project_env\脚本\activate.bat 5. D:\Code_Python_VE>ls-这将列出一个新的目录“project_env”。 6. D:\Code_Python_VE>代码。这将启动Visual Studio Code。确保命令是(code.)。 7.创建包含以下内容的launch.jason:
{// Use IntelliSense to learn about possible attributes.// Hover to view descriptions of existing attributes.// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387"version": "0.2.0","configurations": [{"type": "python","request": "launch","name": "Python: Current File (Integrated Terminal 1)","program": "${file}"},{"name": "Python: Current File (Integrated Terminal 2)","type": "python","request": "launch","program": "${file}","console": "integratedTerminal"}]}
cd /mnt/Vancouver/apps/python_versions/src/Python-3.7.4/time ./configure ## 17 sectime make ## 1 min 51 sectime sudo make install ## 18 sectime make clean ## 0.3 sec
检查已安装的Python版本:
$ which python/usr/bin/python
$ python --versionPython 3.8.0
$ which python3.7/usr/local/bin/python3.7
$ python ## Python 3.8 [system / env]Python 3.8.0 (default, Oct 23 2019, 18:51:26)[GCC 9.2.0] on linuxType "help", "copyright", "credits" or "license" for more information.>>>
$ python3.7 ## newly-installed Python 3.7 packagePython 3.7.4 (default, Nov 20 2019, 11:36:53)[GCC 9.2.0] on linuxType "help", "copyright", "credits" or "license" for more information.>>> import sys>>> print(sys.version)3.7.4 (default, Nov 20 2019, 11:36:53)[GCC 9.2.0]>>>
$ python3.7 --versionPython 3.7.4