简体   繁体   English

-bash: /usr/bin/virtualenvwrapper.sh: 没有那个文件或目录

[英]-bash: /usr/bin/virtualenvwrapper.sh: No such file or directory

I can't figure out where the shell is trying to run /usr/bin/virtualenvwrapper.sh upon server login.我无法弄清楚 shell 在服务器登录时试图运行/usr/bin/virtualenvwrapper.sh的位置。 I want virtualenvwrapper permanently uninstalled, not just removed from the shell instance.我希望 virtualenvwrapper 永久卸载,而不仅仅是从 shell 实例中删除。 I thought I uninstalled it with pip uninstall virtualenvwrapper , but every time I log into the server I get the error -bash: /usr/bin/virtualenvwrapper.sh: No such file or directory , as if there is some sort of leftover artifact.我以为我用pip uninstall virtualenvwrapper卸载了它,但是每次我登录服务器时都会收到错误-bash: /usr/bin/virtualenvwrapper.sh: No such file or directory ,好像有某种遗留的工件。 Yesterday I did a lot of tinkering and I can't remember all the changes I made or how I made this happen.昨天我做了很多修补,我不记得我所做的所有更改或我是如何做到这一点的。 Where is it executing the search for virtualenvwrapper.sh ?它在哪里执行对virtualenvwrapper.sh的搜索?

SUPPLEMENTARY INFO补充资料

$ echo $PATH
/usr/lib64/qt-3.3/bin
/usr/local/bin/ibm/lsf/9.1/linux2.6-glibc2.3-x86_64/etc
/usr/local/bin/ibm/lsf/9.1/linux2.6-glibc2.3-x86_64/bin
/usr/local/bin
/bin
/usr/bin
/usr/local/sbin
/usr/sbin
/sbin/usr/local/bin/CASAVA-1.8.2/bin
/usr/local/bin/blast
/usr/local/bin/mirdeep2
/usr/local/bin/velvet

$ sudo vim ~/.bashrc
1 # .bashrc
2
3 # Source global definitions
4 if [ -f /etc/bashrc ]; then
5         . /etc/bashrc
6 fi
7
8 # User specific aliases and functions

on ubuntu 12.04 LTS, installing through pip, it is installed to在 ubuntu 12.04 LTS 上,通过 pip 安装,安装到

/usr/local/bin/virtualenvwrapper.sh

And if you are using Ubuntu 16.04 or later, it is installed to如果您使用的是 Ubuntu 16.04 或更高版本,它会安装到

~/.local/bin/virtualenvwrapper.sh

There are a number of files that might be run when you login to your terminal if you are using the bash shell.如果您使用的是bash shell,那么在您登录终端时可能会运行许多文件。

You should check ~/.bashrc , ~/.bash_profile , ~/.bash_login and ~/.profile for "/usr/bin/virtualenvwrapper.sh".你应该检查~/.bashrc~/.bash_profile~/.bash_login~/.profile的“/usr/bin/virtualenvwrapper.sh”。

Likely one of those files is being run on login and contains the missing script which you uninstalled.可能其中一个文件正在登录时运行,并且包含您卸载的丢失脚本。

For anyone finding this in the future.对于将来发现此问题的任何人。 The virtualenvwrapper.sh script is/was now located at /usr/share/virtualenvwrapper/virtualenvwrapper.sh on Ubuntu 20.04.1 LTS (at least for me in my VM). virtualenvwrapper.sh脚本现在位于 Ubuntu 20.04.1 LTS 上的/usr/share/virtualenvwrapper/virtualenvwrapper.sh (至少对于我在我的 VM 中)。

