Je ne peux pas installer les packages de base Django sur Ubuntu. Je viens de supprimer virtualenv et de le refaire. pip3install
= pip3 install -r requirements.txt
[mything] cchilders@cchilders-desktop:~/projects/mything (master)
$ cat requirements.txt
Django==1.10.1
Django-filter
djangorestframework
psycopg2
twilio
ipdb
ipython
[mything] cchilders@cchilders-desktop:~/projects/mything (master)
$ pip3install
Collecting Django==1.10.1 (from -r requirements.txt (line 1))
Using cached Django-1.10.1-py2.py3-none-any.whl
Collecting Django-filter (from -r requirements.txt (line 2))
Using cached Django_filter-0.15.2-py2.py3-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): djangorestframework in /home/cchilders/.local/lib/python3.5/site-packages (from -r requirements.txt (line 3))
Requirement already satisfied (use --upgrade to upgrade): psycopg2 in /usr/lib/python3/dist-packages (from -r requirements.txt (line 4))
Collecting twilio (from -r requirements.txt (line 5))
Requirement already satisfied (use --upgrade to upgrade): ipdb in /home/cchilders/.local/lib/python3.5/site-packages (from -r requirements.txt (line 6))
Requirement already satisfied (use --upgrade to upgrade): ipython in /home/cchilders/.local/lib/python3.5/site-packages (from -r requirements.txt (line 7))
Collecting pysocks; python_version == "3.5" (from twilio->-r requirements.txt (line 5))
Requirement already satisfied (use --upgrade to upgrade): six in /home/cchilders/.local/lib/python3.5/site-packages (from twilio->-r requirements.txt (line 5))
Collecting httplib2>=0.7 (from twilio->-r requirements.txt (line 5))
Requirement already satisfied (use --upgrade to upgrade): pytz in /usr/lib/python3/dist-packages (from twilio->-r requirements.txt (line 5))
Requirement already satisfied (use --upgrade to upgrade): setuptools in /home/cchilders/.local/lib/python3.5/site-packages (from ipdb->-r requirements.txt (line 6))
Requirement already satisfied (use --upgrade to upgrade): Prompt-toolkit<2.0.0,>=1.0.3 in /home/cchilders/.local/lib/python3.5/site-packages (from ipython->-r requirements.txt (line 7))
Requirement already satisfied (use --upgrade to upgrade): pickleshare in /home/cchilders/.local/lib/python3.5/site-packages (from ipython->-r requirements.txt (line 7))
Requirement already satisfied (use --upgrade to upgrade): decorator in /home/cchilders/.local/lib/python3.5/site-packages (from ipython->-r requirements.txt (line 7))
Requirement already satisfied (use --upgrade to upgrade): simplegeneric>0.8 in /home/cchilders/.local/lib/python3.5/site-packages (from ipython->-r requirements.txt (line 7))
Requirement already satisfied (use --upgrade to upgrade): traitlets>=4.2 in /home/cchilders/.local/lib/python3.5/site-packages (from ipython->-r requirements.txt (line 7))
Requirement already satisfied (use --upgrade to upgrade): pygments in /home/cchilders/.local/lib/python3.5/site-packages (from ipython->-r requirements.txt (line 7))
Requirement already satisfied (use --upgrade to upgrade): pexpect; sys_platform != "win32" in /home/cchilders/.local/lib/python3.5/site-packages (from ipython->-r requirements.txt (line 7))
Requirement already satisfied (use --upgrade to upgrade): wcwidth in /home/cchilders/.local/lib/python3.5/site-packages (from Prompt-toolkit<2.0.0,>=1.0.3->ipython->-r requirements.txt (line 7))
Requirement already satisfied (use --upgrade to upgrade): ipython-genutils in /home/cchilders/.local/lib/python3.5/site-packages (from traitlets>=4.2->ipython->-r requirements.txt (line 7))
Requirement already satisfied (use --upgrade to upgrade): ptyprocess>=0.5 in /home/cchilders/.local/lib/python3.5/site-packages (from pexpect; sys_platform != "win32"->ipython->-r requirements.txt (line 7))
Installing collected packages: Django, Django-filter, pysocks, httplib2, twilio
Exception:
Traceback (most recent call last):
File "/home/cchilders/.local/lib/python3.5/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/home/cchilders/.local/lib/python3.5/site-packages/pip/commands/install.py", line 317, in run
prefix=options.prefix_path,
File "/home/cchilders/.local/lib/python3.5/site-packages/pip/req/req_set.py", line 742, in install
**kwargs
File "/home/cchilders/.local/lib/python3.5/site-packages/pip/req/req_install.py", line 831, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/home/cchilders/.local/lib/python3.5/site-packages/pip/req/req_install.py", line 1032, in move_wheel_files
isolated=self.isolated,
File "/home/cchilders/.local/lib/python3.5/site-packages/pip/wheel.py", line 346, in move_wheel_files
clobber(source, lib_dir, True)
File "/home/cchilders/.local/lib/python3.5/site-packages/pip/wheel.py", line 287, in clobber
ensure_dir(dest) # common for the 'include' path
File "/home/cchilders/.local/lib/python3.5/site-packages/pip/utils/__init__.py", line 83, in ensure_dir
os.makedirs(path)
File "/usr/lib/python3.5/os.py", line 241, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/usr/lib/python3.5/site-packages'
Le mything
à gauche est un virtualenv actif (je viens de le refaire)
Vous pouvez recréer accidentellement virtualenv avec Python2 en oubliant de mettre le chemin vers l'interpréteur Python3, donc lorsque vous exécutez pip3, il fait référence au système Python3.
Assurez-vous que vous utilisez correctement Python dans votre virtualenv et assurez-vous également que vous créez virtualenv avec pip (oui c'est l'option par défaut mais nous ne savons pas comment vous créez votre environnement virtuel).
Juste pour développer la réponse de @valentjedi, voici comment j'ai résolu mon problème d'autorisation sans utiliser Sudo.
Installer
Assurez-vous que virtualenv est installé ici
Ceci est facultatif, mais j'utilise également virtualenvwrapper pour utiliser la commande workon
ici , sinon vous pouvez simplement source bin/activate
du virtualenv
Créer Virtualenv
Vous ne voulez pas installer vos bibliothèques de projet avec Sudo
car cela installera vos bibliothèques à l'échelle du système (ce qui entraînera des problèmes lorsque vous avez plusieurs projets). Utilisez plutôt virtualenvs comme ceci:
$mkvirtualenv myenv --python=python3.5
$workon myenv
$pip3 install -r requirements.txt
Cela vous permet de configurer en créant votre virtualenv 'myenv' et en spécifiant lequel python vous utilisez. Vous activez ensuite l'environnement et pouvez installer votre fichier d'exigences.
J'ai eu le même problème même si j'avais le bon chemin python dans mon virtualenv. Mon erreur était cependant d'utiliser une mauvaise version de pip - ayant python3.7 je tapais pip install -r requirements.txt au lieu de pip3.7 install -r requirements.txt