I updated from Django 1.5.8 to 1.7:
pip install Django==1.7
Downloading/unpacking Django==1.7
Downloading Django-1.7-py2.py3-none-any.whl (7.4MB): 7.4MB downloaded
Installing collected packages: Django
Found existing installation: Django 1.5.8
Uninstalling Django:
Successfully uninstalled Django
Rolling back uninstall of 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 247, in move_wheel_files
clobber(source, dest, False, fixer=fixer, filter=filter)
File "/Library/Python/2.7/site-packages/pip-1.5.6-py2.7.egg/pip/wheel.py", line 209, in clobber
shutil.copy2(srcfile, destfile)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 130, in copy2
copyfile(src, dst)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 83, in copyfile
with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied: '/usr/local/bin/django-admin.py'
Storing debug log for failure in /Users/stefanieness/Library/Logs/pip.log
This is my error message.
But when I run
python
import django
print(django.get_version())
I get 1.7. Can I use the version like that or do I have to reinstall it? Will it work?
Thank you!
This is because the first time you installed django, you did sudo pip install django, which has installed django in your global Python interpreter as the root user (or the superuser).
You can only have one version of django in your global Python interpreter, so once you upgrade it, any of your django applications that are using the global Python interpreter (in other words, not using a virtual environment) will be automatically upgraded to 1.7
If you don't have any other django projects, then this doesn't really have any negative effects - but as a best practice, you should use virtual environments so that you can easily test versions of libraries.
To solve your immediate problem, you need to sudo pip install -U django which will upgrade django to the latest stable release.
Related
I have downloaded Python 3.6.2 (64 bit) in Windows 10 (64 bit). Now I want to work on Django framework so I want to download Django using pip command but it shows Error.
C:\Windows\system32>pip install django
Collecting django
Using cached Django-1.11.4-py2.py3-none-any.whl
Collecting pytz (from django)
Using cached pytz-2017.2-py2.py3-none-any.whl
Installing collected packages: pytz, django
Exception:
Traceback (most recent call last):
File "c:\program files\python36\lib\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "c:\program files\python36\lib\site-packages\pip\commands\install.py", line 342, in run
prefix=options.prefix_path,
File "c:\program files\python36\lib\site-packages\pip\req\req_set.py", line 784, in install
**kwargs
File "c:\program files\python36\lib\site-packages\pip\req\req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "c:\program files\python36\lib\site-packages\pip\req\req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "c:\program files\python36\lib\site-packages\pip\wheel.py", line 345, in move_wheel_files
clobber(source, lib_dir, True)
File "c:\program files\python36\lib\site-packages\pip\wheel.py", line 316, in clobber
ensure_dir(destdir)
File "c:\program files\python36\lib\site-packages\pip\utils\__init__.py", line 83, in ensure_dir
os.makedirs(path)
File "c:\program files\python36\lib\os.py", line 220, in makedirs
mkdir(name, mode)
PermissionError: [WinError 5] Access is denied: 'c:\\program files\\python36\\Lib\\site-packages\\pytz'
The problem has to do with the location you have chosen to install python, normally it's installed in C:\pythonXX but your installation is in C:\Program Files\pythonXX. That is always going to cause problems, you will need to always be running it as administrator. Quick and best solution, uninstall and accept to install python on the default location - C:\pythonXX
The best way to work with Django is within a virtual environment. Installing packages in your system's Python 3.6 will affect all programs you have running on Python 3.6; if you have multiple Django apps, your requirements could get all mixed up.
Django works really nicely with virtual environments: there's a good tutorial here. Essentially, you want to set up a virtual environment for each project, and then install Django (and its dependencies) cleanly within that environment. This should avoid any "Access denied" or other errors that you're experiencing.
Just as an example of how virtual environments help: if you need to use different versions of Django for different apps, they should be limited only to apps within that same virtual environment. Then, you can install the package differently in a different environment for another app. That way, when you "import django" from one of your apps, you know you're getting the version you need.
I want to install simpleaudio but can't upgrade or install anything with pip, here's what it gives me:
Downloading/unpacking pip from https://pypi.python.org/packages/9c/32/004ce0852e0a127f07f358b715015763273799b d798956fa930814b60f39/pip-8.1.2-py2.py3-none-any.whl#md5=0570520434c5b600d89ec95393b2650b
Downloading pip-8.1.2-py2.py3-none-any.whl (1.2MB): 1.2MB downloaded
Installing collected packages: pip
Found existing installation: pip 1.5.6
Not uninstalling pip at /usr/lib/python2.7/dist-packages, owned by OS
Can't roll back pip; was not uninstalled
Cleaning up...
Exception:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 295, in run
requirement_set.install(install_options, global_options, root=options.root_path)
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1436, in install
requirement.install(install_options, global_options, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 672, in install
self.move_wheel_files(self.source_dir, root=root)
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 902, in move_wheel_files
pycompile=self.pycompile,
File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 214, in move_wheel_files
clobber(source, lib_dir, True)
File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 204, in clobber
os.makedirs(destdir)
File "/usr/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/pip-8.1.2.dist-info'
Storing debug log for failure in /home/pi/.pip/pip.log
I'm using Rasbian with NOOBS if that help figuring this out. I've just started studying programming so I have no clue what I need to do since using the guides results to above, so please explain this to an idiot.
pip fails to access some system paths and shows clearly that the user used to run pip does not have enough privileges to access them.
To solve this, try to run these commands as root using sudo:
sudo pip <options>
Otherwise, if you don't have sudo installed (this is almost impossible) or if you're just curious and know the root's password, simply log in as root and execute your commands without sudo:
su # or su root
# type the root's password
pip <options>
If you use this option, don't forget to log out after you've installed everything!
I just recently re-installed Python 2 and Python 3 via homebrew and everything looked ok. However I updated pip3 as well as pip after installing python and then, when trying to install virtualenv, I get the below errors:
~> pip install virtualenv Collecting virtualenv Downloading virtualenv-13.1.2-py2.py3-none-any.whl (1.7MB) 100% |
████████████████████████████████| 1.7MB 361kB/s Installing collected
packages: virtualenv Exception: Traceback (most recent call last):
File "/usr/local/lib/python3.4/site-packages/pip/basecommand.py", line 211, in main status = self.run(options, args)
File "/usr/local/lib/python3.4/site-packages/pip/commands/install.py", line 311, in run root=options.root_path, File "/usr/local/lib/python3.4/site-packages/pip/req/req_set.py", line 646, in install **kwargs
File "/usr/local/lib/python3.4/site-packages/pip/req/req_install.py", line 803, in install self.move_wheel_files(self.source_dir, root=root)
File "/usr/local/lib/python3.4/site-packages/pip/req/req_install.py", line 998, in move_wheel_files isolated=self.isolated, File "/usr/local/lib/python3.4/site-packages/pip/wheel.py", line 479, in move_wheel_files maker.make_multiple(['%s = %s' % kv for kv in console.items()]) File "/usr/local/lib/python3.4/site-packages/pip/_vendor/distlib/scripts.py", line 364, in make_multiple filenames.extend(self.make(specification, options))
File "/usr/local/lib/python3.4/site-packages/pip/_vendor/distlib/scripts.py", line 353, in make self._make_script(entry, filenames, options=options)
File "/usr/local/lib/python3.4/site-packages/pip/_vendor/distlib/scripts.py", line 257, in _make_script self._write_script(scriptnames, shebang, script, filenames, ext) File "/usr/local/lib/python3.4/site-packages/pip/_vendor/distlib/scripts.py", line 231, in _write_script self._fileop.write_binary_file(outname, script_bytes)
File "/usr/local/lib/python3.4/site-packages/pip/_vendor/distlib/util.py", line 388, in write_binary_file with open(path, 'wb') as f:
PermissionError: [Errno 13] Permission denied: '/usr/local/bin/virtualenv'
pip freeze then seems to think virtualenv is installed but none of it's commands work.
Interestingly if I try to uninstall virtualenv it seems to have it attached to the Python 3 installed by brew installed of the Python 2 version brew installed.
Uninstalling virtualenv-13.1.2:
/usr/local/lib/python3.4/site-packages/__pycache__/virtualenv.cpython-34.pyc
/usr/local/lib/python3.4/site-packages/virtualenv-13.1.2.dist-info/DESCRIPTION.rst
/usr/local/lib/python3.4/site-packages/virtualenv-13.1.2.dist-info/METADATA
/usr/local/lib/python3.4/site-packages/virtualenv-13.1.2.dist-info/RECORD
/usr/local/lib/python3.4/site-packages/virtualenv-13.1.2.dist-info/WHEEL
/usr/local/lib/python3.4/site-packages/virtualenv-13.1.2.dist-info/entry_points.txt
/usr/local/lib/python3.4/site-packages/virtualenv-13.1.2.dist-info/metadata.json
/usr/local/lib/python3.4/site-packages/virtualenv-13.1.2.dist-info/pbr.json
/usr/local/lib/python3.4/site-packages/virtualenv-13.1.2.dist-info/top_level.txt
/usr/local/lib/python3.4/site-packages/virtualenv.py
/usr/local/lib/python3.4/site-packages/virtualenv_support/__init__.py
/usr/local/lib/python3.4/site-packages/virtualenv_support/__pycache__/__init__.cpython-34.pyc
/usr/local/lib/python3.4/site-packages/virtualenv_support/argparse-1.3.0-py2.py3-none-any.whl
/usr/local/lib/python3.4/site-packages/virtualenv_support/pip-7.1.2-py2.py3-none-any.whl
/usr/local/lib/python3.4/site-packages/virtualenv_support/setuptools-18.2-py2.py3-none-any.whl
/usr/local/lib/python3.4/site-packages/virtualenv_support/wheel-0.24.0-py2.py3-none-any.whl
Proceed (y/n)?
pip freeze gives me:
~> pip freeze
pbr==1.6.0
virtualenv==13.1.2
virtualenv-clone==0.2.6
wheel==0.24.0
so virtualenv already installed but doesn't work for some reason.
For python 2.7 I believe pip is referenced by pip2. Your permission error is easily fixed by running the command as sudo.
I am on ubuntu 14.04 freshly installed, and I have installed pip and virtualenvironment but when I try to install django I get the following error message:
name#computername:/$ pip install django
Collecting django
Using cached Django-1.7.4-py2.py3-none-any.whl
Installing collected packages: django
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/pip-6.0.7-py2.7.egg/pip/basecommand.py", line 232, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/dist-packages/pip-6.0.7-py2.7.egg/pip/commands/install.py", line 347, in run
root=options.root_path,
File "/usr/local/lib/python2.7/dist-packages/pip-6.0.7-py2.7.egg/pip/req/req_set.py", line 549, in install
**kwargs
File "/usr/local/lib/python2.7/dist-packages/pip-6.0.7-py2.7.egg/pip/req/req_install.py", line 740, in install
self.move_wheel_files(self.source_dir, root=root)
File "/usr/local/lib/python2.7/dist-packages/pip-6.0.7-py2.7.egg/pip/req/req_install.py", line 949, in move_wheel_files
isolated=self.isolated,
File "/usr/local/lib/python2.7/dist-packages/pip-6.0.7-py2.7.egg/pip/wheel.py", line 234, in move_wheel_files
clobber(source, lib_dir, True)
File "/usr/local/lib/python2.7/dist-packages/pip-6.0.7-py2.7.egg/pip/wheel.py", line 205, in clobber
os.makedirs(destdir)
File "/usr/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/django'
It does, however work when I try installing on a venv.
Could this have anything to do with $PYTHONPATH?
(I believe this is also causing conflicts when I try to run runserver on an already started project. But I will leave that for another question if this one doesn't resolve it.)
You need to activate your virtual environment first.
$ source PATH_TO_ENV/bin/env
$ pip install django
In a newly created virtualenv there will also be a activate shell script. For Windows systems, activation scripts are provided for the Command Prompt and Powershell.
On Posix systems, this resides in /ENV/bin/
Unless you do this you are using system python and system libs. That's why you see the error.
If you need to install a lib into the system scope you need root access:
$ sudo pip install django
I have a mac that has both Python 2.7.6 installed (by default) and Python 3.4.0 installed (by me).
I think that I may also have multiple versions of PIP installed. (When I run PIP --version I get pip 1.5.6 from /Library/Python/2.7/site-packages/pip-1.5.6-py2.7.egg (python 2.7)
But I know that Python 3 comes with version 1.5.4.
So, my questions are:
A. How do I find out if I have multiple versions of pip installed.
B. If I do have multiple versions installed, how do I specify which one to use, or where the installed packages should go?
I have tried the suggestion outlined here (basically using pip-3.4) but I get command not found
The reason for all of this is that when trying to install any package with pip, even just to update (pip install --upgrade pip) I get the following errors
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 1431, in install
requirement.uninstall(auto_confirm=True)
File "/Library/Python/2.7/site-packages/pip-1.5.6-py2.7.egg/pip/req.py", line 598, in uninstall
paths_to_remove.remove(auto_confirm)
File "/Library/Python/2.7/site-packages/pip-1.5.6-py2.7.egg/pip/req.py", line 1836, in remove
renames(path, new_path)
File "/Library/Python/2.7/site-packages/pip-1.5.6-py2.7.egg/pip/util.py", line 295, in renames
shutil.move(old, new)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 299, in move
rmtree(src)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 247, in rmtree
rmtree(fullname, ignore_errors, onerror)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 252, in rmtree
onerror(os.remove, fullname, sys.exc_info())
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 250, in rmtree
os.remove(fullname)
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pip-1.5.6-py2.7.egg/EGG-INFO/dependency_links.txt'
Storing debug log for failure in /Users/Startec/Library/Logs/pip.log
Just like python is symlinked to your Python 2 version, pip is symlinked to Python 2’s pip.
Instead, use pip3 which should refer to the active Python 3 installation (accessible using python3). You can also use the full version name, but then without a dash: pip3.4.