Python hangs while executing pip and virtualenv and brings no results

依然范特西╮ 提交于 2020-01-15 09:17:33

问题


I tried to set up a virtual environment for my project by executing virtualenv myenv. The folder seemed to be generated, but the command hung, and I couldn't execute another command. I had to close the console and restart cmd. The folder was generated, as I said, but I couldn't activate the virtual environment by venv\Scripts\activate.

I met the same behaviour while trying to execute pip freeze > requirements.txt. The file was generated, but it was empty, although I used a lot of packages in my project. When I executed just pip freeze, the list of packages was printed, but the command hung again, and I had to close the console again.

I tried both procedures many times, but with no success. I tried that in Windows cmd and Anaconda Prompt (Anaconda version: Anaconda3 2.4.1; Python: 3.5.1).

EDIT: when I tried to do this for the very first time some days ago, I succeeded in activating the virtual environment, but only for one time.


回答1:


A simple solution to this (which does work) would be to use Powershell as an Administrator, instead of cmd.

Conversely, use cmd as an administrator, though I would recommend using the much-more powerful Powershell for any and all purposes!

Why this works:

A lot of commands need super-user rights (think root/ sudo in linux) in order to be properly executed.

Since there is no such thing as as sudo in Windows yet, you can implement it via admin privileges.

Cheers!



来源:https://stackoverflow.com/questions/44687986/python-hangs-while-executing-pip-and-virtualenv-and-brings-no-results

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!