Django 1.9 Compiling Error - django

I created a virtualenv and downloaded Django with the below commands:
virtualenv tester
source tester/bin/activate
pip install django
and below is the response:
Downloading/unpacking django
Downloading Django-1.9-py2.py3-none-any.whl (6.6MB): 6.6MB downloaded
Installing collected packages: django
Compiling /home/romaan/workspacepy/tester/build/django/django/conf/app_template/apps.py ...
File "/home/romaan/workspacepy/tester/build/django/django/conf/app_template/apps.py", line 4
class {{ camel_case_app_name }}Config(AppConfig):
^
SyntaxError: invalid syntax
Compiling /home/romaan/workspacepy/tester/build/django/django/conf/app_template/models.py ...
File "/home/romaan/workspacepy/tester/build/django/django/conf/app_template/models.py", line 1
{{ unicode_literals }}from django.db import models
^
SyntaxError: invalid syntax
Successfully installed django
Please help me to get rid of this error. All though it says Successfully installed django, I am keen on understanding and getting rid of this syntax error.
Or Should I just wait for the bug fix to happen?

This looks like the setuptools issue mentioned in the Django 1.9 release notes: https://docs.djangoproject.com/en/1.9/releases/1.9/#syntaxerror-when-installing-django-setuptools-5-5-x
Try to run pip install --upgrade pip before running pip install django

Those can't, and shouldn't, be fixed. Those are template files which are substituted at project creation time, and are not valid Python syntax. They shouldn't be compiled at install time but rather at project creation time.

These steps worked for me:
$ sudo python -m pip install --upgrade --force setuptools
$ sudo python -m pip install --upgrade --force pip
$ sudo pip install django==1.9

pip install -U pip ran fine but didn't fix my issue
I got the same message when I was trying pip install django.
I thought to try a previous version so I tried pip install
django-1.9.
It said "Real name of requirement Django-1.9 is django-503".
So pip install Django-503 worked fine for me.

Related

ImageField needs Pillow to be installed

I made a model with ImageField(). But whenever I run python manage.py it says you need to install pillow.ERRORS:
sho.Product.image: (fields.E210) Cannot use ImageField because Pillow is not installed.
HINT: Get Pillow at https://pypi.org/project/Pillow/ or run command "python -m pip
install Pillow".
It did tell you how to fix it , You dont have the pillow library installed so the imagefield wont work unless you run python -m pip install Pillow . Running the command will solve the problem
I think you are using old version of Django old version don't support for ImageField() without installing pillow. just update the Django package by running following command
you must do the following:
1- Update pip
python -m pip install --upgrade pip
2- If you already install Django update by using the following command
pip install --upgrade Django
or you can uninstall it using the following command
pip uninstall Django
3- If you don't install it yet use the following command
python -m pip install Django
4- Type your code
Enjoy
Install Pillow library, pip install Pillow
in your models.py import Pillow as below
from PIL import Image

Error while running PIP command "no module packaging exists"

I have tried many approaches in resolving this issue but still cannot resolve it can someone please help me.
when I try to run the pip to install any new package it is ending in error with the message no module named packaging.version. This is happening in the __init__.py file where there are import command import packaging.version.
I tried to install the packaging package by using the command pip install packaging even that ended in failure with the same error.
Then I tried to install this package using the apt-get command
sudo apt-get install python-packaging but it ended saying could not find the package.
Finally I tried to update the setuptools package to version 33.1.1 as a part of the previous solutions approaches, but can't do it with pip(same issue as above) so I used the apt-get command
sudo apt-get install setuptools=33.1.1 but it is saying no package with this version found error.
I am out of ideas can someone please help. Appreciate your help.
I believe that your version of pip is obsolete. Try running pip install --upgrade pip.
If you cant do it (still the same error), I'd suggest to reinstall pip.
You can do it with get-pip.py file. Here you can find a quick guide: Installing pip setuptools and wheel.
You may also be able to reinstall it with python -m pip install -U pip.

pip is error,TypeError: __call__() takes exactly 2 arguments (1 given)

