pg_config executable not found

I am having trouble installing psycopg2. I get the following error when I try to pip install psycopg2: But the problem is pg_config is actually in my PATH; it runs without any problem: I tried adding the pg_config path to the setup.cfg file and building it using the source files I downloaded from their website (http://initd.org/psycopg/) and I get the following … Read more

use np.random.multinomial() in python

I have a task to randomly chose 100 element from a population of alpha list [a,b,c,d] with corresponding frequency (probability) [0.1, 0.3, 0.2, 0.4]. There are many different ways to do it. But here I want what returned after this function call (suppose there is one) is a list of the number of elements chosen. … Read more

Setting Django up to use MySQL

MySQL support is simple to add. In your DATABASES dictionary, you will have an entry like this: You also have the option of utilizing MySQL option files, as of Django 1.7. You can accomplish this by setting your DATABASES array like so: You also need to create the /path/to/my.cnf file with similar settings from above With this new method of connecting in Django … Read more

AttributeError: Module Pip has no attribute ‘main’

I am trying to build the python api for an open source project called Zulip and I keep running into the same issue as indicated by the screenshot below. I am running python3 and my pip version is 10.0.0. The file in question is setup.py and the code that is messing up is when the pip.main() attribute is accessed … Read more

How to delete last item in list?

If I understood the question correctly, you can use the slicing notation to keep everything except the last item: But a better way is to delete the item directly: Note 1: Note that using record = record[:-1] does not really remove the last element, but assign the sublist to record. This makes a difference if … Read more