Error installing django program

Last summer, I wanted to learn how to do a web developer, so I installed Django 1.8, an unstable version. I installed it without pip. I recently decided to try again, but wanted to work with the stable release 1.7.1 and just wanted to install using pip.

I read that to remove Django that was installed without pip, you need to remove all .eggof it /Library/Python/2.7/site-packages/, so I did it.

Since then I get ridiculous errors. When I issue 'pip install django', I get

bash-3.2$ pip install django
Downloading/unpacking django
  Downloading Django-1.7.1-py2.py3-none-any.whl (7.4MB): 7.4MB downloaded
Installing collected packages: django
Cleaning up...
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip-1.5.6-py2.7.egg/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip-1.5.6-py2.7.egg/pip/commands/install.py", line 283, in run
    requirement_set.install(install_options, global_options, root=options.root_path)
  File "/Library/Python/2.7/site-packages/pip-1.5.6-py2.7.egg/pip/req.py", line 1435, in install
    requirement.install(install_options, global_options, *args, **kwargs)
  File "/Library/Python/2.7/site-packages/pip-1.5.6-py2.7.egg/pip/req.py", line 671, in install
    self.move_wheel_files(self.source_dir, root=root)
  File "/Library/Python/2.7/site-packages/pip-1.5.6-py2.7.egg/pip/req.py", line 901, in move_wheel_files
    pycompile=self.pycompile,
  File "/Library/Python/2.7/site-packages/pip-1.5.6-py2.7.egg/pip/wheel.py", line 215, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/Library/Python/2.7/site-packages/pip-1.5.6-py2.7.egg/pip/wheel.py", line 205, in clobber
    os.makedirs(destdir)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/django'

When I check the false directory, I find that / django does not exist. Throwing sudo will eclipse the errors, but I believe that I still cannot start the django project.

Has anyone seen this before or have any idea how to fix this?

+2
5

. /Library, , .

virtualenv . , , Python, Python.

Mac ( ) , Python, , Python .

, - virtualenv . , :

sudo easy_install virtualenv

- .

, :

$ virtualenv my_env  # This creates a new Python environment called my_env, completely
                     # separate from your system wide install.
$ source my_env/bin/activate # Activates the virtual envrionment
(my_env) $ pip install django # Install django in this new environment the (my_env)
                              # indicates you are working inside a virtual environment

...

(my_env) $ deactivate  # Deactivates the environment,
                       # returning you to the normal system Python
$

, , , , .

+7

. /usr/local/bin/ django 1.8 install (django-admin ..), virtualenvwrapper .

+4

virtualenv, pip install --user Django Mac OS,

, :

~/Library/Python/2,7/Library//-

pip install --help:

--user                      Install to the Python user install directory for your platform. Typically ~/.local/, or %APPDATA%\Python on Windows.
                              (See the Python documentation for site.USER_BASE for full details.)

Then again virtualenv and virtualenvwrapper the recommended method for installing Django, I think?

+3
source

Run the following command:

sudo pip install Django
0
source

First you need to set up a virtual environment or a working environment and activate it.

pip install Django

or

pip install -U Django

or

pip install -e django

0
source

Source: https://habr.com/ru/post/1532775/


All Articles