Installing C library in Heroku - django

I'm trying to use GeoIP with Django. It requires the MaxMind GeoIP C API.
If I were using Ruby, I could simply use the 'geoip' gem which bundles the C API and the Ruby bindings, as explained in Installing MaxMind GeoIP ruby library on heroku.
Unfortunately, nothing like this exists for Python, so I'm wondering how I would go about installing the C API from source on Heroku, or if there's the equivalent of a package manager on Heroku (ie. 'brew install geoip' for OS X, and 'sudo apt-get install geoip' for Ubuntu).

You will need to write your own buildpack to compile anything in Heroku, at the time you push code and in your requirements.txt there's a package with a binary requirement. See the python buildpack code to guide your work https://github.com/heroku/heroku-buildpack-python

Related

Linux python django site-packages not recognized in envelope

I have tried to create envelope on my linux pop os system using miniconda. When I activate it, I can install packages using pip, but when I run my django instance it doesn't find the modules.
If I type which python is shows the miniconda path correctly. I can look in the site-packages folder and see the packages installed.
I've tried installing django-anymail and corsheaders and they are both not being found. It does find my locally installed apps.
If I use the command line and open python and then import, it does not recognize my modules installed in the virtual envelope either. I thought it was a problem with conda, so I also created an envelope using python's native method: python3 -m venv
I have the same problem with it finding pip install site-packages.
Is there a command I can run to show all available packages?
I hadn't realized I had aliased my python. Now it is working.

How to install difflib module in python 2.7 windows 10

Currently, I am facing difficulty installing difflib module in python 2.7 version in windows 10 system.
I want it to perform some text analytics analysis
tried using
apt-get install npm
npm install difflib
and
pip.exe install difflib
Solution for me was to save the difflib.py in the location where your .py file resides and then import it in your file.
install using pip should be a great idea, You can refer to the module related details here:
https://docs.python.org/2.7/library/difflib.html
If you face an issue installing it using pip, then the next way is to get the difflib.py from any working machine and keep it in the project directory itself, so that just importing the module itself will work.
This is the codebase reference from svn of python itself:
https://svn.python.org/projects/python/trunk/Lib/difflib.py

How export python project?

Let me explain elaborately what problem I am facing.
1. I am using Windows environment and pycharm IDE for development of python project.
2. As part of development I am going to use several thrid party python packages say pexpect by installing through pip.
3. Once I am done with development I am going to use python project in Linux environment where I can't install any of these python packages.
So please suggest me way to export python project along with thrid party packages , so that without installing any of 3rd party packages I can run my project in Linux environment.
You have to use virtualenv when you are creating a python project with third party apps. virtualenv is a tool to create isolated Python environments. You can export this project and run in any other environment(Linux, Windows, OSX).
Documentation - Virtualenv
Video - Virtualenv Tutorial
You also need to create a requirement.txt file which will contain your all third party apps. Once you are in virtual environment, you could use the below code:
pip freeze > requirement.txt it will create a requirement.txt file.
For installing all the dependencies again, you need to use:
pip install -r requirement.txt

Is it possible to install a django package without pip?

I am trying to install django-dash to run one of the dashboard examples and see what it's like.
I am on Windows running Python 2.7 and Django 1.6.5. I know the usual approach is to download pip then install the package using pip. However, I am on a work computer with no administrative rights so I can't access my Internet Option Settings to find my proxy URL to follow the instructions below:
Proxy problems
If you work in an office, you might be behind a HTTP proxy. If so, set the environment variables http_proxy and https_proxy. Most Python applications (and other free software) respect these. Example syntax:
http://proxy_url:port
http://username:password#proxy_url:port
I had the same issue when trying to install Django but was able to get it to work by moving the django directory under Python27/Lib/site-packages. Is there something similar I can do with django-dash?
I also tried downloading the sources and running python setup.py install. I received the following error:
File "setup.py", line 3, in <module> from setuptools import setup, find_packages ImportError: No module named setuptools
Link to django-dash: http://django-dash.readthedocs.org/en/latest/
Yes, you can probably get the sources from The Python Package Index
Once you have them, uncompress the files and install them manually (this will depend on you OS).
On Linux systems:
python setup.py build
python setup.py install
Here's the full reference
EDIT : Note that when manually installing those packages, you must also install any missing dependencies, eg. setuptools in your case

using dajaxice and editlive apps in django

So I am pretty new to Django and I am a little confused on how to install apps.
I am trying to get the editlive app to work in Django. This requires dajaxice to also be installed. Both of the instructions for this are very similar, basically it says to change some things in settings.py, urls.py, and add some imports to your main.html.
I did these things, but the instructions don't say what I am supposed to do with the dajaxice, and editlive packages. In each package there is a install.py, should I build and run this? Or am I supposed to just include all the code in with my project?
The python/django community uses a tool called pip to install python packages and libraries. Look up how to install pip on your system (and also look up virtualenv), and then you can simply do:
pip install django-dajaxice
pip install django-editlive