问题描述
在虚拟环境下,执行某些命令需要有sudo提升权限,会导致该条命令退出虚拟环境:
如启动django 服务,需要监听80端口:
$: python manage.py runserver 80 Performing system checks... System check identified no issues (0 silenced). March 15, 2018 - 07:43:40 Django version 2.0.3, using settings 'helloworld.settings' Starting development server at http://127.0.0.1:80/ Quit the server with CONTROL-C. Error: You don't have permission to access that port.
此时会提示权限不足,无法访问80端口。
所以通过sudo提升命令权限:
$: ~/python3env/helloworld$ sudo python manage.py runserver 80 Traceback (most recent call last): File "manage.py", line 11, in <module> "Couldn't import Django. Are you sure it's installed and " ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environ