Installing pandas in django - django

I have installed numpy and pandas in ubuntu 12.04. Also, I have added django_pandas in my INSTALLED_APPS but then also I am getting
ImportError: No module named django_pandas
how should i proceed now

There are no extra steps you need to take to install "Pandas in Django", just install Django and Pandas using pip:
pip install django
pip install pandas

sorry for the question. i havent correctly executed the command
pip install https://github.com/chrisdev/django-pandas/tarball/master.
after going for the above command it worked fine

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

installing seaborn without sudo

I am trying to install seaborn without using sudo. I have already installed on my python 2.7 and windows 7 setting with the following cmd commands :
pip install pandas
pip install xlrd
pip install matplotlib
and they all were installed like charm.
`pip install seaborn` did not work
i have attached the error message.[last lines of emssage][1]
You may be interested in installing precompiled python wheel binaries for Windows.
That, or use something like Anaconda python.

No module named 'matplotlib.pyplot'; 'matplotlib' is not a package

Have found a similar issue, however haven't found proper solution.
Here's a code:
import matplotlib.pyplot as plt
plt.plot([1,2,3],[4,2,5])
plt.show()
Run, got the message:
ImportError: No module named 'matplotlib.pyplot'; 'matplotlib' is not a package
I run Linux Mint 18 with preinstalled python-2.7 and python-3.5 (I use python3), before that I was installing modules with a simple sudo apt-get install method and that worked great.
Before running this the code above, I've installed matplotlib in a usual way sudo apt-get install python-matplotlib. As it haven't worked out, started to look for solution.
Python location
which python3 /usr/bin/python3
Current Matplotlib installed
sudo find /usr | grep matplotlib /usr/lib/python3/dist-packages/matplotlib
My tries:
1) I've removed matplotlib with autoremove, and tried to make it sudo apt-get install python3-matplotlib instead. Didn't worked out.
2) Used: pip3 install matplotlib or sudo pip3 install matplotlib. Received errors like:
command python setup.py egg_info failed with error code 1 in /tmp/pip-build- ....
3) Then I found another solution:
sudo apt-get install virtualenv
virtualenv -p /usr/bin/python3 py3env
source py3env/bin/activate
pip install matplotlib
Same outcome.
Haven't tried to use import sys sys.path.append('/usr/lib/pymodules/python2.7/')(proposed in link above), but as I am not sure what exactly this command does (quite a newbie to python and programming itself) - haven't risked.
If you are using pycharm and have matplotlib.py in your current working directory than you get this error. Just delete or rename the matplotlib.py file and it will work.
don't name any file as matplotlib.py within your working directory
In your working directory, check if there is any file matplotlib.py
Delete that file and import matplotib again. That should work.
simply install:
python -m pip install -U pip
python -m pip install -U matplotlib
I had the same problem reasons in my case were
python 3.8.2 with matplotlib that I downloaded was for 3.7. Make sure they are the same.
python 64 bits version with matplotlib 32bits. Make sure they are the same
Use python -m pip install package_which_you_need to install packages for Windows
Make sure to add to PATH the environment variables I forgot to do in my case
pip version was old use
Use python -m pip install --upgrade pip to upgrade pip to the latest for Windows
I saved the file name as matplotlib.py. Try to avoid that
Finally I typed matplotlib.pyplot as matplotlib.plyplot remember to check for typos first. The error message looks similar even though I corrected all the steps above.
ModuleNotFoundError: No module named 'matplotlib.pyplot'
ModuleNotFoundError: No module named 'matplotlib.plyplot'

Kivy cannot find PIL module in Mac

OSX 10.10.2, Python 2.7.9, Kivy 1.9
I used sudo pip install Pillow to install Pillow when i get the not found error. I can find PIL in python help('modules') but not in kivy help('modules')
I tried Kivy user group but got no reply yet. Thank you in advance!
Kivy 1.9 package uses it's own Virtual Environment. You have to make sure to install modules into that. Simply do::
kivy -m pip install pillow
Probably kivy is looking for the Pillow package in the wrong place.
You should check where your library is installed and use that path.
The path should be something like "/Library/Python/2.7/site-packages/", look if you have the PIL package in that position.
Then set the PYTHONPATH variable or use
import sys
sys.path.append('path_to_the_PILLOW_package')
and look if "import PIL" raises an ImportError.

Django : Cannot Import name xrange

I am new to python and django. I had django running properly in my machine, till I installed django-haystack. I directly downloaded django-haystack.zip from github and executed 'python setup.py install' in haystack dir. After this whenever I run 'django-admin.py runserver' I am getting the following error : ImportError: cannot import name xrange.
If I remove 'haystack' from INSTALLED_APPS the above command is working fine.
I also cannot run 'python manage.py build_solr_schema' because of the same error.
Let me know how I can resolve this issue.
Solved the issue. Deleted the haystack installation from /usr/local/.../dist-packages/ and used pip install django-haystack to install. That worked fine
This:
http://pypi.python.org/pypi/haystack/
is not the same as this:
http://pypi.python.org/pypi/django-haystack
but if you have them both in your requirements.txt file for some reason, like so:
haystack
django-haystack
and install them into the same virtualenv then you will have problems because they both want to unpack to a directory named 'haystack'. 99% of the time if you're doing django development you don't want that first one at all. So remove it from the requirements.txt file, remove all traces of anything to do with haystack from your virtualenv and then reinstall with:
pip install -r requirements.txt
and you should be good to go.
if you have installed haystack and django-haystack, uninstall both haystacks and install django-haystack
pip uninstall haystack
pip uninstall django-haystack
pip install django-haystack
if you have it installed and still this error appears
uninstall haystack and reinstall it
pip uninstall haystack
#here ask for y/n type y :)
pip install haystack
that works for me