Skip to content

Tag: python-2.7

Dynamically creating Django models with `type`

I have 20+ MySQL tables, prm_a, prm_b, … with the same basic structure but different names, and I’d like to associate them with Django model classes without writing each one by hand. So, feeling ambitious, I thought I’d try my hand at using type() as a class-factory: The following works: But…

How to get PID by process name?

Is there any way I can get the PID by process name in Python? For example I need to get 3110 by chrome. Answer You can get the pid of processes by name using pidof through subprocess.check_output: check_output([“pidof”,name]) will run the command as “pidof process_name”, If the return …

nltk download url authorization issue

I tried to update my nltk data with nltk.download() but I got HTTP Error 401: Authorization Required. When I traced the url in question, I found it in downloader.py DEFAULT_URL = ‘http://nltk.googlecode.com/svn/trunk/nltk_data/index.xml’ I then copied that URL and ran it in my browser to find out …

ImportError: No module named scipy

I am using Python 2.7 and trying to get PyBrain to work. But I get this error even though scipy is installed – I have installed scipy using this command – I get – What should I do? Answer Try to install it as a python package using pip. You said you already tried: Now run: I ran both and