我尝试使用pip在ubuntu上安装django。但不幸的是我得到了这样的错误。谁能解释一下并告诉我一些方法来解决这个问题?
error: could not create '/usr/local/lib/python2.7/dist-packages/django': Permission denied
----------------------------------------
Command /usr/bin/python -c "import setuptools;__file__='/home/franklingu/build/django /setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-W5MhGe-record/install-record.txt failed with error code 1
Storing complete log in /home/franklingu/.pip/pip.log
答案 0 :(得分:15)
请勿使用sudo使用虚拟环境,如下所示:
$ sudo apt-get install python-virtualenv
$ mkvirtualenv django_env
$ source django_env/bin/activate
(django_env) $ pip install django
(django_env) $ cd $HOME
(django_env) $ mkdir projects
(django_env) $ cd projects
(django_env)/projects $ django-admin.py startproject foo
(django_env)/projects $ cd foo
(django_env)/projects/foo $ python manage.py runserver
当你完成;键入deactivate
以退出虚拟环境:
(django_env)/projects/foo $ deactivate
/projects/foo $
答案 1 :(得分:9)
请尝试sudo pip install django
。
答案 2 :(得分:3)
您尝试安装的位置django" usr / local / lib /..."是root owanership location.So对于你需要的每个命令 须藤。
而不是你可以遵循这些疱疹
1.安装玻璃环境
$ sudo pip install virtualenv
2.创建虚拟环境
$ virtualenv -p python3 testEnv
(不要在这里使用sudo,它将使环境拥有所有权。我在创建python 3环境)
3.使用以下命令
激活该env$ source testEnv/bin/activate
4。使用命令
安装django$ pip install django
5.使用follwing命令,您可以检查该环境中已安装的软件包
$ pip freeze
注意:最好不要使用sudo来使用pip命令。如果我们使用sudo,那么包将更改为root权限