简体   繁体   English

在Mac上创建应用程序时无法启用Python虚拟环境

[英]can't enable the Python virtual environment while creating an app on Mac

I am following instruction to create Mac app with Python. 我正在按照说明使用Python创建Mac应用。 I was installing Virtualenv as a part of it, as here says. 我安装VIRTUALENV作为它的一部分,因为在这里说。 I successfully did till second step; 我成功地做到了第二步。 pip install, bash_profile. pip安装,bash_profile。 But when I try to Enable the virtual environment part, I get a. 但是当我尝试启用虚拟环境部分时,我得到了。 no file or directory / b&c. 没有文件或目录/ b&c。 command not found, for each step. 对于每个步骤,找不到命令。

By the way, this is the first time I heard .bash_profile, so the script is empty except what I did at the second step. 顺便说一句,这是我第一次听到.bash_profile,因此该脚本为空,除了我在第二步中所做的。

How can I fix the problem? 我该如何解决该问题?

Follow simple steps 遵循简单的步骤

  1. pip install virtualenv
  2. virtualenv venv # venv is your desired name virtualenv venv #venv是您想要的名称
  3. source venv/bin/activate

I suggest you read Virtualenv User Guide . 我建议您阅读《 Virtualenv用户指南》

  1. Install virtualenv by using pip install virtualenv 使用pip install virtualenv

  2. virtualenv ENV to create virtual environment. virtualenv ENV创建虚拟环境。

    Where ENV is a directory to place the new virtual environment. ENV是放置新虚拟环境的目录。

  3. source bin/activate to activate script. source bin/activate激活脚本。

  4. And type deactivate to undo the changes. 并键入deactivate以撤消更改。

virtualenvwrapper 虚拟环境包装器

Add three lines to your shell startup file ( .bashrc , .profile , etc.) to set the location where the virtual environments should live, the location of your development project directories, and the location of the script installed with this package: 在外壳启动文件中添加三行( .bashrc.profile等),以设置虚拟环境应驻留的位置,开发项目目录的位置以及与此软件包一起安装的脚本的位置:

export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Devel
source /usr/local/bin/virtualenvwrapper.sh

Run source ~/.bashrc to reload the startup file. 运行source ~/.bashrc以重新加载启动文件。

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

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