0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Pythonで仮想環境を作ろうとしたら上手く行かなかった件

Posted at

環境

  • windows
  • VS Code

今回出たエラー

virtualenv my_python_env

と打って仮想環境ディレクトリを作成することはできていたのですが、

.\my_python_env\Scripts\activate.bat

と打ってアクティベイトしようとしても、

.\my_python_env\Scripts\activate.bat : The term '.\my_python_env\Scripts\activate.bat' is not recognized as the name of a cmdlet, 
PS C:\Users\--\Documents\programming\Sakai\my_python_env\Scripts> cd..
PS C:\Users\--\Documents\programming\Sakai\my_python_env> .\Scripts\activate.bat
PS C:\Users\--\Documents\programming\Sakai\my_python_env> .\Scripts\activate.bat
PS C:\Users\--\Documents\programming\Sakai\my_python_env> .\Scripts\activate.bat
PS C:\Users\--\Documents\programming\Sakai\my_python_env> .\Scripts\activate.bat
PS C:\Users\--\Documents\programming\Sakai\my_python_env> cd..
PS C:\Users\--\Documents\programming\Sakai> cd .\my_python_env\   
PS C:\Users\--\Documents\programming\Sakai\my_python_env> .\Scripts\activate
.\Scripts\activate : File C:\Users\--\Documents\programming\Sakai\my_python_env\Scripts\activate.ps1 cannot be loaded       
because running scripts is disabled on this system. For more information, see about_Execution_Policies at
https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ .\Scripts\activate
+ ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

という風にエラーが出て上手く行きません。
調べても理由が分からずかなり困っていました。

解決

本当にたまたまなのですが、powershellからcommand promptにdefault shellを変えたところ普通に解決されました。
理由は全然わかりませんが、同じ問題で訳も分からず悩んでいる方のためにシェアします。
理由が分かったらまた更新します。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?