Q_CreationDate stringlengths 23 23 | Title stringlengths 11 149 | Question stringlengths 25 6.53k | Answer stringlengths 15 5.1k | Score float64 -1 1.2 | Is_accepted bool 2
classes | N_answers int64 1 17 | Q_Id int64 0 6.76k |
|---|---|---|---|---|---|---|---|
2014-04-10 18:48:30.837 | How to search in one NumPy array for positions for getting at these position the value from a second NumPy array? | I have two raster files which I have converted into NumPy arrays (arcpy.RasterToNumpyArray) to work with the values in the raster cells with Python.
One of the raster has two values True and False. The other raster has different values in the range between 0 to 1000. Both rasters have exactly the same extent, so both N... | If I understand your description right, you should just be able to do B[A]. | 1.2 | true | 1 | 3,143 |
2014-04-11 01:26:13.200 | Counting 1's in a n x n array of 0's and 1's | Assuming that in each row of the array, all 1's come before the 0's, how would I be able to come up with an (O)nlogn algorithm to count the 1's in the array. I think first I would have to make a counter, search each row for 1's (n), and add that to the counter. Where does the "log n part" come into play? I read that a ... | Since all 1's come before the 0's, you can find the index of the first 0 using Binary search algorithm (which is log N) and you just have to do this for all the N rows. So the total complexity is NlogN. | 1.2 | true | 1 | 3,144 |
2014-04-11 13:46:24.623 | Performance Improvements with Processes or Threads | I've written a script that pulls data from my school's website and I'm having some trouble with execution time.
There are over 20 campuses, each with data for three semesters. The script looks up those school names, then the semesters available for each school, then the subjects/departments that are offering classes e... | In python you want multiprocessing over multithreading. Threads don't do well in Python beacause of the GIL. | 0 | false | 1 | 3,145 |
2014-04-12 10:07:33.580 | How to use tornado as both a socket server and web server? | I know the httpserver module in tornado is implemented based on the tcpserver module, so I can write a socket server based on tornado. But how can I write a server that is both a socket server and a web server?
For example, if I want to implement a chat app. A user can either login through a browser or a client progra... | You can start multiple servers that share an IOLoop within the same process. Your HTTPServer could listen on one port, and the TCPServer could listen on another. | 1.2 | true | 1 | 3,146 |
2014-04-12 13:42:05.423 | how to install python package in Raspbian? | I'm trying to install pycrypto for python 3.x.x on raspberry pi
but when i run python setup.py install
from the command line, it is by default installed to python 2.7.x
i have installed python-dev and still with no luck, i have read that using a PIP might help, but unfortunately i don't know how to use it. all my codes... | Having looked into it there does not seem to be a pycrypto version for python3 at the moment. I think you're options are to look for an alternative package or to convert your code to python 2. There are tools available which can do this automatically, for example 3to2 is available in pip. | 0 | false | 1 | 3,147 |
2014-04-13 01:48:02.487 | Installing Leap Motion sdk into Enthought SDK | I am trying to install the leap motion sdk into Enthought Canapy. The page called Hello World on leap motion mentions i need to put these four files:
Sample.py, Leap.py, LeapPython.so and libLeap.dylib
into my "current directory". I don't know how to find my current directory. I have tried several things including typi... | Try this:
Put the four files into one folder.
Right click on the Sample.py until it says "Open with" and gives some choices.
Select Python Launcher.app (2.7.6) # This version of Python Launcher must match the Mac built in Python Version.
If your version of LeapPython.so is constructed correctly, it should run. | 0 | false | 1 | 3,148 |
2014-04-14 21:37:35.363 | Compile pymunk on mac OS X | I have downloaded pymunk module on my computer. When I typed in "python setup.py install" in terminal, it says "no such file or directory", then I typed in the complete path of setup.py instead of setup.py, and it still could not run since the links to other files in the code of setup.py are not complete paths. (Like R... | Try and go to the folder where setup.py is first and then do python setup.py install. As you have noticed, it assumes that you run it from the same folder as where its located. | 1.2 | true | 1 | 3,149 |
2014-04-15 15:36:52.237 | how to specify version of python to run a script? | I'm learning python now using a mac which pre-installed python 2.7.5. But I have also installed the latest 3.4.
I know how to choose which interpreter to use in command line mode, ie python vs python 3 will bring up the respective interpreter.
But if I just write a python script with this header in it "#!/usr/bin/pyth... | You know, you can start python with py -specific version
To run a script on interpreter with a specific version you'll just start your script with following parameters, py yourscript.py -version | 0.296905 | false | 1 | 3,150 |
2014-04-15 23:59:55.517 | How do I break down files in a similar way to torrents? | I am trying to make a program that breaks down files like HTML or CSS into chunks like that of a torrent. I am completely unsure how to do this. They need to be broken down, than later reassembled in order. anybody know how to do this?
It doesn't have to be in Python, that was just my starting point. | It's trivial to "break down" files as you put it. You'll need an algorithm to disassemble them, and then to reassemble them later, presumably by a browser since you mentioned HTML and CSS. Bittorrents implements this, and additionally the ability upload and download from a distributed "swarm" of peers also interested i... | 0 | false | 1 | 3,151 |
2014-04-16 01:51:04.360 | How to structure my Python code? | I apologize in advance for this being a bit vague, but I'm trying to figure out what the best way is to write my program from a high-level perspective. Here's an overview of what I'm trying to accomplish:
RasPi takes input from altitude sensor on serial port at 115000 baud.
Does some hex -> dec math and updates state ... | I don't think that RasPi would work that well running multithreaded programs. Try the first method, though it would be interesting to see the results of a multithreaded program. | 0 | false | 1 | 3,152 |
2014-04-16 03:42:19.920 | Opening notebook with Ipython 2.0 in Firefox yields only a blank screen | I upgraded from Ipython 1.2.1 to Ipython 2.0. When I try to open an existing notebook or create a new notebook in Firefox, I only get a blank screen. There is no error message in the terminal window that I used to start the notebook server. This happens on CentOs 6.5 with Python 2.7.5 and Firefox 24.4 as well as on Mac... | I found that the problem occurs when changing the cookie preference "Keep until:" " they expire" to "ask me every time" (in Preferences->Privacy->History). As soon as I switch to "they expire" or "I close Firefox" and reload the page with my notebook, it renders as expected and the notebook is shown as running. Creatin... | 0 | false | 1 | 3,153 |
2014-04-16 09:05:35.220 | Embedding IronPython's stdlib in VS extension | I'm currently writing a Visual Studio extension, which provides scripting capabilities. I'm using IronPython (the newest one), but I have some problems with Python's standard libraries.
As I understand, all necessary files reside in the <IronPython folder>\Lib folder. I cannot rely on my users installing IronPython, so... | I would presume that there is a way to include them in the VSIX file and also know where they are on disk - at least, you could use AppDomain.CurrentDomain.GetAssemblies() for find the IronPython assembly and Assembly.Location to find where it is, and hope the VSIX puts the Lib directory near that. (My only experience ... | 1.2 | true | 1 | 3,154 |
2014-04-16 13:13:32.607 | How do I find the slope (m) for a line given a point (x,y) on the line and the line's angle from the y axis in python? | I understand that the equation for a straight line is:
y = (m * x) + c
where m is the slope of the line which would be (ydelta/xdelta) but I dont know how to get this value when I only know a single point and an angle rather than two points.
Any help is appreciated. Thanks in advance. | Okay, let's say your point is (x,y)=(1,2)
Then you want to solve 2 = m + c. Obviously there is no way you can do this. | -0.135221 | false | 3 | 3,155 |
2014-04-16 13:13:32.607 | How do I find the slope (m) for a line given a point (x,y) on the line and the line's angle from the y axis in python? | I understand that the equation for a straight line is:
y = (m * x) + c
where m is the slope of the line which would be (ydelta/xdelta) but I dont know how to get this value when I only know a single point and an angle rather than two points.
Any help is appreciated. Thanks in advance. | With just a single point (and nothing else) you cannot solve such a problem, there are infinitely many lines going through a single point.
If you know the angle to x axis then simply m=tan(angle) (you do not need any points to do that, point is only required to figure out c value, which should now be simple).
To conver... | 1.2 | true | 3 | 3,155 |
2014-04-16 13:13:32.607 | How do I find the slope (m) for a line given a point (x,y) on the line and the line's angle from the y axis in python? | I understand that the equation for a straight line is:
y = (m * x) + c
where m is the slope of the line which would be (ydelta/xdelta) but I dont know how to get this value when I only know a single point and an angle rather than two points.
Any help is appreciated. Thanks in advance. | The equation of a line is y = mx + c.
You are given a point on this line, and the angle of this line from the y-axis.
The gradient m will be math.cot(angle_in_radians). The x and y values will be the same as your given point. To find c, simply evaluate y - mx. | 0 | false | 3 | 3,155 |
2014-04-16 18:21:50.753 | Python OpenCV "ImportError: undefined Symbol" or Memory Access Error | I'm using OpenSUSE 13.1 64-bit on an Lenovo ThinkPad Edge E145.
I tryed to play a bit around with Python(2.7) and Python-OpenCV(2.4). Both is installed by using YAST.
When i start the Python-Interactive-Mode (by typing "python") and try to "import cv" there are 2 things that happen:
case 1: "import cv" --> End's up wit... | Not exactly a prompt answer (nor a direct one). I had the same issue and (re)installing various dependencies didn't help either.
Ultimately, I cloned (from git) and compiled opencv (which includes the cv2.so library) from scratch, replaced the old cv2.so library and got it to work.
Here is the git repo: https://github.... | 0 | false | 1 | 3,156 |
2014-04-17 09:07:18.350 | Google Analytics reports API - Insufficient Permission 403 | I am trying to access data from google-analytics. I am following the guide and is able to gauthorize my user and get the code from oauth.
When I try to access data from GA I only get 403 Insufficient Permission back. Do I somehow have to connect my project in Google API console to my analytics project? How would I do ... | You should use View ID Not account ID, the 'View ID', you can go:
Admin -> Select Site -> Under "View" -> View Settings , if it doesn't works
you can go: Admin->Profiles->Profile Settings | 0 | false | 2 | 3,157 |
2014-04-17 09:07:18.350 | Google Analytics reports API - Insufficient Permission 403 | I am trying to access data from google-analytics. I am following the guide and is able to gauthorize my user and get the code from oauth.
When I try to access data from GA I only get 403 Insufficient Permission back. Do I somehow have to connect my project in Google API console to my analytics project? How would I do ... | Had the same problem, but now is solved.
Use View ID Not account ID, the 'View ID', can be found in the Admin->Profiles->Profile Settings tab
UPDATE
now, if you have more a account , you must go: Admin -> Select account -> under View-> click on View Settings | 1.2 | true | 2 | 3,157 |
2014-04-18 03:41:12.857 | Creating Family Trees Using Python | I ve recently started with python and am working on building a Family tree using python. My idea is that the tree should grow in both sides, i.e) both the older generations as well as younger generations can be added to the same tree.
I tried implementing with Binary tree ADT and N-ary tree ADT, but that doesn't work ... | After searching a lot, I found that the Graph ADT suits the above problem better. Since a family has relations over a wide span in all directions, using a graph ADT would be conventional.
Each node can store details about a person.
Node can consist of parent node links, and some functionalities
to find rel... | 1.2 | true | 1 | 3,158 |
2014-04-18 12:26:26.120 | google endpoint custom auth python | I'm trying to implement a secure google cloud endpoint in python for multi-clients (js / ios / android)
I want my users to be able to log by three ways loginForm / Google / Facebook.
I read a lot of docummentation about that but I didn't realy understood how I have to handle connection flow and session (or something el... | For request details, add 'HttpServletRequest' (java) to your API function parameter.
For Google authentication, add 'User' (java) to your API function parameter and integrate with Google login on client.
For twitter integration, use Google app-engine OpenID.
For facebook/loginForm, its all on you to develop a custom au... | 1.2 | true | 1 | 3,159 |
2014-04-19 05:16:08.020 | Make python script to run forever on Amazon EC2 | I have a python script that basically runs forever and checks a webpage every second and notifies me if any value changes. I placed it on an AWS EC2 instance and ran it through ssh. The script was running fine when I checked after half an hour or so after I started it.
The problem is that after a few hours when I chec... | You can run the program using the nohup command, so that even when the SSH session closes your program continues running.
Eg: nohup python yourscriptname.py &
For more info you can check the man page for it using
man nohup. | 1 | false | 1 | 3,160 |
2014-04-19 05:45:15.857 | Replacing Python 2.7.5 with Python 3.4 on OS X 10.9.2 | I have Python 2.7.5 running on OS X 10.9.2.
I downloaded the Python installer "python-3.4.0-macosx10.6.dmg" from python.org.
After the installation, I still get 2.7.5 when querying python -V.
I am not sure what I need to do to replace 2.7.5 with 3.4 besides installing python-3.4.0-macosx10.6.dmg. | I simply replaced the executable link in my IDE from "/usr/bin/python" to "/Library/Frameworks/Python.framework/Versions/3.4/bin". | 0 | false | 1 | 3,161 |
2014-04-19 17:49:18.547 | Parameters to let random_powerlaw_tree() generate trees with more than 10 nodes | I am trying to use one of the random graph-generators of NetworkX (version 1.8.1):
random_powerlaw_tree(n, gamma=3, seed=None, tries=100)
However, I always get this error
File "/Library/Python/2.7/site-packages/networkx/generators/random_graphs.py", line 840, in random_powerlaw_tree
"Exceeded max (%d) attempts for a va... | To generate trees with more nodes it is only needed to increase the "number of tries" (parameter of random_powerlaw_tree). 100 tries is not enough even to have a tree with 11 nodes (it gives an error). For example, with 1000 tries I manage to generate trees with 100 nodes, using networkX 1.8.1 and python 3.4.0 | 0.386912 | false | 1 | 3,162 |
2014-04-20 16:17:22.563 | How do I get xhtml2pdf working on GAE? | I am new to GAE, web dev and python, but am working my way up.
I have been trying to get xhtml2pdf working on GAE for some time now but have had no luck. I have downloaded various packages but keep getting errors of missing modules. These errors vary depending on what versions of these packages and dependencies I use... | I got it now! Don't use XHTML2PDF - use ReportLab on its own instead. | 0 | false | 1 | 3,163 |
2014-04-21 04:42:08.933 | How to pass variable in one .py cgi to other python cgi script | I want to pass a variable in one python cgi script to other cgi script? how can i do this as in php. using url or something...?
i saved variable in text file, thus read and get saved variable when other page load
Is this method good? | Traditionally this is done using cookies or hidden form fields. | 1.2 | true | 1 | 3,164 |
2014-04-21 05:16:46.203 | Accessing localhost from windows browser | I am running python 2.7 + bottle on cygwin and I wanted to access a sample webpage from chrome.
I am unable to access the website running on http://localhost:8080/hello but when I do a curl within cygwin I am able to access it.
Error Message when accessing through Chrome
Connection refused
Description: Connection refus... | Since you get a connection refused error, the best I can think of is that this is a browser issue. Try editing the LAN settings on your Chrome browser to bypass proxy server for local address. | 1.2 | true | 1 | 3,165 |
2014-04-23 07:17:29.727 | Collecting Data from Database, functions vs classes | I searched around and couldn't really find any information on this. Basically i have a database "A" and a database "B". What i want to do is create a python script (that will likely run as a cron job) that will collect data from database "A" via sql, perform an action on it, and then input that data into database "B".
... | Would a Class be better for this?
Probably not.
Classes are useful when you have multiple, stateful instances that have shared methods. Nothing in your problem description matches those criteria.
There's nothing wrong with having a script with a handful of functions to perform simple data transfers (extract, transfor... | 0.999329 | false | 1 | 3,166 |
2014-04-23 13:34:19.803 | Condtionally selecting values from a Numpy array returned from PyFITS | I have opened a FITS file in pyfits. The HEADER file reads XTENSION='BINTABLE' with DIMENSION= 52989R x 36C with 36 column tags like, 'ZBEST', 'ZQUALITY', 'M_B', 'UB', 'PGAL' etc.
Now, I have to choose objects from the data with 'ZQUALITY' greater than 2 & 'PGAL' equals to 3. Then I have to make a histogram for the 'ZB... | The expression data.field[('zquality' > 2) & ('pgal'==3)] is asking for fields where the string 'zquality' is greater than 2 (always true) and where the string 'pgal' is equal to 3 (also always false).
Actually chances are you're getting an exception because data.field is a method on the Numpy recarray objects that PyF... | 0.386912 | false | 1 | 3,167 |
2014-04-24 01:28:09.183 | What is the Translastion Process of Java? | So my question today is about the translation process of Java. I understand the general translation process itself but I am not too sure how it applies to Java.
Where does the lexical analysis take place? When is symbol table created? When is the syntax analysis and how is the syntax tree created?
From what I have alr... | All of the translation process is done when you compile a Java program. This is no different than compiling a C++ program or any other compiled language. The biggest difference is that this translation is targeted to the Java Byte Code language rather than assembly or machine language. The Byte Code undergoes its own t... | 0 | false | 1 | 3,168 |
2014-04-24 07:41:13.530 | How does auto-login Outlook successfully when in AD environment? | When I logon to my company's computer with the AD username/password, I find that my Outlook will launch successfully. That means the AD authentication has passed.
In my opinion, outlook retrieves the AD user information, then sends it to an LDAP server to verify.
But I don't know how it retrieves the information, or by... | You are right, there is an ongoing communication between your workstation and the Active Directory server, which can use LDAP protocol.
Since I don't know what you tried so far, I suggest that you look into the python module python-ldap. I have used it in the past to connect, query and modify information on Active-Dire... | 0 | false | 1 | 3,169 |
2014-04-24 11:55:22.790 | How to display data from a database file onto pyqt so that the user can add/delete/edit the data? | I have made a database file using SQL commands in python. i have used quite a lot of foreign keys as well but i am not sure how to display this data onto qt with python? any ideas? i would also like the user to be able to add/edit/delete data | This question is a bit broad, but I'll try answering it anyway. Qt does come with some models that can be connected to a database. Specifically classes like QSqlTableModel. If you connect such a model to your database and set it as the model for a QTableView it should give you most of the behavior you want.
Unfortunate... | 0.201295 | false | 1 | 3,170 |
2014-04-25 09:14:17.847 | Pass Data From Python To Html Tag | I am developing a project on Python using Django. The project is doing lot of work in the background so i want to notify users what's going on now in the system. For this i have declared a p tag in HTML and i want to send data to it.
I know i can do this by templates but i am little confused as 5 functions need to pas... | Part of your page that contains the paragraph tags is a piece of JavaScript that contains a timer.
Every once in a while it does an Ajax request to get the data with regard to "what's going on now in the system".
If you use the Ajax facilites of JQuery, which is probably the easiest, you can pass a JavaScript callback ... | 1.2 | true | 1 | 3,171 |
2014-04-26 03:40:23.467 | how to identify http response belongs to which particular request through python? | I am trying to write my own proxy extensions. Both, burp suite as well as mitmproxy allows us to write extensions.
Till now, I am successful with intercepting the request and response headers, and write it to my own output file.
The problem is, I get frequent requests and responses at anonymous time and at the same ti... | In mitmproxy 0.10, a flow object is passed to the response handler function. You can access both flow.request and flow.response. | 0.386912 | false | 1 | 3,172 |
2014-04-26 13:00:01.593 | Python pseudo service | I am writing a python 'sensor'. The sensor spawns two children, one that reads in data and the other processes and outputs the data in db format. I need to run it in the background with the ability to start, stop pretty much as a service/daemon. I've looked at various options: daemonizing, init scripts etc. The problem... | The communication with daemons is usually done by signals. You can use userdefined signals or SIGSTOP(17) and SIGCONT(19) to pause and continue your daemon. | 1.2 | true | 1 | 3,173 |
2014-04-27 03:43:00.980 | Hash Mapping and ECMP | I would like to know , how an ECMP and hash mapping are used in load balancing or routing of a tcp packet .Any help with links,examples or papers would be really useful. Sorry for the inconvinience , as I am completely new to this type of scenario.
Thanks for your time and consideration. | Typical algorithms split the traffic into semi-even groups of N pkts, where N is the number of ECMP links. So if the pkt sizes differ, or if some "streams" have more pkts than others, the overall traffic rates will not be even. Some algorithms factor for this. Breaking up or moving strean is bad (for many reasons). ... | 0 | false | 1 | 3,174 |
2014-04-27 17:13:51.513 | learn a threshold from labels and discrimination values? | I have a set of {(v_i, c_i), i=1,..., n}, where v_i in R and c_i in {-1, 0, 1} are the discrimination value and label of the i-th training example.
I would like to learn a threshold t so that the training error is the minimum when I declare the i-th example has label -1 if v_i < t, 0 if v_i=t, and 1 if v_i>t.
How ca... | Sort the points, group them by value, and try all <=2n+1 thresholds that classify differently (<=n+1 gaps between distinct data values including the sentinels +-infinity and <=n distinct data values). The latter step is linear-time if you try thresholds lesser to greater and keep track of how many points are misclassif... | 0.386912 | false | 1 | 3,175 |
2014-04-27 18:58:09.147 | Refresh same page with ajax with different data | I have a web page with a form each time a form is submitted same page loads but with different data relevant to the query. On the back-end i am using python for finding data relevant to query.
I want to process all this with ajax as back-end process needs more time so i need to show status to the user i -e whats going ... | You can use jQuery, which gives you a very simple way to do that:
$.post( "yourpage.html", $('form').serialize() + "&ajax=true", function(response) {
$('#results').html(response);
});
Server side, detect if ajax is true and then return only the query results instead of the whole page. They will be saved in the elem... | 1.2 | true | 1 | 3,176 |
2014-04-27 21:10:11.733 | Python OSX $ which Python gives /Library/Frameworks/Python.framework/Versions/2.7/bin/python | Hello I'm trying to run twisted along with python but python cannot find twisted.
I did run $pip install twisted successfully but it is still not available.
ImportError: No module named twisted.internet.protocol
It seems that most people have $which python at /usr/local/bin/python
but I get /Library/Frameworks/Pytho... | I too was getting a ImportError: No module named xxxeven though I did a pip install xxx and pip2 install xxx.
pip2.7 install xxx worked for me. This installed it in the python 2.7 directory. | 0 | false | 1 | 3,177 |
2014-04-29 13:27:05.123 | Modifying a .py file within Python | I have a program that imports a .py file that contains lists and dictionaries and uses them in the program. I am making another program that's purpose is to change the lists and dictionaries in this database .py file (either adding or removing parts of the lists/dictionaries). How would I go about doing this? Do i need... | You can use SQLite or Pickle module instead, to allow easier data retrieval/manipulation from multiple programs/scripts. | 0 | false | 1 | 3,178 |
2014-04-29 20:42:10.627 | Simplest way to communicate between Python and C# using IPC? | I have some C# code that needs to call a Python script several thousand times, each time passing a string, and then expecting a float back. The python script can be run using ANY version of Python, so I cannot use Iron python. It's been recommended that I use IPC named pipes. I have no experience with this, and am havi... | Based on the what you have said, you can connect to the python process and catch standard output text. Easy, fast and reliable! | 0 | false | 1 | 3,179 |
2014-04-30 12:53:12.733 | pygtk spinbutton "greek" floating point | I'm trying to use the data collected by a form I to a sqlite query. In this form I've made a spin button which gets any numeric input (ie. either2,34 or 2.34) and sends it in the form of 2,34 which python sees as str.
I've already tried to float() the value but it doesn't work. It seems to be a locale problem but someh... | AFAIK, WinXP supports setlocale just fine.
If you want to do locale-aware conversions, try using locale.atof('2,34') instead of float('2,34'). | 1.2 | true | 1 | 3,180 |
2014-04-30 16:31:36.293 | Categorizing points using known distributions | My problem is as follows:
I am given a number of chi-squared values for the same collection of data sets, fitted with different models. (so, for example, for 5 collections of points, fitted with either a single binomial distribution, or both binomial and normal distributions, I would have 10 chi-squared values).
I woul... | The principled way to do this is to assign probabilities to different model types and to different parameters within a model type. Look for "Bayesian model estimation". | 1.2 | true | 1 | 3,181 |
2014-04-30 19:47:54.360 | How to determine the "sentiment" between two named entities with Python/NLTK? | I'm using NLTK to extract named entities and I'm wondering how it would be possible to determine the sentiment between entities in the same sentence. So for example for "Jon loves Paris." i would get two entities Jon and Paris. How would I be able to determine the sentiment between these two entities? In this case shou... | In short "you cannot". This task is far beyond simple text processing which is provided with NLTK. Such objects relations sentiment analysis could be the topic of the research paper, not something solvable with a simple approach. One possible method would be to perform a grammar analysis, extraction of the conceptual r... | 0.386912 | false | 1 | 3,182 |
2014-04-30 23:38:54.253 | ipython console2 no module named Ipython | I've been using ipython notebook with console2 for a while now and recently installed a different version of python and now my console is giving me an error saying "No module named IPython". I think the path has been changed or something, but I don't know how to fix it. Any help is greatly appreciated! | I am pulling the answer out of the comments.
Point your PATH system variable to the correct version of Python. This is accomplished (on Windows) by going to System Properties -> Advanced -> Environment Variables. If you already have a Python directory in there, modify it to the correct, new path. Otherwise, append it t... | 1.2 | true | 1 | 3,183 |
2014-05-02 11:20:36.767 | Products are not shown if the user is not logged in | I am trying to develop a small project to learn how mezzanine and cartridge work.
I have the problem that items in the shop are listed only if I am logged in, while I'd like to be able to show them to unauthorized users.
Is there a setting that has to be toggled? | The products most likely aren't published, but can be previewed by an authenticated administrator.
Check the "status" and "published from" fields for each product. | 1.2 | true | 1 | 3,184 |
2014-05-03 04:49:07.233 | how to prevent the window from self-close when building program in sublime | I was learning python use sublime text2 dev.
when I code "hello world" and build it, the "cmd"window appears and disappears in a moment.
I want to make the output hold on,but I don't know how.
help me, thank you. | Just add raw_input("Press ENTER to exit") and it will "pause" until you press a key. You should be able to add this line anywhere and as often as needed. | 0 | false | 1 | 3,185 |
2014-05-04 09:16:36.007 | How to start a privileged process through web on the server? | I have created a web-app using Python Flask framework on Raspberry Pi running Raspbian. I want to control the hardware and trigger some sudo tasks on the Pi through web.
The Flask based server runs in non-sudo mode listening to port 8080. When a web client sends request through HTTP, I want to start a subprocess with s... | Best practice is to never do this kind of thing. If you are giving sudo access to your pi from internet and then executing user input you are giving everyone in the internet the possibility of executing arbitrary commands in your system. I understand that this is probably your pet project, but still imagine someone get... | 0 | false | 1 | 3,186 |
2014-05-05 08:33:08.513 | Django: Atomic operations on a directory in media storage | Our Django project provides interfaces to users to create repository
create new repo
add new changes to existing repo
Any user can access any repo to make changes directly via an HTTP POST containing changes.
Its totally fine if the traffic is less. But if the traffic increases up to the point that multiple users wan... | This is something you should fix at the web application level, not at the Mercurial level. If you're fine with having people wait you set up a distributed locking scheme where the web worker thread tries to acquire a repository-specific lock from shared memory/storage before taking any actions. If it can't acquire th... | 0 | false | 1 | 3,187 |
2014-05-07 09:31:13.477 | How to install cabot in linux | I have downloaded and unzip the cabot(python tool) in my linux system.But then I don't know how to install it.In the cabot folder there is setup.sh file. But when I put build or install it is not working.So What to do? | .sh is a shell script, you can just execute it.
./setup.sh | 0 | false | 2 | 3,188 |
2014-05-07 09:31:13.477 | How to install cabot in linux | I have downloaded and unzip the cabot(python tool) in my linux system.But then I don't know how to install it.In the cabot folder there is setup.sh file. But when I put build or install it is not working.So What to do? | It's an ".sh" file right?
Then to run the same what you have to do is :-
1)Open Terminal
2)Change directory to file location
3) run the following command.
sh setup.sh | 0 | false | 2 | 3,188 |
2014-05-07 10:26:14.687 | How to delete some file with crontab in linux | I have two questions about using crontab file:
1.I am using a service. When it runs, a new log file created everyday in a log directory. i want to delete all files that already exist greater 5 day in that log directory
2.I want to delete all the infomation that exist greater than 5 days in a log file( /var/log/syslog)
... | If you are using logrotate for log rotation then it has options to remove old files, if not you could run something as simple as this once a day in your cron:
find /path/to/log/folder -mtime +5 -type f -exec rm {} \;
Or more specific match a pattern in the filename
find . -mtime +5 -type f -name *.log -exec ls -l ... | 1.2 | true | 1 | 3,189 |
2014-05-07 19:25:58.313 | scrapyd pool_intervel to scheduler a spider | I want to make my spider start every three hours.
I have a scrapy confinguration file located in c:/scrapyd folder.
I changed the poll_interval to 100
the spider works, but it didn't repeat each 100 seconds.
how to do that please? | Maybe you should do a cron job that executes every three hours and performs a curl call to Scrapyd to schedule the job. | 0.386912 | false | 1 | 3,190 |
2014-05-08 02:09:44.840 | Run python from virtualenv in org file & HTML5 export in org v.7.9.3 | I'm running into a few issues on my Emacs + Org mode + Python setup. I thought I'd put this out there to see if the community had any suggestions.
Virtualenv:
I'm trying to execute a python script within a SRC block using a virtual environment instead of my system's python implementation. I have a number of libraries i... | Reads like a bug, please consider reporting it at emacs-orgmode@gnu.org
As a workaround try setting the virtualenv at the Python-side, i.e. give PYTHONPATH as argument.
Alternatively, mark the source-block as region and execute it the common way, surpassing org | 0 | false | 1 | 3,191 |
2014-05-08 20:24:22.863 | django-celery infrastructure over multiple servers, broker is redis | Currently we have everything setup on single cloud server, that includes:
Database server
Apache
Celery
redis to serve as a broker for celery and for some other tasks
etc
Now we are thinking to break apart the main components to separate servers e.g. separate database server, separate storage for media files, web ser... | Celery actually makes this pretty simple, since you're already putting the tasks on a queue. All that changes with more workers is that each worker takes whatever's next on the queue - so multiple workers can process at once, each on their own machine.
There's three parts to this, and you've already got one of them.
S... | 0.545705 | false | 2 | 3,192 |
2014-05-08 20:24:22.863 | django-celery infrastructure over multiple servers, broker is redis | Currently we have everything setup on single cloud server, that includes:
Database server
Apache
Celery
redis to serve as a broker for celery and for some other tasks
etc
Now we are thinking to break apart the main components to separate servers e.g. separate database server, separate storage for media files, web ser... | What will strongly simplify your processing is some shared storage, accessible from all cooperating servers. With such design, you may distribute the work among more servers without worrying on which server will be next processing step done.
Using AWS S3 (or similar) cloud storage
If you can use some cloud storage, lik... | 0.673066 | false | 2 | 3,192 |
2014-05-09 14:53:12.973 | PYQTGraph application slows down when mouse moves over application | I have a multi-threaded (via pyqt) application which plots realtime data (data is processed in the second thread and passed to the gui thread to plot via a pyqt-signal). If I place the mouse over the application it continues to run at full speed (as measured by the time difference between calls to app.processEvents()).... | It's likely you have items in the scene that accept their own mouse input, but it's difficult to say without seeing code. In particular, be wary of complex plot lines that are made clickable--it is very expensive to compute the intersection of the mouse cursor with such complex shapes.
The best (some would say only) w... | 0.673066 | false | 1 | 3,193 |
2014-05-09 19:27:18.923 | How do I get IDLE to find NLTK? | Programming noob here. I'm on Mac OS 10.5.8. I have Python 2.7.6 and have installed NLTK. If I run Python from Terminal, I can "import nltk" with no problem. But if I open IDLE (either from Terminal or by double-clicking on the application) and try the same thing there, I get an error message, "ImportError: No module n... | Supplementing the answer above, when you install python packages they will install under the default version of python you are using. Since the module imports in python 2.7.6 make sure that you aren't using the Python 3 version of IDLE. | 0.201295 | false | 1 | 3,194 |
2014-05-10 04:49:40.817 | IPython 2.0 Notebook: where has the "Add Cell Above" button gone, and how do I get it back? | I upgraded to IPython 2.0 today.
Alot of changes seem good, but the button to insert a new cell, above/below seems to be gone.
The option is still in the menu, and I believe the keyboard short cut works.
But the button is gone.
I'm sure there is a way to turn it back on, but the documentation for the new version doesn'... | as now in 5.7.4 version shortcut to create cell above is esc + a | 0 | false | 1 | 3,195 |
2014-05-10 15:40:16.860 | Can web2py be made to allow exceptions to be caught in my PyCharm debugger? | I'm just starting to build a web app with web2py for the first time. It's great how well PyCharm integrates with web2py.
One thing I'd like to do, however, is avoid the web2py ticketing system and just allow exceptions to be caught in the normal way in PyCharm. Currently, any attempt to catch exceptions, even via an ... | I figured this out by looking through the web2py source code. Apparently, web2py is set up to do what I want to do for a particular debugger, seemingly called Wing Db. There's a constant env var ref in the code named WINGDB_ACTIVE that, if set, redirects exceptions to an external debugger.
All I had do to was define ... | 1.2 | true | 1 | 3,196 |
2014-05-10 23:57:59.530 | Efficient algorithm for determining values not as frequent in a list | I am building a quiz application which pulls questions randomly from a pool of questions. However, there is a requirement that the pool of questions be limited to questions that the user has not already seen. If, however, the user has seen all the questions, then the algorithm should "reset" and only show questions t... | Why not have two lists, one for questions not yet picked and one for questions that have been picked. Initially, the not-yet-picked list will be full, and you will pick elements from it which will be removed and added to the picked list. Once the not-yet-picked list is empty, repeat the same process as above, this time... | 0.386912 | false | 2 | 3,197 |
2014-05-10 23:57:59.530 | Efficient algorithm for determining values not as frequent in a list | I am building a quiz application which pulls questions randomly from a pool of questions. However, there is a requirement that the pool of questions be limited to questions that the user has not already seen. If, however, the user has seen all the questions, then the algorithm should "reset" and only show questions t... | Let's define a "pivot" that separates a list into two sections. The pivot partitions the array such that all numbers before the pivot has been picked one more than the numbers after the pivot (or more generally, all numbers before pivot are ineligible for picking, while all numbers after the pivot are eligible for pick... | 0 | false | 2 | 3,197 |
2014-05-11 16:53:52.633 | Multiple Python versions in one computer (windows 7) | I have two versions of Python installed in my computer, Python 3.4 and Python 2.7, and I use both of these installations. When I run a script, how do I choose which versions I want to use? May I rename the names of the executables for that (Python.exe -> Python27.exe)?
Thanks. | Both python 2.7 and python 3 coexist on one machine happily.
If you name the scripts .py for those you would like to run with python 2.3 and .py3 for those that you would like to run with python3 then you can just invoke the scripts by typing their names or by double clicking. These associations are set up by default ... | 0.201295 | false | 1 | 3,198 |
2014-05-12 13:44:27.370 | GAE: how to quantify Frontend Instance Hours usage? | We are developing a Python server on Google App Engine that should be capable of handling incoming HTTP POST requests (around 1,000 to 3,000 per minute in total). Each of the requests will trigger some datastore writing operations. In addition we will write a web-client as a human-usable interface for displaying and an... | There's no 100% sure way to assess the number of frontend instance hours. An instance can serve more than one request at a time. In addition, the algorithm of the scheduler (the system that starts the instances) is not documented by Google.
Depending on how demanding your code is, I think you can expect a standard F1 i... | 1.2 | true | 1 | 3,199 |
2014-05-12 15:37:35.033 | How to check what is causing a web element to be invisible to Python Selenium? | I am trying to use Python Selenium to click a button on a webpage, but Selenium is giving exception "Element is not currently visible and so may not be interacted with".
The DOM structure is quite simple:
<body style="overflow: hidden;">
...
<div aria-hidden="false" style="display: block; ...">
...
... | Overflow takes only one of five values (overflow: auto | hidden | scroll | visible | inherit). Use visible | 1.2 | true | 1 | 3,200 |
2014-05-13 05:54:47.530 | Graphviz xdot utility fails to parse graphs | Lately I have observed that xdot utility which is implemented in python to view dot graphs is giving me following error when I am trying to open any dot file.
File "/usr/bin/xdot", line 4, in xdot.main()
File "/usr/lib/python2.7/dist-packages/xdot.py", line 1947, in main win.open_file(args[0])
File "/usr/lib/pytho... | This is a bug in latest ubuntu xdot package, please use xdot in pip repository:
sudo apt-get remove xdot
sudo pip install xdot | 0 | false | 1 | 3,201 |
2014-05-14 04:19:54.847 | App Engine: Difference between NDB and Datastore | I have been going through the Google App Engine documentation (Python) now and found two different types of storage.
NDB Datastore
DB Datastore
Both quota limits (free) seem to be same, and their database design too. However NDB automatically cache data in Memcache!
I am actually wondering when to use which storage?... | In simple words these are two versions of datastore . db being the older version and ndb the newer one. The difference is in the models, in the datastore these are the same thing. NDB provides advantages like handling caching (memcache) itself. and ndb is faster than db. so you should definitely go with ndb. to use ndb... | 1.2 | true | 1 | 3,202 |
2014-05-14 05:42:12.970 | Pyramid Mako pserver --reload not reloading in Mac | I've a strange issue. pserve --reload has stopped reloading the templates. It is reloading if some .py-file is changing, but won't notice .mak-file changes anymore.
I tried to fix it by:
Checking the filepermissions
Creating the new virtualenv, which didn't help.
Installing different version of mako without any effec... | Oh my,
I found the thing... I had <%block cached="True" cache_key="${self.filename}+body"> and the file inclusion was inside of that block.
Cheerious:) | 0.201295 | false | 1 | 3,203 |
2014-05-15 14:12:35.423 | Detach from IPython kernel without terminating it | Can someone please tell me how I can detach from an IPython kernel without terminating it?
I see in the documentation of quit() that there is a parameter keep_kernel, but unfortunately quit(keep_kernel=True) won't work. | If you are connected to the kernel via the IPython console client and are on a Unix-like OS, you can detach using Ctrl-\ | 0.673066 | false | 1 | 3,204 |
2014-05-16 02:43:45.883 | Get focus on tkinter program after pc is unlocked | I have a tkinter program written in python 3.3.3. I see myself in the need of making the the program get focus when the user unlocks the computer. I don't really know how to go ahead and start with this, users have a .exe version of the program that I created with cxfreeze. I f i need to modify the .py and create anoth... | I cannot answer this specifically for 'unlock' event (if there even is one in the GUI; I can't find one by cursory search.).
But I think the real answer is to change the question. Having a program simply take focus when user unlocks the display is very un-Windows-ish behavior. The Windows user expects to see the de... | 0 | false | 1 | 3,205 |
2014-05-16 12:45:53.747 | install scipy on openshift | I would like to install scipy on openshift but I don't know how to do it. I'm an absolute beginner with python and openshift. Therefore it would be great if somebody could provide a step by step explanation on how to proceed. | Either add scipy to your setup.py file or login to openshift rhc ssh yourapp and install manually: pip install scipy | 0 | false | 1 | 3,206 |
2014-05-17 22:58:17.270 | IFFT taking orders of magnitude more than FFT | I'm trying to resample a 1-D signal using an FFT method (basically, the one from scipy.signal). However, the code is taking forever to run, even though my input signal is a power of two in length. After looking at profiling, I found the root of the problem.
Basically, this method takes an FFT, then removes part of the ... | If your IFFT's length is different from that of the FFT, and the length of the IFFT isn't composed of only very small prime factors (2,3,etc.), then the efficiency can drop off significantly.
Thus, this method of resampling is only efficient if the two sample rates are different by ratios with small prime factors, such... | 1.2 | true | 1 | 3,207 |
2014-05-19 04:53:35.457 | Text summarization using deep learning techniques | I am trying to summarize text documents that belong to legal domain.
I am referring to the site deeplearning.net on how to implement the deep learning architectures. I have read quite a few research papers on document summarization (both single document and multidocument) but I am unable to figure to how exactly the s... | I think you need to be a little more specific. When you say "I am unable to figure to how exactly the summary is generated for each document", do you mean that you don't know how to interpret the learned features, or don't you understand the algorithm? Also, "deep learning techniques" covers a very broad range of model... | 0.386912 | false | 1 | 3,208 |
2014-05-19 17:52:33.183 | how to do database mocking or make sqlite run on localhost? | Hi I am trying to write python functional tests for our application. It involves several external components and we are mocking them all out.. We have got a better framework for mocking a service, but not for mocking a database yet.
sqlite is very lite and thought of using them but its a serverless, is there a way I c... | I don't understand your problem. Why do you care that it's serverless?
My standard technique for this is:
use SQLAlchemy
in tests, configure it with sqlite:/// or sqlite:///:memory: | -0.386912 | false | 1 | 3,209 |
2014-05-20 07:59:40.347 | Using Database with Pyside and Socket | I am working on my Python project using PySide as my Ui language. My projet is a game which require an internet connection to update the users'score and store in the database.
My problem is how can I store my database in the internet. I mean that all users can access this information when they are connected to an inter... | I'm not familiar with PySide .. but the idea is
you need to build a function that when internet connection is available it should synchronize your local database with online database and in the server-side you need to build a script that can handle requests ( POST / GET ) to receive the scores and send it to database ... | 0 | false | 1 | 3,210 |
2014-05-20 14:59:30.190 | How do I tell Python not to interpret backslashes in strings? | I'm using Python 2.7 and Django 1.4
If I have a string variable result = "fred\xbf", how do I tell the Django template to display "fred\xbf" rather than process the backslash and display some strange character?
I know I can escape the backslash: "fred\\xbf" , but can I get the Django template to understand I want the ... | This has nothing to do with the Django template, but how you define the variable in the first place.
Basckslashes are only "interpreted" when you specify them as literals in your Python code. So given your Python code above, you can either use the double backslash, or use a raw string.
If you were loading the string "f... | 0.386912 | false | 1 | 3,211 |
2014-05-20 15:56:30.370 | how to contribute on open source project featuring python | I know python and want to contribute on OpenSource projects that features python. Anyone can help me where to contribute and how.
I already googled it and find github and code.google as a good place to contribute but how to start it I don't know.
Suggest how to get started. | Not sure if this is an appropriate question for SO - you might get voted down. But ...
Whenever I have seen this question, the answer is almost always:
find a project you like / you're interested in
find something in that project that you feel you can fix / enhance (have a look through their bug tracker)
fork the proj... | 1.2 | true | 1 | 3,212 |
2014-05-21 11:24:55.837 | How to write binary and asci data into a file in python? | I have this wired protocol I am implementing and I have to write binary and ASCII data into the same file, how can I do this at the same time or at least the result in the end will be the file with mixed asci and binary data ?
I know that open("myfile", "rb") does open myfile in the binary mode, except that I can't fin... | Under Python 2, the only difference binary mode makes is how newlines are translated when writing; \n would be translated to the platform-dependant line separator.
In other words, just write your ASCII byte strings directly to your binary file, there is no difference between your ASCII data and the binary data as far a... | 1.2 | true | 1 | 3,213 |
2014-05-21 20:56:07.487 | How to extract meaning from sentences after running named entity recognition? | First: Any recs on how to modify the title?
I am using my own named entity recognition algorithm to parse data from plain text. Specifically, I am trying to extract lawyer practice areas. A common sentence structure that I see is:
1) Neil focuses his practice on employment, tax, and copyright litigation.
or
2) Neil f... | I do not think your "algo" is even doing entity recognition... however, stretching the problem you presented quite a bit, what you want to do looks like coreference resolution in coordinated structures containing ellipsis. Not easy at all: start by googling for some relevant literature in linguistics and computational ... | 0.135221 | false | 1 | 3,214 |
2014-05-22 08:49:32.923 | Two dimensional array in python | I need to read values from excel worksheet into 2d array.can anyone tell me how to do this using pythonwin32com. | You can have multi dimensional arrays or objects, your choice :)
arr = []; arr.append([1,2]); print arr;
would output
[[1,2]] | 0 | false | 1 | 3,215 |
2014-05-22 12:55:37.970 | Programmatically launch and interact with python virtual machine | Does anyone know how to launch a new python virtual machine from inside a python script, and then interact with it to execute code in a completely separate object space? In addition to code execution, I'd like to be able to access the objects and namespace on this virtual machine, look at exception information, etc.
I'... | It may depend on Python implementation such as Pypy, Jython. In CPython, you have to use a separate process if you want an independent interpreter otherwise at the very least GIL is shared.
multiprocessing, concurrent.futures modules allow you to run arbitrary Python code in separate processes and to communicate with ... | 0.201295 | false | 1 | 3,216 |
2014-05-23 07:35:15.547 | What should I install Distribute or Setuptools | I am following a python bbok which says to install Distribute. However I am confused should I install Distribute or Setuptools as both of them have merged now. Is there still a difference between the two? Since I have installed pip and that automaticallly installs setuptools I want to know how can I check if Distribute... | The situation is legitimately confusing as there are too many installers available for Python and the landscape has changed recently.
Distribute was a fork of setuptools which itself is an extension to distutils. They merged back with setuptools in 2013. Your book is most likely out of date. The documentation of setupt... | 1.2 | true | 1 | 3,217 |
2014-05-23 14:08:10.250 | What endianness does Python use to write into files? | When using file.write() with 'wb' flag does Python use big or litte endian, or sys.byteorder value ? how can i be sure that the endianness is not random, I am asking because I am mixing ASCII and binary data in the same file and for the binary data i use struct.pack() and force it to little endian, but I am not sure wh... | Note: I assume Python 3.
Endianness is not a concern when writing ASCII or byte strings. The order of the bytes is already set by the order in which those bytes occur in the ASCII/byte string. Endianness is a property of encodings that maps some value (e.g. a 16 bit integer or a Unicode code point) to several bytes. By... | 0.135221 | false | 1 | 3,218 |
2014-05-24 15:45:51.620 | Install Light Table editor on Windows 7 | I am trying to download/install Light Table. I want it to show up in the start menu.
When downloading light table, it shows up as a Zip folder in the TEMP file. I've extracted the files and am unable to get it to show up in the start menu.
Normally the programs I download have an installer that does this automatically.... | It's pretty easy to do.
Unzip to where ever
Move the LightTable directory (from inside LightTableWin) to your Program Files (x86) directory.
2.1 If you are using Windows Explorer, you'll need to start windows explorer as an administrator (found by right clicking the program icon)
open your Program Files (x86)\Ligh... | 0.995055 | false | 1 | 3,219 |
2014-05-25 20:22:02.227 | PyQt - How to open a directory folder? | I have searched a lot and I know how to open a directory dialog window.
But what I am looking for is the method to open a directory folder under windows OS, just like you right click one of your local folder and select open.
Any suggestions? | You may simply try this:
os.startfile(whatever_valid_filename)
This starts the default OS application for whatever_valid_filename, meaning Explorer for a folder name, default notepad for a .txt file, etc. | 0.265586 | false | 1 | 3,220 |
2014-05-26 11:31:55.927 | workbook calculation to automatic in both vba and python | how to make excel workbook calculation to automatic in both vba and python script?
I tried this Application.Calculation = xlCalculateAutomatic but it is not working.
It throws me below error.
global name 'xlCalculateAutomatic' is not defined. | It is xlCalculationAutomatic or you could use the number -4105 in Python. | 0.386912 | false | 1 | 3,221 |
2014-05-26 12:38:51.493 | How to set up a Django project in PyCharm | I'm new in this area so I have a question. Recently, I started working with Python and Django. I installed PyCharm Community edition as my IDE, but I'm unable to create a Django project.
I looked for some tutorials, and there is an option to select "project type", but in the latest version this option is missing. Can s... | I have met the problems today. At last, I finished it by:
Create project in command line
Create app in command line
Just open the existing files and code in pycharm
The way I use have the benefits:
don't need by professional pycharm
code django project in pycharm | 0.443188 | false | 1 | 3,222 |
2014-05-27 08:08:05.317 | how to make playbin of gstreamer1.0 playing multichannel-audio 5.0 playing without downmixing to stereo | I'm writing a mediaplayer-gui fitting some needs of a medialibrary containing classical music only.
Language is python3/tkinter.
One backend is gstreamer1.0, playbin (seems to be the only one, playing gapless).
When playbin gets the uri of a file with 5.0 channels
(FRONT_LEFT,FRONT_RIGHT,FRONT_CENTER,REAR_LEFT,REAR_RIG... | I'd suggest to file a bug and ideally make your test files available.
If you want to track this down yourself take a look at the GST_DEBUG="*:3" ./your-app output to see which element is emitting the warning. | 0.386912 | false | 1 | 3,223 |
2014-05-27 13:46:26.907 | Add path to python package to sys.path | I have a case for needing to add a path to a python package to sys.path (instead of its parent directory), but then refer to the package normally by name.
Maybe that's weird, but let me exemplify what I need and maybe you guys know how to achieve that.
I have all kind of experimental folders, modules, etc inside a pat... | I'll answer to my own question since I got an idea while writing the question, and maybe someone will need that.
I added a link from that folder to my site-packages folder like that:
ln -s /home/me/python/pyutils /path/to/site-packages/pyutils
Then, since the PYTHONPATH contains the /path/to/site-packages folder, and I... | 1.2 | true | 1 | 3,224 |
2014-05-27 19:16:39.787 | LSF: Submit one Python script that uses multiprocessor module *or* submit several scripts at once that are "pre-split"? | I have a single task to complete X number of times in Python and I will be using LSF to speed that up. Is it better to submit a job containing several Python scripts which can be run separately in parallel or one Python script that utilizes the multiprocessor module?
My issue is I don't trust LSF to know how to split u... | One (very simplified) way to think of LSF is as a system that launches a process and lets the process know how many cores (potentially on different hosts) have been allocated to it. LSF can't prevent your program from doing something stupid (like for example, if multiple instances of it run at the same time, and one i... | 1.2 | true | 1 | 3,225 |
2014-05-28 21:13:59.817 | Web scraping without knowledge of page structure | I'm trying to teach myself a concept by writing a script. Basically, I'm trying to write a Python script that, given a few keywords, will crawl web pages until it finds the data I need. For example, say I want to find a list of venemous snakes that live in the US. I might run my script with the keywords list,venemou... | You're basically asking "how do I write a search engine." This is... not trivial.
The right way to do this is to just use Google's (or Bing's, or Yahoo!'s, or...) search API and show the top n results. But if you're just working on a personal project to teach yourself some concepts (not sure which ones those would be... | 0.386912 | false | 1 | 3,226 |
2014-05-29 22:46:20.497 | How do numpy and GMPY2 compare with GMP in terms of speed? | I understand that GMPY2 supports the GMP library and numpy has fast numerical libraries. I want to know how the speed compares to actually writing C (or C++) code with GMP. Since Python is a scripting language, I don't think it will ever be as fast as a compiled language, however I have been wrong about these generaliz... | numpy and GMPY2 have different purposes.
numpy has fast numerical libraries but to achieve high performance, numpy is effectively restricted to working with vectors or arrays of low-level types - 16, 32, or 64 bit integers, or 32 or 64 bit floating point values. For example, numpy access highly optimized routines writt... | 1.2 | true | 1 | 3,227 |
2014-06-02 00:19:02.350 | Secure access of webassets with Flask and AWS S3 | I am trying to serve files securely (images in this case) to my users. I would like to do this using flask and preferably amazon s3 however I would be open to another cloud storage solution if required.
I have managed to get my flask static files like css and such on s3 however this is all non-secure. So everyone who ... | Make the request to your Flask application, which will authenticate the user and then issue a redirect to the S3 object. The trick is that the redirect should be to a signed temporary URL that expires in a minute or so, so it can't be saved and used later or by others.
You can use boto.s3.key.generate_url function in y... | 0.386912 | false | 1 | 3,228 |
2014-06-02 03:41:46.447 | How to access Django DB and ORM outside of Django | So in my spare time, I've been developing a piece of network monitoring software that essentially can be installed on a bunch of clients, and the clients report data back to the server(RAM/CPU/Storage/Network usage, and the like). For the administrative console as well as reporting, I've decided to use Django, which ha... | I chose option 1 when I set up my environment, which does much of the same stuff.
I have a JSON interface that's used to pass data back to the server. Since I'm on a well-protected VLAN, this works great. The biggest benefit, like you say, is the Django ORM. A simple address call with proper data is all that's neede... | 0.201295 | false | 1 | 3,229 |
2014-06-04 11:33:32.663 | How protobuf-net serialize DateTime? | I'm working on a project consisting on Client/Server. Client is written in Python (will run on linux) and server in C#. I'm communicating through standard sockets and I'm using protobuf-net for protocol definition. However, I'm wondering how would protobuf-net handle DateTime serialization. Unix datetime differs from .... | DateTime is spoofed via a multi-field message that is not trivial, but not impossible to understand. In hindsight, I wish I had done it a different way, but it is what it is. The definition is available in bcl.proto in the protobuf-net project.
However! If you are targering multiple platforms, I strongly recommend you ... | 1.2 | true | 1 | 3,230 |
2014-06-05 14:26:13.100 | Best way to package a Python library that includes a C shared library? | I have written a library whose main functionality is implemented in C (speed is critical), with a thin Python layer around it to deal with the ctypes nastiness.
I'm coming to package it and I'm wondering how I might best go about this. The code it must interface with is a shared library. I have a Makefile which builds ... | I'd consider building the python module as a subproject of a normal shared library build. So, use automake, autoconf or something like that to build the shared library, have a python_bindings directory with a setup.py and your python module. | 0.135221 | false | 1 | 3,231 |
2014-06-05 20:31:02.323 | How to search freebase data dump | I downloaded the freebase data dump and I want to use it to get information about a query just like how I do it using the web API. How exactly do I do it? I tried using a simple zgrep but the result was a mess and takes too much time. Any graceful way to do it (preferably something that plays nicely with python)? | The Freebase dump is in RDF format. The easiest way to query it is to dump it (or a subset of it) into an RDF store. It'll be quicker to query, but you'll need to pay the database load time up front first. | 0.386912 | false | 1 | 3,232 |
2014-06-06 08:05:41.110 | Google App Engine Check Success of backup programmatically | I am taking the backup of datastore , using Taskqueues. I want to check whether the backup has completed successfully or not. I can check the end of the backup job by checking the taskqueue, but how can i check whether the backup was successful or it failed due to some errors. | Unfortunately there is not currently a well-supported way to do this.
However, with the disclaimer that this is likely to break at some point in the future, as it depends on internal implementation details, You can fetch the relevant _AE_Backup_Information and _AE_DatastoreAdmin_Operation entities from your datastore a... | 1.2 | true | 1 | 3,233 |
2014-06-09 01:02:07.897 | Best way to access data from mysql db on other non-local machines | I have read a few posts on how to enable remote login to mysql. My question is: is this a safe way to access data remotely?
I have a my sql db located at home (on Ubuntu 14.04) that I use for research purposes. I would like to run python scripts from my Macbook at work. I was able to remote login from my old windows O... | Use ssh to login to your home computer, setup authorized keys for it and disable password login. setup iptables on your linux machine if you don't have a firewall on your router, and disable traffic on all ports except 80 and 22 (ssh and internet). That should get you started. | 1.2 | true | 1 | 3,234 |
2014-06-09 15:05:10.713 | Launch Python script in Git Bash | I'm writing git commands through a Python script (on Windows)
When I double click on myScript.py, commands are launched in the Windows Command Prompt.
I would like to execute them in Git Bash.
Any idea how to do that without opening Git Bash and write python myScript.py? | in the top of your python file add #!/usr/bin/python then you can rename mv myScript.py myScript and run chmod 755 myScript. This will make it so you can run the file with ./myScript look into adding the file directory to your path or linking it to the path if you want to be able to run it from anywhere. | 0 | false | 1 | 3,235 |
2014-06-09 20:26:58.563 | django-allauth: how to modify email confirmation url? | I'm running django on port 8001, while nginx is handling webserver duties on port 80. nginx proxies views and some REST api calls to Django. I'm using django-allauth for user registration/authentication.
When a new user registers, django-allauth sends the user an email with a link to click. Because django is running... | Django get hostname and port from HTTP headers.
Add proxy_set_header Host $http_host; into your nginx configuration before options proxy_pass. | 1.2 | true | 1 | 3,236 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.