mkvirtualenv: command not found 详细有效解决方案!!

hellopython@ubuntu:~$ which python3
/usr/bin/python3
hellopython@ubuntu:~$ mkvirtualenv -p /usr/bin/python3 dm
mkvirtualenv: command not found

参考:https://blog.csdn.net/liu_xzhen/article/details/79293373#commentsedit

执行命令
sudo apt-get install python-virtualenv
sudo easy_install virtualenvwrapper

其中easy_install 出问题了,参考:https://blog.csdn.net/weixin_43256057/article/details/102984840

hellopython@ubuntu:~$ mkdir $HOME/.virtualenvs
hellopython@ubuntu:~$ export WORKON_HOME=$HOME/.virtualenvs
hellopython@ubuntu:~$ source /usr/local/bin/virtualenvwrapper.sh
virtualenvwrapper.user_scripts creating /home/hellopython/.virtualenvs/premkproject
virtualenvwrapper.user_scripts creating /home/hellopython/.virtualenvs/postmkproject
virtualenvwrapper.user_scripts creating /home/hellopython/.virtualenvs/initialize
virtualenvwrapper.user_scripts creating /home/hellopython/.virtualenvs/premkvirtualenv
virtualenvwrapper.user_scripts creating /home/hellopython/.virtualenvs/postmkvirtualenv
virtualenvwrapper.user_scripts creating /home/hellopython/.virtualenvs/prermvirtualenv
virtualenvwrapper.user_scripts creating /home/hellopython/.virtualenvs/postrmvirtualenv
virtualenvwrapper.user_scripts creating /home/hellopython/.virtualenvs/predeactivate
virtualenvwrapper.user_scripts creating /home/hellopython/.virtualenvs/postdeactivate
virtualenvwrapper.user_scripts creating /home/hellopython/.virtualenvs/preactivate
virtualenvwrapper.user_scripts creating /home/hellopython/.virtualenvs/postactivate
virtualenvwrapper.user_scripts creating /home/hellopython/.virtualenvs/get_env_details

hellopython@ubuntu:~$ ls -a
.              .config           .ICEauthority                    .pam_environment  setuptools-33.1.1.zip                  Templates
..             Desktop           .java                            Pictures          snap                                   Videos
.bash_history  Documents         java_error_in_PYCHARM_20211.log  .profile          .ssh                                   .virtualenvs
.bash_logout   Downloads         .local                           Public            sublime_text_3                         .wget-hsts
.bashrc        examples.desktop  .mozilla                         .PyCharm2019.2    sublime_text_3_build_3114_x64.tar.bz2  .xinputrc
.cache         .gnupg            Music                            PycharmProjects   .sudo_as_admin_successful
hellopython@ubuntu:~$ source ~/.bashrc
hellopython@ubuntu:~$ mkvirtualenv -p /usr/bin/python3 dm
Already using interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /home/hellopython/.virtualenvs/dm/bin/python3
Also creating executable in /home/hellopython/.virtualenvs/dm/bin/python
Installing setuptools, pkg_resources, pip, wheel...done.
virtualenvwrapper.user_scripts creating /home/hellopython/.virtualenvs/dm/bin/predeactivate
virtualenvwrapper.user_scripts creating /home/hellopython/.virtualenvs/dm/bin/postdeactivate
virtualenvwrapper.user_scripts creating /home/hellopython/.virtualenvs/dm/bin/preactivate
virtualenvwrapper.user_scripts creating /home/hellopython/.virtualenvs/dm/bin/postactivate
virtualenvwrapper.user_scripts creating /home/hellopython/.virtualenvs/dm/bin/get_env_details
(dm) hellopython@ubuntu:~$ 

就这样成功地创建虚拟环境并进去了。
补充:source xx.sh 是无需权限直接读取xx.sh脚本并运行里面的命令的意思。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
"bash: mkvirtualenv: command not found" 这个错误提示意味着在你的系统中找不到 `mkvirtualenv` 命令。`mkvirtualenv` 是一个用于创建和管理Python虚拟环境的命令,通常与 `virtualenvwrapper` 库一起使用。 要解决这个问题,你可以按照以下步骤进行操作: 1. 确保你已经正确安装了 `virtualenvwrapper` 库。你可以使用以下命令来安装它: ``` pip install virtualenvwrapper ``` 2. 确保你已经将 `virtualenvwrapper` 添加到了你的环境变量中。在大多数情况下,它会自动添加到你的 `.bashrc` 或 `.bash_profile` 文件中。你可以通过运行以下命令来检查: ``` cat ~/.bashrc ``` 如果你没有看到类似于以下内容的行: ``` source /usr/local/bin/virtualwrapper.sh ``` 那么你需要手动将其添加到你的 `.bashrc` 或 `.bash_profile` 文件中。可以使用文本编辑器打开文件,并在文件末尾添加上述行。然后保存文件并重新启动终端。 3. 如果你经安装了 `virtualenvwrapper`,但仍然遇到问题,可能是因为 `virtualenvwrapper` 的安装路径没有正确设置。你可以尝试手动设置 `WORKON_HOME` 环境变量,该变量指定虚拟环境的存储位置。例如,你可以将以下行添加到你的 `.bashrc` 或 `.bash_profile` 文件中: ``` export WORKON_HOME=~/.virtualenvs ``` 然后保存文件并重新启动终端。 请注意,以上步骤假设你正在使用Bash作为你的默认shell。如果你使用的是其他shell,例如Zsh,请相应地修改配置文件。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值