(Sadly i can't just comment on the above post mentioning the locations so it would all be together, because new user reputation) (遗憾的是,我不能只评论上面提到的位置的帖子,所以它们会在一起,因为新用户的声誉)

sudo -H pip3 install virtualenvwrapper sudo -H pip3 安装 virtualenvwrapper

i ran into to similar problem where installation could not suceed because ~/.cache/pip and ~/.cache/pip/http is not owned by the current user.我遇到了类似的问题,安装无法成功,因为 ~/.cache/pip 和 ~/.cache/pip/http 不属于当前用户。 installing with -H or --set-home option solved my problem.使用 -H 或 --set-home 选项安装解决了我的问题。

Confirmed for Ubuntu 18 , as already answered by @Tarique .已确认适用于 Ubuntu 18,正如@Tarique 已经回答的那样。 The shell script virtualenvwrapper.sh for the wrapper is within - ~/.local/bin/包装器的 shell 脚本virtualenvwrapper.sh位于 - ~/.local/bin/

(base) dhankar@dhankar-1:~/opencv_cuda$ cd ~/.local/bin/
(base) dhankar@dhankar-1:~/.local/bin$ ls -ltr
total 100
-rwxr-xr-x 1 dhankar dhankar 41703 Jul 23 20:56 virtualenvwrapper.sh
-rwxr-xr-x 1 dhankar dhankar  2210 Jul 23 20:56 virtualenvwrapper_lazy.sh
-rwxr-xr-x 1 dhankar dhankar   259 Jul 23 20:56 virtualenv

Setting up a Virtual Environment Now open your terminal in the home directory by right clicking and choosing the option “Open in Terminal”.设置虚拟环境 现在通过右键单击并选择“在终端中打开”选项,在主目录中打开您的终端。 You can also press the CTRL , ALT , and T keys on your keyboard at the same time to open the Terminal application automatically.您还可以同时按下键盘上的CTRLALTT键以自动打开终端应用程序。

You first need to create a special directory that will hold all of your virtual environments.您首先需要创建一个特殊目录来保存您的所有虚拟环境。 So proceed with creating a new hidden directory called virtualenv.因此,继续创建一个名为 virtualenv 的新隐藏目录。

$ mkdir .virtualenv

Now you should install pip for Python3.现在你应该为 Python3 安装 pip。

$ sudo apt install python3-pip

Confirm the pip3 installation.确认pip3安装。

$ pip3 --version

Now install virtualenv via pip3.现在通过 pip3 安装 virtualenv。

$ pip3 install virtualenv

To find where your virtualenv was installed, type:要查找您的 virtualenv 的安装位置,请键入:

$ which virtualenv

Install virtualenvwrapper via pip3:通过 pip3 安装 virtualenvwrapper:

$ pip3 install virtualenvwrapper

We are going to modify your .bashrc file by adding a row that will adjust every new virtual environment to use Python 3. We will point virtual environments to the directory we created above (.virtualenv) and we will also point to the locations of the virtualenv and virtualenvwrapper.我们将通过添加一行来修改您的 .bashrc 文件,该行将调整每个新的虚拟环境以使用 Python 3。我们将虚拟环境指向我们上面创建的目录 (.virtualenv),我们还将指向virtualenv 和 virtualenvwrapper。

Now open the .bashrc file using Vim editor.现在使用 Vim 编辑器打开 .bashrc 文件。

$ vim .bashrc

If you still haven't used the Vim editor or you don't have it installed on your computer you should install it now.如果您还没有使用 Vim 编辑器或者您的计算机上没有安装它,您应该立即安装它。 It is a widely used Linux editor, and for good reason.它是一个广泛使用的 Linux 编辑器,这是有充分理由的。

$ sudo apt install vim

After you've installed Vim open the file .bashrc file by typing the vim .bashrc command in your terminal.安装 Vim 后,通过在终端中键入 vim .bashrc 命令打开文件 .bashrc 文件。 Navigate to the bottom of the .bashrc file, press the letter i to enter the insert mode of Vim, and add these rows:导航到 .bashrc 文件的底部,按字母 i 进入 Vim 的插入模式,并添加以下行:

#Virtualenvwrapper settings:
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_VIRTUALENV=/home/your_username/.local/bin/virtualenv
source ~/.local/bin/virtualenvwrapper.sh

After you are done, press the esc key.完成后,按 esc 键。 Then type :wq and press enter.然后输入 :wq 并按回车键。 This command will save and exit the Vim editor.此命令将保存并退出 Vim 编辑器。 Close and reopen your terminal when you're done.完成后关闭并重新打开终端。

To create a virtual environment in Python3 and activate it immediately, use this command in your terminal:要在 Python3 中创建虚拟环境并立即激活它,请在终端中使用以下命令:

$ mkvirtualenv name_of_your_env

You should confirm that this environment is set up for Python3:你应该确认这个环境是为 Python3 设置的:

$ Python -V

To deactivate the environment use the deactivate command.要停用环境,请使用停用命令。

$ deactivate

To list all available virtual environments use the command workon or lsvirtualenv (same result as workon but shown in a fancy way) in your terminal:要列出所有可用的虚拟环境,请在终端中使用命令 workon 或 lsvirtualenv (结果与 workon 相同,但以一种奇特的方式显示):

$ workon

$ lsvirtualenv

To activate one specific environment use workon + name of your environment:要激活一个特定环境,请使用 workon + 您的环境名称:

$ workon name_of_your_env

There are several useful command you might need to use someday:有一天你可能需要使用几个有用的命令:

Rmvirtualenv will remove a specific virtual environment located in your .virtualenv directory. Rmvirtualenv 将删除位于 .virtualenv 目录中的特定虚拟环境。

$ rmvirtualenv name_of_your_env

Cpvirtualenv will copy the existing virtual environment to a new virtual environment and activate it. Cpvirtualenv 会将现有的虚拟环境复制到一个新的虚拟环境并激活它。

$ cpvirtualenv old_virtual_env new_virtual_env

Well done!做得好! You have now created your first isolated Python 3 environment.您现在已经创建了第一个独立的 Python 3 环境。

I also confronted the same problem, but this worked for me: -我也遇到了同样的问题,但这对我有用:-

  1. Create a directory to hold the virtual environments.创建一个目录来保存虚拟环境。 mkdir $HOME/.virtualenvs
  2. Add a line like export WORKON_HOME=$HOME/.virtualenvs to your .bashrc .将类似export WORKON_HOME=$HOME/.virtualenvs的行添加到您的.bashrc
  3. Add a line like source /path/to/this/file/virtualenvwrapper.sh to your .bashrc .将像source /path/to/this/file/virtualenvwrapper.sh这样的行添加到您的.bashrc
  4. Run: source ~/.bashrc运行: source ~/.bashrc
  5. Run: mkvirtualenv temp运行: mkvirtualenv temp
  6. This time, the "temp" environment is included.这一次,包括“临时”环境。
  7. Run: workon temp运行: workon temp
  8. The virtual environment is activated.虚拟环境被激活。

If you are on Ubuntu 20 then use the code given below in ~/.bashrc如果您使用的是 Ubuntu 20,请使用以下 ~/.bashrc 中给出的代码

export WORKON_HOME=~/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
export VIRTUALENVWRAPPER_VIRTUALENV=~ /.local/bin/virtualenv
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
source ~/.local/bin/virtualenvwrapper.sh

It can be that you python packages are installed somewhere else.可能是你的 python 包安装在其他地方。 So try:所以尝试:

$ which python
/home/tesla/miniconda3/bin/python

or要么

$ which virtualenvwrapper.sh
/home/tesla/miniconda3/bin/virtualenvwrapper.sh    

To check the location of python installation.检查python安装的位置。 In my case I was using miniconda, therefore system was not able to find the location mentioned in the documentation.就我而言,我使用的是 miniconda,因此系统无法找到文档中提到的位置。 If the above location is not /usr/local/bin/virtualenvwrapper.sh then now use :如果上述位置不是/usr/local/bin/virtualenvwrapper.sh那么现在使用:

source /home/tesla/miniconda3/bin/virtualenvwrapper.sh

Should work.应该管用。

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

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