本文介绍了bash:使用 virtualenv 时出现意外标记“("附近的语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用virualenv在~/.virtualenvs"中创建了一个python3虚拟环境test".但是,当我尝试激活时出现以下错误.

I have created a python3 virtual environment "test" inside "~/.virtualenvs" using virualenv. But, I got the following error when I tried to activate.

bash: /home/ubuntu/.virtualenvs/test/bin/activate: line 4: syntax error near unexpected token `('
bash: /home/ubuntu/.virtualenvs/test/bin/activate: line 4: `deactivate () {'

我也尝试在 ubuntu 容器和 cloud9 ide 上使用 virtualenv,但遇到了同样的错误.

I tried to use virtualenv on ubuntu container and cloud9 ide also but got the same error.

推荐答案

看来,这个问题被频繁查看​​.尽管我对解决方案发表了评论,但我认为最好在这里回答.我发现问题出在我的 ~.bash_alias 文件中.有一个别名停用"我很久以前创建的以停用 conda 环境,但我忘记了.在我所有的 ubuntu 容器和个人电脑中,我使用了相同的 ~.bash_alias 文件.从 ~.bash_alias 文件中删除后,命令 source ~/.virtualenvs/test/bin/activate 工作正常.

It seems, the question is being viewed frequently. Even though I put a comment regarding the solution, I think, it is better to answer here.I have figured out that the cause of the problem was in my ~.bash_alias file. There was an alias "deactivate" that I created long before to deactivate conda environment but I forgot that. And in all my ubuntu containers and pcs I used the same ~.bash_alias file. After deleting that from the ~.bash_alias file the command source ~/.virtualenvs/test/bin/activate worked fine.

这篇关于bash:使用 virtualenv 时出现意外标记“("附近的语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 17:41