system
centos 7.2
Python 2.7.5
install
I install webhook
pip install webhook
### but hava error,then
yum install python-devel -y
## go on,pip doesn't workding
pip
error
Enter the command contain pip.Then
[root#location src]# pip
Traceback (most recent call last):
File "/usr/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 72, in <module>
import packaging.requirements
File "/usr/lib/python2.7/site-packages/packaging/requirements.py", line 59, in <module>
MARKER_EXPR = originalTextFor(MARKER_EXPR())("marker")
TypeError: __call__() takes exactly 2 arguments (1 given)
So,what should I do?!
I had the same problem on a fresh virtualenv and apparently this is a conflict between the version requirements for packaging, pip and pyparsing with the new setuptools. What worked for me was to pin down the old one.
pip install setuptools==33.1.1
Update:
As another answer pointed out, pip has already fixed the bug, so you should try upgrading it instead of using the workaround above.
python -m pip install --upgrade --force pip
UPDATE:
Please see the solution lower in this thread by Pedro Werneck instead of this one. It's the correct way to solve the problem.
Preface: I do not recommend this!
This seems to work, but I have no idea what the consequences could be. This is cargo cult programming at its best! I'm only adding it here in case it can help someone in a bind.
I made changes to the file requirements.py where the error occurred. For #hysg, that would be this file:
/usr/lib/python2.7/site-packages/packaging/requirements.py
On me on OS X, it's here:
/Library/Python/2.7/site-packages/packaging/requirements.py
I modified the the offending line by removing the parentheses for the call to MARKER_EXPR, as demonstrated below:
#MARKER_EXPR = originalTextFor(MARKER_EXPR())("marker")
MARKER_EXPR = originalTextFor(MARKER_EXPR)("marker")
And that worked.
Again, please be careful! I don't know what I'm doing and this could potentially cause more harm than good.
this is work well:
python -m pip install --upgrade --force pip
pip install setuptools==33.1.1
This is what worked for me:
pip install setuptools==33.1.1
It downgraded setuptools from 35.0.1 to 33.1.1 and pyparsing 1.5.7 installed!
Use the following command to upgrade pip, which has the bug fixed:
python -m pip install --upgrade --force pip
It worked for me (centos 7, python 2.7).
For more details: GitHub
I applied the fix
pip install setuptools==33.1.1
and it solved the problem for OSX 10.10.5 (Yosemite)
I ran into the same problem on a new virtualenv trying to install. I'm running python 2.7.11 and found the two commands belows solve the versioning problem with setuptools:
This forces a pip upgrade, which has a fix for the bug, but doesn't reinstall setup tools, so I was still running on setuptools version 35.0.1
python -m pip install --upgrade --force pip
This sets setuptools to an older version.
pip install setuptools==33.1.1
After this, I successfully installed my requirements.
None of the other uninstall/reinstall/force answers worked for me, but on OS X 10.10.5 with the system Python 2.7.10, I was able to do:
pip uninstall packaging pip
easy_install pip # this installed pip 1.4.1
pip install --upgrade pip # and this upgraded to the current pip
and I was then able to import pkg_resources without a problem.
Should really learn to stop messing with the system Python…
Actually, I had a problem that OS/system which means root, not sudo, has been the owner of the pip2 package. But after I had executed this command:
sudo apt-get remove python-pip
it worked like a charm.
Noting, of course that I have a debian distribution.
And then I used what Pedro suggested:
sudo pip install setuptools==33.1.1
It worked for me too (centos 7, python 2.7).
python -m pip install --upgrade --force pip
pip install setuptools==33.1.1

Pip installation bug

So I tried to install pip using the get-pip.py file, and when I ran the file, terminal told me I already had pip installed on 2.7. However, when I try to find the version of my pip, terminal tells me pip doesn't exist and points to a version of 3.5 I have installed. Clearly my issue is that I have pip installed on v2.7 but the pip command is linked to v3.5. Any clues on how to fix?
Here's a picture of my terminal output:
To install a package in a particular version of python, use the following commands always:
For python 2.x:
sudo python -m pip install [package]
For python 3.x:
sudo python3 -m pip install [package]
This should resolve the doubt of which python version is the given package getting installed for.
Note: This is assuming you have not created aliases for the python command

Installing specific version of django

I am trying to install django 1.4.3 using pip. I am running
$ sudo pip unistall django
$ sudo pip install django==1.4.3
and I get the following messagin during installation
Requested django==1.4.3, but installing version 1.5.1
I can give more code if needed. Thanks!
I met the same problem while install Twisted.
requiring 10.0.0 but install 13.0.0,
finally I get the 10.0.0 package and download src, mannually installed it.
just change https://pypi.python.org/pypi/Twisted/13.0.0 to https://pypi.python.org/pypi/Twisted/10.0.0
A simple solution is to create a requirements.txt file:
pip freeze > requirements.txt
Then, change the django version inside your requirements.txt
file manually:
Django==1.4.3
and finally run the command:
pip install -r requirements.txt
You should have your required Django version.
Cheers!