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 |
|---|---|---|---|---|---|---|---|
2015-03-30 03:25:11.703 | How to remove anaconda from windows completely? | I installed Anaconda a while ago but recently decided to uninstall it and just install basic python 2.7.
I removed Anaconda and deleted all the directories and installed python 2.7.
But when I go to install PyGTK for Windows it says it will install it to the c:/users/.../Anaconda directory - this doesn't even exist. I ... | Uninstall Anaconda from control Panel
Delete related folders, cache data and configurations from Users/user
Delete from AppData folder from hidden list
To remove start menu entry -> Go to C:/ProgramsData/Microsoft/Windows/ and delete Anaconda folder or search for anaconda in start menu and right click on anaconda promp... | 0.029146 | false | 13 | 3,650 |
2015-03-30 08:38:26.157 | How to use external Auth system in Pyramid | Context
My app relies on external service for authentication, python API has function authentiate_request witch takes
request instance as a param, and returns result dict:
if auth was successful, dict contains 3 keys:
successful: true
username: alice
cookies: [list of set-cookie headers required to remember user]
if... | There are two broad ways to do integrate custom auth with Pyramid:
- write your own authentication policy for Pyramid (I haven't done this)
- write your own middleware to deal with your auth issues, and use the RemoteUserAuthenticationPolicy in Pyramid (I have done this)
For the second, you write some standard wsgi mid... | 1.2 | true | 1 | 3,651 |
2015-03-31 00:14:32.007 | Get the count of each key in each Mapper or globally in Spark MapReduce model | We need to get the count of each key (the keys are not known before executing), and do some computation dynamically in each Mapper. The key count could be global or only in each Mapper. What is the best way to implement that? In Hadoop this is similar to an aggregator function.
The accumulator in Spark needs to be defi... | You can use pairRDD.countByKey() function for counting the rows according their keys. | 0 | false | 1 | 3,652 |
2015-04-01 06:58:11.770 | how to find current day is weekday or weekends in Python? | Please suggest me on the following.
How to find whether a particular day is weekday or weekend in Python? | Use the date.weekday() method. Digits 0-6 represent the consecutive days of the week, starting from Monday. | 1 | false | 1 | 3,653 |
2015-04-01 16:23:01.873 | Connection with boto to AWS hangs when running with crond | I have a very basic python script which uses boto to query the state of my EC2 instances. When I run it from console, it works fine and I'm happy. The problem is when I want to add some automation and run the script via crond. I notices that the script hangs and waits indefinitely for the connection. I saw that boto ha... | The entire issue appeared to be HTTP_PROXY environment variable. The variable was set in /etc/bashrc and all users got it this way but when cron jobs ran (as root) /etc/bashrc wasn't read and the variable wasn't set. By adding the variable to the configuration file of crond (via crontab -e) the issue was solved | 0.201295 | false | 1 | 3,654 |
2015-04-01 18:11:45.407 | Using 3rd party packages on remote machine without download/install rights | I am SSHed into a remote machine and I do not have rights to download python packages but I want to use 3rd party applications for my project. I found cx_freeze but I'm not sure if that is what I need.
What I want to achieve is to be able to run different parts of my project (will mains everywhere) with command line ar... | It is basically useless if you don't have executable permission in the remote machine. You need to contact your administrator to obtain an executable permission.
In the case for the SCP files to the remote server, you may still be able to cp you files but you may not be able to execute it. | 0.201295 | false | 1 | 3,655 |
2015-04-04 05:46:32.837 | how to avoid memory error in generating and processing python permutations? | I got a problem in calculating permutations. The program needs to generate
permutations(xrange(num), num)) and for each permutation I have to count the number of consecutive primes. i.e sum of every adjacent two digits in the number should be a prime.
max value 'num' would be 18
primes = permutations(xrange(1,num+1), n... | There are 6402373705728000 permutations of 18 elements so it takes years to iterate over them. It should be better to think of an analytic solution for this problem. | 0.386912 | false | 1 | 3,656 |
2015-04-04 11:38:22.827 | graph of multiple y axes in plotly | I have 3 sets of comparison data(y axes) which needs to be plotted against a target source values. I'm comparing exports, gdp, standard of living values of different countries against a target countries values for different years. But values of each category are haphazard i.e exports in millions of dollars, gdp in perc... | Full disclosure, I work for Plotly.
Here's my shot at summarizing your problem in general, you've got 4 dimensions for each country (year, exports, gdp, standard of living).
You might be able to use either or both of these solutions:
visualize this in two dimensions using x-value, y-value, marker-size, and marker-line... | 1.2 | true | 1 | 3,657 |
2015-04-05 00:28:47.123 | Python delete lines of text line #1 till regex | I have an issue that I can't seem to find a solution within python.
From command line I can do this by:
sed '1,/COMMANDS/d' /var/tmp/newFile
This delete everything from line #1 till regex "COMMANDS". Simple
But I can't do the same with Python that I can find.
The re.sub and multiline doesn't seem to work.
So I have ... | Set a flag false.
Iterate over each line.
For each line,
1) When you match your pattern, set a flag.
2) If the flag is currently set set, print the line. | 0 | false | 1 | 3,658 |
2015-04-05 19:44:52.037 | Console output consuming much CPU? (about 140 lines per second) | I am doing my bachelor's thesis where I wrote a program that is distributed over many servers and exchaning messages via IPv6 multicast and unicast. The network usage is relatively high but I think it is not too high when I have 15 servers in my test where there are 2 requests every second that are going like that:
Ser... | I finally found the real problem. It was not because of the prints (removing them improved performance a bit, but not significantly) but because of a thread that was using a shared lock. This lock was shared over multiple CPU cores causing the whole thing being very slow.
It even got slower the more cores I added to th... | 0 | false | 1 | 3,659 |
2015-04-07 05:29:14.317 | Pygame, sub-pixel coordinates. | The question I have as the title says is on the idea of setting up a graph in pygame that graphs sub-pixel coordinates.
Something a friend and I spoke of was how I could try to make a function graphing program for fun in python, and I thought about how I could use it, but I found a few issues.
The first one was the u... | Instead of setting each individual pixel, use pygame's line drawing function to draw a line from the current coordinate to the next instead of using sub-pixel coordinates (pygame.draw.line or even pygame.draw.lines).
This way, the "gaps" between two points are filled; no need for sub-pixel coordinates.
You just have to... | 0 | false | 1 | 3,660 |
2015-04-08 07:53:55.563 | how to embed standalone bokeh graphs into django templates | I want to display graphs offered by the bokeh library in my web application via django framework but I don't want to use the bokeh-server executable because it's not the good way. so is that possible? if yes how to do that? | It must put {{the_script|safe}} inside the head tag | 0.16183 | false | 1 | 3,661 |
2015-04-08 13:06:23.073 | How to test uncaught/unhandled exceptions in behave? | When an exception is raised in the application that is not accounted for (an uncaught/unhandled exception), it should be logged. I would like to test this behaviour in behave.
The logging is there to detect unhandled exceptions so developers can implement handling for these exceptions or fix them if needed.
In order to... | Regadless to framework/programming language exception is a state when something went wrong. This issue has to be handled somehow by the application, that's why a good programmer will write exception handling code in places where it needed at most.
Exception handling can be everything. In your case you want to test that... | 0 | false | 1 | 3,662 |
2015-04-08 20:37:37.587 | Include mouse cursor in screenshot | I'm making a program that streams my screen to another computer(like TeamViewer), I'm using sockets, PIL ImageGrab, Tkinter.
Everything is fine but the screenshot I get from ImageGrab.grab() is without the mouse cursor, which is very important for my program purpose.
Do you know how can I take screenshot with the mouse... | The cursor isn't on the same layer as the desktop or game your playing, so a screenshot won't capture it (try printscreen and paste into mspaint). A workaround is to get the position of the cursor and draw it on the image. you could use win32gui.GetCursorPos(point) for windows. | 0.995055 | false | 1 | 3,663 |
2015-04-08 23:09:44.867 | How Do you make a delay in python without stoping the whole program | I am making a game for a presentation and I cannot seem to understand how to make a delay in Python.
For example, whenever I press the D key, my character not only moves but also changes pictures so it looks like it's running.
I have the movement part down, I just need to slow down the changing of the sprite so that it... | The command turtle.down() will work, I guess | 0 | false | 1 | 3,664 |
2015-04-09 14:40:38.793 | How to interact with social websites (auto youtube posting, finding titles of new videos etc.) from the command line | I would like to write a script to access data on a website, such as:
1) automatically searching a youtuber's profile for a new posting, and printing the title of it to stdout.
2) automatically posting a new video, question, or comment to a website at a specified time. For a lot of sites, there is a required login, so t... | Python or Node (JS) will probably be a lot easier for this task than Bash, primarily because you're going to have to do OAuth to get access to the social network.
Or, if you're willing to get a bit "hacky", you could issue scripts to PhantomJS, and automate the interaction with the sites in question... | 0.386912 | false | 1 | 3,665 |
2015-04-09 20:51:07.207 | Get IO Wait time as % in python | I am writing a python script to get some basic system stats. I am using psutil for most of it and it is working fine except for one thing that I need.
I'd like to log the average cpu wait time at the moment.
from top output it would be in CPU section under %wa.
I can't seem to find how to get that in psutil, does an... | %wa is giving your the iowait of the CPU, and if you are using times = psutil.cpu_times() or times = psutil.cpu_times_percent() then it is under the times.iowait variable of the returned value (Assuming you are on a Linux system) | 1.2 | true | 1 | 3,666 |
2015-04-09 23:49:48.743 | How can I combine PyQt4 and Tornado's event loops into one application? | I am trying to program an application that runs a HTTP server as well as a GUI using Tornado and PyQt4 respectively. I am confused about how to use these two event loops in parallel. Can this be done with the multiprocessing module? Should the HTTP server be run in a QtThread? Or is a bash script the best way to go to... | You won't need a bash script. Probably simplest to write a PyQt application and have the application launch the web server. The server may be in a separate thread or process depending on your requirements, but I'd start by having a single thread as a first draft and splitting it out later.
Having the PyQt app as your m... | 0 | false | 1 | 3,667 |
2015-04-10 11:28:54.167 | PyQT Qtabwidget add, remove, hide, show certain tab | I am trying to build a GUI which will:
Load a file with parameters which describe certain type of problem.
Based on the parameters of the file, show only certain tab in QTabwidget (of many predefined in Qt Designer .ui)
I plan to make a QTabwidget with, say 10 tabs, but only one should be visible based on the paramet... | I see that this thread is kinda old. But I hope this will still help.
You can use the remove() method to "hide" the tab. There's no way to really hide them in pyqt4. when you remove it, it's gone from the ui. But in the back end, the tab object with all your settings still exist. I'm sure you can find a way to improvis... | 0 | false | 1 | 3,668 |
2015-04-11 23:33:45.970 | How do you make a Python executable file on Mac? | My google searching has failed me. I'd like to know how to make an executable Python file on OS X, that is, how to go about making an .exe file that can launch a Python script with a double click (not from the shell). For that matter I'd assume the solution for this would be similar between different scripting language... | You can run python scripts through OS X Terminal. You just have to write a python script with an editor, open your Terminal and enter python path_to_my_script/my_script.py | 0.201295 | false | 1 | 3,669 |
2015-04-12 01:10:46.060 | I don't know how to update my Python version to 3.4? | I'm on OSX, and I installed IDLE for Python 3.4. However, in Terminal my python -V and pip --version are both Python 2.7.
How do I fix this? I really have no idea how any of this works, so please bear with my lack of knowledge. | I have found that making the 'python' alias replace the default version of python that the system comes with is a bad idea.
When you install a new version of python (3.4 for instance),
these two new commands are installed, specifically for the version you installed:
pip3.4
python3.4
If you're using an IDE that wants y... | 0 | false | 2 | 3,670 |
2015-04-12 01:10:46.060 | I don't know how to update my Python version to 3.4? | I'm on OSX, and I installed IDLE for Python 3.4. However, in Terminal my python -V and pip --version are both Python 2.7.
How do I fix this? I really have no idea how any of this works, so please bear with my lack of knowledge. | Try python3 or python3.4. It should print out the right version if correctly installed.
Python 3.4 already has pip with it. You can use python3 -m pip to access pip. Or python3 -m ensurepip to make sure that it's correctly installed. | 0 | false | 2 | 3,670 |
2015-04-12 22:27:33.050 | Custom user model in Django? | I know how to make custom user models, my question is about style and best practices.
What are the consequences of custom user model in Django? Is it really better to use auxiliary one-to-one model?
And for example if I have a UserProfile models which is one-to-one to User, should I create friends relationship (which ... | I would definitely recommend using a custom user model - even if you use a one-to-one with a profile. It is incredibly hard to migrate to a custom user model if you've committed to the default user model, and there's almost always a point where you want to add at least some custom logic to the user model.
Whether you u... | 0.201295 | false | 2 | 3,671 |
2015-04-12 22:27:33.050 | Custom user model in Django? | I know how to make custom user models, my question is about style and best practices.
What are the consequences of custom user model in Django? Is it really better to use auxiliary one-to-one model?
And for example if I have a UserProfile models which is one-to-one to User, should I create friends relationship (which ... | Also all 3rd-party packages rely on get_user_model(), so looks like if I don't use custom user model, all your relations should go to User, right? But I still can't add methods to User, so if User has friends relation, and I want to add recent_friends method, I should add this method to UserProfile.
I have gone down t... | 1.2 | true | 2 | 3,671 |
2015-04-13 00:21:06.060 | how to make time.mktime work consistently with datetime.fromtimestamp? | I am expecting the following code will return 0 but I get -3600, could someone explains why? and how to fix it? thanks
import datetime
import time
ts = time.mktime(time.gmtime(0))
print time.mktime(datetime.datetime.fromtimestamp(ts).timetuple()) | time.mktime converts a time tuple in local time to seconds since the Epoch. Since time.gmtime(0) returns GMT time tuple, and the conversion assumes it was in your local time, you see this discrepancy. | 1.2 | true | 1 | 3,672 |
2015-04-13 14:01:01.780 | Update existing row in database from pandas df | I have a PostgreSQL db. Pandas has a 'to_sql' function to write the records of a dataframe into a database. But I haven't found any documentation on how to update an existing database row using pandas when im finished with the dataframe.
Currently I am able to read a database table into a dataframe using pandas read_sq... | For sql alchemy case of read table as df, change df, then update table values based on df, I found the df.to_sql to work with name=<table_name> index=False if_exists='replace'
This should replace the old values in the table with the ones you changed in the df | 0 | false | 1 | 3,673 |
2015-04-13 22:11:52.840 | can't find substring in regex | I can't figure out how to get "any text" from the string any text [monkey bars][fancy swing][1002](special)
after a lot of trying I've made (.*)[\(*]|[\[*] but it doesn't seem to work very well
I'm using the python regex engine | Use the regexp ^[^[]* to match everything up to the first [. | 1.2 | true | 1 | 3,674 |
2015-04-14 07:08:10.117 | how to execute shell script in the same process in python | I need to execute several shell scripts with python, some scripts would export environment parameters, so I need to execute them in the same process, otherwise, other scripts can't see the new environment parameters
in one word, I want to let the shell script change the environment of the python process
so I should not... | What if you make a 'master' shell script that would execute all the others in sequence? This way you'll only have to create a single sub-process yourself, and the individual scripts will share the same environment.
If, however, you would like to interleave script executions with Python code, then you would probably ha... | 1.2 | true | 2 | 3,675 |
2015-04-14 07:08:10.117 | how to execute shell script in the same process in python | I need to execute several shell scripts with python, some scripts would export environment parameters, so I need to execute them in the same process, otherwise, other scripts can't see the new environment parameters
in one word, I want to let the shell script change the environment of the python process
so I should not... | No, you cannot run more than one program (bash, python) in the same process at the same time.
But you can run them in sequence using exec in bash or one of the exec commands in python, like os.execve. Several things survive the "exec boundary", one of which is the environment block. So in each bash script you exec... | 0.201295 | false | 2 | 3,675 |
2015-04-15 10:21:55.367 | Defining inputs and fitness in ANN with GA Python | I am attempting to create a program that can find the best solution for winning a game using NN and I was hoping to get some help from the wonderful community here.
The game is a strategy war game, you have your soldiers and a land you need to conquer. There is also the opponent's soldiers you need to be aware from the... | Since I can't comment yet I will just answer taking some assumptions.
(I'm also starting to experiment with NN and GA in Python too (MultiNEAT), so not an expert either ;) )
The problem could be poor feedback to the genetic algorithm, so it can't select the best individuals. Try making your fitness score more fine gra... | 0 | false | 1 | 3,676 |
2015-04-15 22:49:23.023 | How to install pylint for python2 and python3 side by side | I have a codebase that includes both python2 and python3 code. I want to make one script that will run pylint on all python2 and all python3 files, ideally from within a single virtualenv.
I can figure out which version of pylint to run by annotating the directories (eg, adding a .pylint3 file to directories that need... | Usually python modules for different major versions don't interfer with each other. The only problem is utilities. So the recipe is as follows:
Create a virtual environment for a python2, then go to the bin/ folder of the created environment and rename all created scripts/wrappers/binaries so that all of them would ha... | 0.201295 | false | 1 | 3,677 |
2015-04-17 16:30:39.687 | python copying directory and reading text files Remotely | I'm about to start working on a project where a Python script is able to remote into a Windows Server and read a bunch of text files in a certain directory. I was planning on using a module called WMI as that is the only way I have been able to successfully remotely access a windows server using Python, But upon furthe... | I've done some work with WMI before (though not from Python) and I would not try to use it for a project like this. As you said WMI tends to be obscure and my experience says such things are hard to support long-term.
I would either work at the Windows API level, or possibly design a service that performs the desired a... | 0 | false | 1 | 3,678 |
2015-04-18 03:10:26.357 | My Python program generates an HTML page; how do I display a .jpg that's in the same directory? | The generated HTML page works fine for text. But
does not find the file and displays the alt text instead. I know the HTML works because "view source" in the browser can be copied into a file, which then works locally when the .jpg is in the same directory.
On the remote site, the .jpg file is in the same directory as... | No, your python process does not care about the JPG at all. It just generates html asking the browser to fetch the JPG. Then it's the browser, fetching the JPG by making another request to the webserver.
Therefore it is very likely that your python script needs to live in a different directory than the JPG. Have a look... | 0 | false | 1 | 3,679 |
2015-04-18 11:54:26.107 | using materialized views or alternatives in django | I need to use some aggregate data in my django application that changes frequently and if I do the calculations on the fly some performance issues may happen. Because of that I need to save the aggregate results in a table and, when data changes, update them. Because I use django some options may be exist and some mayb... | You can use Materialized view with postgres. It's very simple.
You have to create a view with query like CREATE MATERIALIZED VIEW
my_view as select * from my_table;
Create a model with two
option managed=false and db_name=my_view in the model Meta like
this
MyModel(models.Model):
class Meta:
managed ... | 0.999998 | false | 1 | 3,680 |
2015-04-18 19:35:36.223 | Django/Python - Updating the database every second | I'm working on creating a browser-based game in Django and Python, and I'm trying to come up with a solution to one of the problems I'm having.
Essentially, every second, multiple user variables need to be updated. For example, there's a currency variable that should increase by some amount every second, progressively ... | One of the possible solutions would be to use separate daemonized lightweight python script to perform all the in-game business logic and left django be just the frontend to your game. To bind them together you might pick any of high-performance asynchronous messaging library like ZeroMQ (for instance to pass player's ... | 0.386912 | false | 1 | 3,681 |
2015-04-18 22:37:38.243 | RethinkDB: how many connections? | I'm starting out with rethinkdb in python, and taking a look at the different approaches:
Blocking approach with threads
Non-blocking, callback-based approach with Tornado
Greenlet-based approach with gevent
In the first case, the natural thing to do is to give each thread a connection object. In the second and third... | If you're using a non-blocking library, one connection should be sufficient in RethinkDB 2.0 (prior to 2.0 there was less per-connection parallelism). Per-connection overhead is pretty low, though. Some people open a connection per query and even that isn't too slow, so you should just do whatever's easiest.
EDIT: Th... | 0.999909 | false | 1 | 3,682 |
2015-04-19 07:02:04.450 | Magento 1.9 Custom Menu Extension Use in django | I am trying to use the Magento Custom Menu extension in a django project.
I have modified the menucontent.phtml, but yet my menu items are not reflecting the appropriate captions.
Does anyone know how does the extension work to generate the menu? | Ok. Great. I found the issue. I had not noticed another javascript line at the end of my html file's tag. so I am home and dry. Cheers. | 0 | false | 1 | 3,683 |
2015-04-20 17:08:54.103 | How to Set Scrapy Auto_Throttle Settings | My use case is this: I have 10 spiders and the AUTO_THROTTLE_ENABLED setting is set to True, globally. The problem is that for one of the spiders the runtime WITHOUT auto-throttling is 4 days, but the runtime WITH auto-throttling is 40 days...
I would like to find a balance and make the spider run in 15 days (3x the o... | set DOWNLOAD_DELAY = some_number where some_number is the delay (in seconds) you want for every request and RANDOMIZE_DOWNLOAD_DELAY = False so it can be static. | 0.101688 | false | 2 | 3,684 |
2015-04-20 17:08:54.103 | How to Set Scrapy Auto_Throttle Settings | My use case is this: I have 10 spiders and the AUTO_THROTTLE_ENABLED setting is set to True, globally. The problem is that for one of the spiders the runtime WITHOUT auto-throttling is 4 days, but the runtime WITH auto-throttling is 40 days...
I would like to find a balance and make the spider run in 15 days (3x the o... | Auto_throttle is specifically designed so that you don't manually adjust DOWNLOAD_DELAY. Setting the DOWNLOAD_DELAY to some number will set an lower bound, meaning your AUTO_THROTTLE will not go faster than the number set in DOWNLOAD_DELAY. Since this is not what you want, your best bet would be to set AUTO_THROTTLE to... | 0.101688 | false | 2 | 3,684 |
2015-04-20 21:15:35.967 | Scrapy crawl blocked with 403/503 | I'm running Scrapy 0.24.4, and have encountered quite a few sites that shut down the crawl very quickly, typically within 5 requests. The sites return 403 or 503 for every request, and Scrapy gives up. I'm running through a pool of 100 proxies, with the RotateUserAgentMiddleware enabled.
Does anybody know how a site co... | It appears that the primary problem was not having cookies enabled. Having enabled cookies, I'm having more success now. Thanks. | 1.2 | true | 2 | 3,685 |
2015-04-20 21:15:35.967 | Scrapy crawl blocked with 403/503 | I'm running Scrapy 0.24.4, and have encountered quite a few sites that shut down the crawl very quickly, typically within 5 requests. The sites return 403 or 503 for every request, and Scrapy gives up. I'm running through a pool of 100 proxies, with the RotateUserAgentMiddleware enabled.
Does anybody know how a site co... | I simply set AutoThrottle_ENABLED to True and my script was able to run. | 0 | false | 2 | 3,685 |
2015-04-21 02:17:24.163 | How to uninstall and/or manage multiple versions of python in OS X 10.10.3 | I have installed the Python IDE Spyder. For me it's a great development environment.
Some how in this process I have managed to install three versions of Python on my system.These can be located as following:
Version 2.7.6 from the OS X Terminal;
Version 2.7.8 from the Spyder Console; and
Version 2.7.9rc1 from an IDL ... | (Spyder dev here) There is no simple way to do what you ask for, at least for the Python version that comes with Spyder.
I imagine you downloaded and installed our DMG package. That package comes with its own Python version as part of the application (along with several important scientific packages), so it can't be re... | 0.995055 | false | 1 | 3,686 |
2015-04-21 07:08:26.130 | Install Numpy in pydev(eclipse) | I am trying to install a package called 'numpy'.
i have python setup in eclipse luna with the help of pydev.
how do i install numpy in pydev.
tried putting numpy in site-packages folder. doesnt seem to work | Pandas can be installed after install python in to your pc.
to install pandas go to command prompt and type "pip install pandas" this command collecting packages related to pandas. After if it asking to upgrade pip or if pip is not recognized by the command prompt use this command:
python -m pip install --upgrade pip. | 0 | false | 1 | 3,687 |
2015-04-21 16:46:04.380 | File permission gets changed after file gets downloaded on client machine | How to execute a file after it gets downloaded on client side,File is a python script, User dont know how to change permission of a file, How to solve this issue?? | Maybe you can try teaching them how to use chmod +x command? Or actualy even more simple it would be to change it using GUI: right click -> properties -> permissions-> pick what is needed | 0 | false | 2 | 3,688 |
2015-04-21 16:46:04.380 | File permission gets changed after file gets downloaded on client machine | How to execute a file after it gets downloaded on client side,File is a python script, User dont know how to change permission of a file, How to solve this issue?? | Change file permissions to make it executable: sudo chmod +x file.py | 0.201295 | false | 2 | 3,688 |
2015-04-22 00:24:01.460 | How to attach to PyCharm debugger when executing python script from bash? | I know how to set-up run configurations to pass parameters to a specific python script. There are several entry points, I don't want a run configuration for each one do I? What I want to do instead is launch a python script from a command line shell script and be able to attach the PyCharm debugger to the python scri... | You can attach the debugger to a python process launched from terminal:
Use Menu Tools --> Attach to process then select python process to debug.
If you want to debug a file installed in site-packages you may need to open the file from its original location.
You can to pause the program manually from debugger and insp... | 0.386912 | false | 1 | 3,689 |
2015-04-22 06:23:12.987 | How to add a gallery in photologue? | I installed photologue correctly in my project (blog) and I can add images in admin panel, but how to display them on my main page? | In the admin panel, you also need to:
Create a gallery.
Choose which photos are a part of which galleries. | 0 | false | 1 | 3,690 |
2015-04-22 12:40:03.030 | Cannot import cv2 in PyCharm | I am working on a project that requires OpenCV and I am doing it in PyCharm on a Mac. I have managed to successfully install OpenCV using Homebrew, and I am able to import cv2 when I run Python (version 2.7.6) in Terminal and I get no errors. The issue arises when I try importing it in PyCharm. I get a red underline wi... | Do the following steps:
Download and install the OpenCV executable.
Add OpenCV in the system path(%OPENCV_DIR% = /path/of/opencv/directory)
Go to C:\opencv\build\python\2.7\x86 folder and copy cv2.pyd file.
Go to C:\Python27\DLLs directory and paste the cv2.pyd file.
Go to C:\Python27\Lib\site-packages directory and p... | 0 | false | 3 | 3,691 |
2015-04-22 12:40:03.030 | Cannot import cv2 in PyCharm | I am working on a project that requires OpenCV and I am doing it in PyCharm on a Mac. I have managed to successfully install OpenCV using Homebrew, and I am able to import cv2 when I run Python (version 2.7.6) in Terminal and I get no errors. The issue arises when I try importing it in PyCharm. I get a red underline wi... | Have you selected the right version of python ?
or rather, when you have installed opencv with brew, this last probably has installed a new version of python that you can find in Cellar's Directory. You can see this immediately; from the main window of PyCharm select:
Configure -> Preferences -> Project Interpreter
... | 0 | false | 3 | 3,691 |
2015-04-22 12:40:03.030 | Cannot import cv2 in PyCharm | I am working on a project that requires OpenCV and I am doing it in PyCharm on a Mac. I have managed to successfully install OpenCV using Homebrew, and I am able to import cv2 when I run Python (version 2.7.6) in Terminal and I get no errors. The issue arises when I try importing it in PyCharm. I get a red underline wi... | I got the same situation under win7x64 with pycharm version 2016.1.1, after a quick glimpse into the stack frame, I think it is a bug!
Pycharm ipython patches import action for loading QT, matplotlib, ..., and finally sys.path lost its way!
anyway, there is a workaround, copy Lib/site-packages/cv2.pyd or cv2.so to $PYT... | 0 | false | 3 | 3,691 |
2015-04-23 14:19:53.433 | I can't install eyeD3 0.7.5 into Python in windows | could you help me with that. I can't manage to install this plugin. I tried:
1) install it through pip
2) through setup.py in win console
3) through anaconda3 but still no.
4) I searched about it in web and here, but insructions are made to older versions.
5) and also through the installation page of eyeD3.
Could you ... | The problem is that this file is only written for Python 2 but you are using Python 3. You should use Anaconda (vs. Anaconda3), or create a Python 2 environment with conda with conda create -n py2 anaconda python=2 and activate it with activate py2. | 0 | false | 1 | 3,692 |
2015-04-23 14:30:23.333 | Python float precision float | I need to implement a Dynamic Programming algorithm to solve the Traveling Salesman problem in time that beats Brute Force Search for computing distances between points. For this I need to index subproblems by size and the value of each subproblem will be a float (the length of the tour). However holding the array in m... | You could try the c_float type from the ctypes standard library. Alternatively, if you are capable of installing additional packages you might try the numpy package. It includes the float32 type. | 0.386912 | false | 1 | 3,693 |
2015-04-24 05:56:00.197 | how to change the subject for Django error reporting emails? | i noticed about to change the subject for django error reporting emails,
is it possible to change subject?
can we modify the subject for Django error reporting emails ? | If you need it only for reporting errors the best choice would be to inherit from the django.utils.log.AdminEmailHandler and override the def format_subject(self, subject): method.
Note that changing EMAIL_SUBJECT_PREFIX will affect not only error emails but all emails send to admins including system information email... | 0.545705 | false | 1 | 3,694 |
2015-04-24 11:08:39.137 | GAE: how to get current server IP? | I'm hosting my app on Google App Engine. Is there any posibility to get server IP of my app for current request?
More info:
GAE has a specific IP addressing. All http requests go to my 3-level domain, and IP of this domain isn't fixed, it changes rather frequently and can be different on different computers at the same... | I'm not entirely clear on what you're looking for, but you can retrieve that type of information from the WSGI environmental variables. The method of retrieving them varies with WSGI servers, and the number of variables made available to your application depends on the web server configuration.
That being said, gettin... | 0 | false | 1 | 3,695 |
2015-04-24 11:41:28.240 | Django way for multiple translations for one language or parametrize translations | I have django app which is backend for javascript application intended for multiple TV devices. Each device has different frontend but I don't think that creating multiple .po files is good idea for this goal, because most of translations are repetitive for these devices.
Is this possible to add additional parameters f... | I assume that you are using Django to create an API, and you consume the API with javascript. You can check the user-agent string from the header and make the appropriate redirect according to the request. | -0.135221 | false | 1 | 3,696 |
2015-04-24 16:14:39.523 | Crafting a DNS Query Message in Python | I've been using Scapy to craft packets and test my network, but the programmer inside me is itching to know how to do this without Scapy.
For example, how do I craft a DNS Query using sockets (I assume it's sockets that would be used).
Thanks | To open a UDP socket you'd use:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_UDP
To send use:
query = craft_dns_query() # you do this part
s.sendto(query,(socket.inet_aton("8.8.8.8",53))
To receive the response use:
response = s.recv(1024)
You'll have to refer to documentation on DNS for actuall... | 0.386912 | false | 1 | 3,697 |
2015-04-27 03:03:57.107 | How to remove hours, minutes, and seconds from a Unix timestamp? | Without having to convert it to datetime, how can I get the date from a Unix timestamps? In other words, I would like to remove hours, minutes and seconds from the time stamp and get the numbers that represent the date only. | If running the script in a UNIX like OS, you can use the date command -
>>>import subprocess
>>>process=subprocess.Popen(['date','-d','@1430106933', '+%Y%m%d'], stdout=subprocess.PIPE)
>>>out,err = process.communicate()
>>>print out
20150426 | 0.201295 | false | 1 | 3,698 |
2015-04-27 05:58:47.753 | How to visualize a neural network | I want to draw a dynamic picture for a neural network to watch the weights changed and the activation of neurons during learning. How could I simulate the process in Python?
More precisely, if the network shape is: [1000, 300, 50],
then I wish to draw a three layer NN which contains 1000, 300 and 50 neurons respectiv... | Draw the network with nodes as circles connected with lines. The line widths must be proportional to the weights. Very small weights can be displayed even without a line. | 0.04532 | false | 1 | 3,699 |
2015-04-27 10:42:37.700 | Does redeclaring a cursor create new connection while using psycopg2? | I am using the psycopg2 library with Python3 on a linux server to create some temporary tables on Redshift and querying these tables to get results and write to files on the server.
Since my queries are long and takes about 15 minutes to create all these temp tables that I ultimate pull data from, how do I ensure that... | Re-declaring a cursor doesn't create new connection while using psycopg2. | 1.2 | true | 1 | 3,700 |
2015-04-27 12:50:23.680 | how to create a .condarc file for Anaconda? | I am trying to set up a proxy server in Anaconda because my firewall does not allow me to run online commands such as
conda update
I see online that I should create a .condarc file that contains the proxy address. Unfortunately,
I dont know how to create that file (is it a text file?)
and where to put it?! (in whic... | to create the .condarc file open Anaconda Prompt and type:
conda config
it will appear in your user's home directory | 0 | false | 2 | 3,701 |
2015-04-27 12:50:23.680 | how to create a .condarc file for Anaconda? | I am trying to set up a proxy server in Anaconda because my firewall does not allow me to run online commands such as
conda update
I see online that I should create a .condarc file that contains the proxy address. Unfortunately,
I dont know how to create that file (is it a text file?)
and where to put it?! (in whic... | There are chances that the .condarc file is hidden as was in my case. I was using Linux Mint (Sarah) and couldn't find the file though later on I found that it was hidden in the home directory and hence when I opted to show hidden files I could find it. | 0.135221 | false | 2 | 3,701 |
2015-04-27 18:31:33.507 | Webapp architecture: Putting python in a MEAN stack app | I currently have a small webapp on AWS based on the MEAN (Mongo, Express, Angular, Node) but have a python script I would like to execute on the front end. Is there a way to incorporate this? Basically, I have some data objects on my AngularJS frontend from a mongoDB that I would like to manipulate with python and do... | To answer my own question about a year later, what I would do now is just run my python script in tiny web server that lived on the same server as my MEAN app. It wouldn't have any external ports exposed and the MEAN app would just ping it for information and get JSON back. Just in case anyone is looking at this questi... | 0.386912 | false | 1 | 3,702 |
2015-04-28 19:42:56.140 | GAE module: "Request attempted to contact a stopped backend." | I am currently experiencing an issue in my GAE app with sending requests to non-default modules. Every request throws an error in the logs saying:
Request attempted to contact a stopped backend.
When I try to access the module directly through the browser, I get:
The requested URL / was not found on this server.
I... | Fixed by shutting down all instances (on all modules/versions just to be safe). | 1.2 | true | 1 | 3,703 |
2015-04-28 19:43:33.607 | Displaying pyqtgraph and pyqt widgets on web | Is there a way to take existing python pyqtgraph and pyqt application and have it display on a web page to implement software as a service? I suspect that there has to be a supporting web framework like Django in between, but I am not sure how this is done.
Any hints links examples welcome. | If all you need are static plots, then it should be straightforward to draw and export to an SVG file, then display the SVG in a webpage (or export to image, as svg rendering is not reliable in all browsers). If you need interactivity, then you're going to need a different solution and probably pyqtgraph is not the too... | 0 | false | 2 | 3,704 |
2015-04-28 19:43:33.607 | Displaying pyqtgraph and pyqt widgets on web | Is there a way to take existing python pyqtgraph and pyqt application and have it display on a web page to implement software as a service? I suspect that there has to be a supporting web framework like Django in between, but I am not sure how this is done.
Any hints links examples welcome. | Here is what I have sort of put together by pulling several threads online:
Ruby On Rails seems to be more popular than python at this moment.
If you go python, Flask and Django are good templates.
bokeh seems to be a good way of plotting to a browser.
AFAIK, there is no way to take an existing PyQt or pyqtgraph appl... | 1.2 | true | 2 | 3,704 |
2015-04-29 05:38:50.567 | Django rest framework: correctly handle incoming array of model ids | I have a question about REST design in general and specifically what the best way to implement a solution is in Django Rest Framework. Here it the situation:
Say I have an app for keeping track of albums that the user likes. In the browser, the user sees a list of albums and each one has a check box next to it. Chec... | Consider the upvote button to the left. When you click it, a request may be sent to stackoverflow.com/question/12345/upvote. It creates an "action resource" on the db, so later you can go to your user profile and check out the list of actions you took.
You can consider doing the same thing for your application. It may ... | 0.673066 | false | 1 | 3,705 |
2015-04-29 09:08:25.977 | Remove # from the URL in Python Simple HTTP Server | I have an angularjs app that uses Angular UI Router and the URL that are created have a # in them.. Eg. http://localhost:8081/#/login. I am using Python Simple HTTP server to run the app while developing. I need to remove the # from the URL. I know how to remove it by enabling HTML5 mode in angular. But that method has... | Well i had a similar problem but the difference is that i had Spring on the Server Side.
You can capture page not found exception at your server side implementation, and redirect to the default page [route] in your app. In Spring, we do have handlers for page not found exceptions, i guess they are available in python t... | 0 | false | 1 | 3,706 |
2015-04-29 17:13:23.360 | What is the relationship between virtualenv and pyenv? | I recently learned how to use virtualenv and virtualenvwrapper in my workflow but I've seen pyenv mentioned in a few guides but I can't seem to get an understanding of what pyenv is and how it is different/similar to virtualenv. Is pyenv a better/newer replacement for virtualenv or a complimentary tool? If the latter w... | Short version:
virtualenv allows you to create local (per-directory), independent python installations by cloning from existing ones
pyenv allows you to install (build from source) different versions of Python alongside each other; you can then clone them with virtualenv or use pyenv to select which one to run at any ... | 1 | false | 1 | 3,707 |
2015-04-30 07:44:15.333 | How to track anonymous users with Flask | My app implements a shopping cart in which anonymous users can fill their cart with products. User Login is required only before payment. How can this be implemented?
The main challenge is that flask must keep track of the user (even if anonymous) and their orders. My current approach is to leverage the AnonymousUserMi... | You can use a AnonymousUserMixin subclass if you like, but you need to add some logic to it so that you can associate each anonymous user with a cart stored in your database.
This is what you can do:
When a new user connects to your application you assign a randomly generated unique id. You can write this random id to... | 0.673066 | false | 2 | 3,708 |
2015-04-30 07:44:15.333 | How to track anonymous users with Flask | My app implements a shopping cart in which anonymous users can fill their cart with products. User Login is required only before payment. How can this be implemented?
The main challenge is that flask must keep track of the user (even if anonymous) and their orders. My current approach is to leverage the AnonymousUserMi... | There is no need for a custom AnonymousUserMixin, you can keep the shopping cart data in session:
anonymous user adds something to hist cart -> update his session with the cart data
the user wants to check out -> redirect him to login page
logged in user is back at the check out -> take his cart data out of the sessio... | 0.999753 | false | 2 | 3,708 |
2015-04-30 12:19:33.867 | WebSockets best practice for connecting an external application to push data | I am trying to understand how to use websockets correctly and seem to be missing some fundamental part of the puzzle.
Say I have a website with 3 different pages:
newsfeed1.html
newsfeed2.html
newsfeed3.html
When a user goes to one of those pages they get a feed specific to the page, ie newsfeed1.html = sport, news... | It depends on your software design, if you decide the logic from WebSocketServer.px and CoreApplication.py belongs together, merge it.
If not, you need some kind of inter process communication (ipc).
You can use websockets for this ipc, but i would suggest, you use something simpler. For example, you can you json-rpc... | 0 | false | 1 | 3,709 |
2015-04-30 13:18:18.817 | Load local data into IPython notebook server | I did setup an ipython server for other people (in my company department) to have a chance to learn and work with python.
Now I wonder how people can load their own local data into the ipython notebook session on the remote server. Is there any way to do this? | If it is a text file, create a empty file, edit it and then copy/paste the content..
You can do this to bypass the 25mb constraint | 0 | false | 1 | 3,710 |
2015-04-30 15:01:43.100 | Python XLRD Error : formula/tFunc unknown FuncID:186 | I'm stumped on this one, please help me oh wise stack exchangers...
I have a function that uses xlrd to read in an .xls file which is a file that my company puts out every few months. The file is always in the same format, just with updated data. I haven't had issues reading in the .xls files in the past but the newe... | I had the same problem and I think we have to look at the cells excel that these are not picking up empty, that's how I solved it. | 0 | false | 1 | 3,711 |
2015-04-30 16:01:24.727 | How do I change the serializer that my multiprocessing.mangers.BaseManager subclass uses to cPickle? | Using Python 2.7,
I am passing many large objects across processes using a manager derived from multiprocessing.managers. BaseManager and I would like to use cPickle as the serializer to save time; how can this be done? I see that the BaseManager initializer takes a serializer argument, but the only options appear to ... | I'm the author of dill and pathos. Multiprocessing should use cPickle by default, so you should't have to do anything.
If your object doesn't searliize, you have two options: go to a fork of multiprocessing or some other parallel backend, or add methods to your class (i.e. reduce methods) that register how to serialize... | 0.201295 | false | 1 | 3,712 |
2015-04-30 20:00:19.387 | how to omit imports using .coveragerc in coverage.py? | I am using nosetests --with-coverage to test and see code coverage of my unit tests. The class that I test has many external dependencies and I mock all of them in my unit test.
When I run nosetests --with-coverage, it shows a really long list of all the imports (including something I don't even know where it is being ... | The simplest way to direct coverage.py's focus is to use the source option, usually source=. to indicate that you only want to measure code in the current working tree. | 1.2 | true | 1 | 3,713 |
2015-05-01 15:46:37.773 | ObjectListView wxPython: how to show a wx.Color | I am using wxPython ObjectListView and it is very easy to use. Now I need to render a wx.Color as a column but I haven't found a way in the documentation. Basically I have list of items each of them have the following attributes: name, surname and hair color. Hair color is a RGB color and I would like to show it as a c... | For the future: what I did was to show the color as a background of the row of the list. | 0 | false | 1 | 3,714 |
2015-05-02 13:29:37.350 | 3rd party Tkinter themes and modifying outside window buttons | My question is simple, apart from the three themes pre-installed in Tkinter are there any other themes I can get ? Something like 3rd party themes ? If not, how can I change the button or other widgets looks (manually changing the form,etc..)?
Also I would like to know if it is possible to change the outside window loo... | You cannot change the window border, but you can remove it entirely and draw your own border. You'll also be responsible for adding the ability to move and resize the window. Search this site for "overrideredirect" for lots of questions and answers related to this feature.
As for third party themes: no, there aren't an... | 1.2 | true | 1 | 3,715 |
2015-05-04 16:31:29.273 | Plot 2d line diagram in mayavi | I have a dataset of a tennis game. This dataset contains the ball positions in each rally and the current score. I already 3d-visualized the game and ball positions in mayavi.
Now I want to plot 2d line diagrams in mayavi that visualizes the score developement after specific events (such as after: a break, a set-win, s... | Mayavi is not really good at plotting 2d-diagramms, you can cheat a little by setting your camera position parallel to an 2d image. If you want to plot 2d-diagramms try using matplotlib. | 0 | false | 1 | 3,716 |
2015-05-04 17:26:40.517 | Scapy packet time interpretation | I was wondering what is the difference between using pkt.time and pkt[IP].time since they both give different times for the same packet.
I was also wondering how to interpret packet time such as 1430123453.564733
If anyone has an idea or knows where I can find such information it would be very helpful.
Thanks. | pkt.time gives you the epoch time that is included in the FRAME layer of the packet in wireshark.
Just after the notation pkt[IP].time gives you the time that is included in the IP layer of the packet in wireshark. But the IP layer has no time, so I don't think this command will work. | 0 | false | 1 | 3,717 |
2015-05-05 06:26:47.973 | How to disable GPIO pins on the RaspberryPi? | Basically, I need to disable or turn off a GPIO pin whenever I execute a method in python.
Does anyone knows how to disable the pins? | There is a built-in function GPIO.cleanup() that clean up all the ports you've used.
For the power and ground pins, they are not under software control. | 0 | false | 1 | 3,718 |
2015-05-05 09:45:40.620 | What does eigenfaces training set have to look like? | I am using python and openCV to create face recognition with Eigenfaces. I stumbled on a problem, since I don't know how to create training set.
Do I need multiple faces of people I want to recognize(myself for example), or do I need a lot of different faces to train my model?
First I tried training my model with 10 pi... | I later found the answer and would like to share it if someone will be facing the same challenges.
You need pictures only for the different people you are trying to recognise. I created my training set with 30 images of every person (6 persons) and figured out that histogram equalisation can play an important role when... | 1.2 | true | 1 | 3,719 |
2015-05-05 11:29:37.480 | How to localize a msi setup installer file to support various languages? | I have created a python application and created a .msi installer for it to work and get installed on other machines.
I would like to know how can the user change the language during the installation. ie the localization of msi. | A lot of this seems to be a question about how bdist_msi works, and it seems to be a tool that nobody here knows anything about. I would get some clarification from that tool somehow. The docs seem non-existent to me.
It might generate only one MSI in English. If so then you need to use a tool like Orca to translate ... | 0 | false | 1 | 3,720 |
2015-05-05 14:50:43.753 | How to list all scikit-learn classifiers that support predict_proba() | I need a list of all scikit-learn classifiers that support the predict_proba() method. Since the documentation provides no easy way of getting that information, how can get this programatically? | AdaBoostClassifier
BaggingClassifier
BayesianGaussianMixture
BernoulliNB
CalibratedClassifierCV
ComplementNB
DecisionTreeClassifier
ExtraTreeClassifier
ExtraTreesClassifier
GaussianMixture
GaussianNB
GaussianProcessClassifier
GradientBoostingClassifier
KNeighborsClassifier
LabelPropagation
LabelSpreading
LinearDiscrimi... | 0.296905 | false | 2 | 3,721 |
2015-05-05 14:50:43.753 | How to list all scikit-learn classifiers that support predict_proba() | I need a list of all scikit-learn classifiers that support the predict_proba() method. Since the documentation provides no easy way of getting that information, how can get this programatically? | If you are interested in a spesific type of estimator(say classifier), you could go with:
import sklearn
estimators = sklearn.utils.all_estimators(type_filter="classifier")
for name, class_ in estimators:
if not hasattr(class_, 'predict_proba'):
print(name) | 0 | false | 2 | 3,721 |
2015-05-05 21:21:26.733 | how to extract the relative colour intensity in a black and white image in python? | Suppose I have got a black an white image, how do I convert the colour intensity at each point into a numerical value that represents its relativity intensity?
I checked somewhere on the web and found the following:
Intensity = np.asarray(PIL.Image.open('test.jpg'))
What's the difference between asarray and array?... | The image is being opened as a color image, not as a black and white one. The shape is 181x187x3 because of that: the 3 is there because each pixel is an RGB value. Quite often images in black and white are actually stored in an RGB format. For an image image, if np.all(image[:,:,0]==image[:,:,1]) and so on, then you c... | 0.386912 | false | 1 | 3,722 |
2015-05-05 21:58:38.470 | how to set the camera in raspberry pi to take black and white image? | Are there any ways to set the camera in raspberry pi to take black and white image?, like using some commands / code in picamera library?
Since I need to compare the relative light intensity of a few different images, I'm worried that the camera will already so some adjustments itself when the object is under different... | What do you mean by "black and white image," in this case? There is no "true" black and white image of anything. You have sensors that have some frequency response to light, and those give you the values in the image.
In the case of the Raspberry Pi camera, and almost all standard cameras, there are red, green and blue... | 0.386912 | false | 1 | 3,723 |
2015-05-06 22:48:00.560 | how to write unreadable ^A into output file in Python? | Wondering how to write unreadable ^A into a file using Python. For unreadable ^A, I mean when we use command "set list" in vi, we can see unreadable character like ^I for '\t', $ for '\n'.
thanks in advance,
Lin | Another way to do it is '\1'. Cheers! | 0.545705 | false | 1 | 3,724 |
2015-05-07 02:30:29.993 | is there any possible way to run a python script on boot in windows operating system? | I want to run a python script which should always start when windows boot.
i believe i can create an executable windows executable file from python by using py2exe... But how to make as a start up service which will be triggered while boot
Is there any way ? | You don't need to create a py2exe executable for this, you can simply run the Python executable itself (assuming it's installed of course), passing the name of your script as an argument.
And one way to do that is to use the task scheduler, which can create tasks to be run at boot time, under any user account you have ... | 1.2 | true | 1 | 3,725 |
2015-05-07 17:55:50.333 | how to prevent python function to read outer scope variable? | When defining a python function, I find it hard to debug if I had a typo in a variable name and that variable already exists in the outer scope. I usually use similar names for variables of the same type of data structure, so if that happens, the function still runs fine but just returns a wrong result. So is there a w... | You're going against the point of having Scopes at all. We have local and global scopes for a reason. You can't prevent Python from seeing outer scope variables. Some other languages allow scope priority but Python's design principles enforce strong scoping. This was a language design choice and hence Python is the wro... | 1.2 | true | 1 | 3,726 |
2015-05-08 07:52:14.940 | Keep track of items in array with timer | I apologize I couldn't find a proper title, let me explain what I'm working on:
I have a Python IRC bot, and I want to be able to keep track of how long users have been idle in the channel, and allow them to earn things (I have it tied to Skype/Minecraft/my website) each x amount of hours they're idle in the channel.
... | Two general ways:
Create a separate timer for each user when he joins, do something when the timer fires and destroy it when the user leaves.
Have one timer set to fire, say, every second (or ten seconds) and iterate over all the users when it fires to see how long they have been idle.
A more precise answer would req... | 1.2 | true | 1 | 3,727 |
2015-05-08 08:23:54.197 | Port Python Code to Android | I am having some Python code that heavily relies on numpy/scipy and scikit-learn. What would be the best way to get it running on an Android device? I have read about a few ways to get Python code running on Android, mostly Pygame and Kivy but I am not sure how this would interact with numpy and scikit-learn.
Or would ... | Depends on what you need....
Python on a server using Flask/ Django would allow you to build an http UI or even an API interface for your Android (or any) device.
Qpython is a brilliant way to run python on an Android but probably won't cope with the whole of scipy so depends on what libraries have already been ported ... | 0.201295 | false | 1 | 3,728 |
2015-05-08 18:12:18.263 | Binary storage of floating point values (between 0 and 1) using less than 4 bytes? | I need to store a massive numpy vector to disk. Right now the vector that I am trying to store is ~2.4 billion elements long and the data is float64. This takes about 18GB of space when serialized out to disk.
If I use struct.pack() and use float32 (4 bytes) I can reduce it to ~9GB. I don't need anywhere near this amou... | Use struct.pack() with the f type code to get them into 4-byte packets. | 0 | false | 1 | 3,729 |
2015-05-10 12:14:10.010 | How to run qtconsole connected to ipython3 instance? | When I run %qtconsole from within ipython3 I get ERROR: Line magic function%qtconsolenot found., but ipython3 qtconsole in terminal starts fine. According to this, how can I run qtconsole instance connected to ipython3 instance? And how to run it on a single core -- rc[0].execute(%qtconsole)?
P.S. If someone know, tell... | Reposting as an answer:
If you just run ipython3 in a terminal, what you get is a pure terminal interface, it's not running a kernel that the Qt console can talk to.
If you run ipython3 console, you'll get a similar interface but it will be talking to a kernel, so you can start a Qt console to interact with it. You can... | 1.2 | true | 1 | 3,730 |
2015-05-11 16:16:37.047 | Returning a specific data type when referring to an object in Python | Usually when outputting an object in Python, you define the string that is returned in __repr__, but what if you want it to return something else instead, like an integer or tuple?
I'll give an example. My class is Users and there are member variables self.username and self.email. If I want to output an object of type ... | The __*__ attributes of an object are meant to implement internal functions standardized by the Python language. Like __add__ (which is used to provide a result of object + whatever, __repr__ is expected to behave in a defined way, which would include to return (a) certain datatype(s).
While statically typed languages ... | 0 | false | 1 | 3,731 |
2015-05-13 00:42:27.537 | Product of elements of scipy sparse matrix | I can find sum of all (non-zero) elements in scipy sparse matrix by mat.sum(), but how can I find their product? There's no mat.prod() method. | If you are using any plugin that is named as "infinite posts scroll" or "jetpack" or any thing similar delete it. | 0 | false | 1 | 3,732 |
2015-05-13 02:58:08.340 | SVM find member of outside training set | I try to make classification multiclass with SVM on OpenCV (I use openCV for python). Let's say if I have 5 class and training it well. I have been test it, and got good result.
The problem appear when object from 6th class come to this classification. Althought I haven't train this class before, why I got result this ... | The classic SVM does part the n-dimensional feature space with planes. That means every point in space is in one of the partitions and therefore belongs to one of the trained classes. there is no outlier detection.
However there is also the concept of a one-class SVM that tries to encapsulate the "known" space and clas... | 0.386912 | false | 1 | 3,733 |
2015-05-13 07:31:42.313 | how to upload the existing app in to web2py environment | I am new to web2py I have web2py application in my local system i want to upload this application into web2py environment throught admin interface option present in web2py Upload & install packed application and do some modifications and run the application but i am unable to uploded the app please give the suggesatio... | Just use the file system.
GUI:
Copy your application folder to your new instance of web2py (/web2py/applications).
Command line:
scp -r /home/username/oldarea/web2py/application/myApp /home/username/newarea/web2py/applications | 0 | false | 1 | 3,734 |
2015-05-14 10:14:07.090 | How to query rows with a minute/hour step interval in SqlAlchemy? | I am using sqlalchemy to query memory logs off a MySql database. I am using:
session.query(Memory).filter(Memmory.timestamp.between(from_date, to_date))
but the results after using the time window are still too many.
Now I want to query for results withing the time window, but filtered down by asking for entries logge... | If I understand correctly your from_date and to_date are just dates. If you set them to python datetime objects with the date/times you want your results between, it should work. | 0 | false | 1 | 3,735 |
2015-05-14 23:22:26.500 | Is it possible to see what a Python process is doing? | I created a python script that grabs some info from various websites, is it possible to analyze how long does it take to download the data and how long does it take to write it on a file?
I am interested in knowing how much it could improve running it on a better PC (it is currently running on a crappy old laptop. | You can always store the system time in a variable before a block of code that you want to test, do it again after then compare them. | 0 | false | 2 | 3,736 |
2015-05-14 23:22:26.500 | Is it possible to see what a Python process is doing? | I created a python script that grabs some info from various websites, is it possible to analyze how long does it take to download the data and how long does it take to write it on a file?
I am interested in knowing how much it could improve running it on a better PC (it is currently running on a crappy old laptop. | If you just want to know how long a process takes to run the time command is pretty handy. Just run time <command> and it will report how much time it took to run with it counted in a few categories, like wall clock time, system/kernel time and user space time. This won't tell you anything about which parts of the sy... | 0 | false | 2 | 3,736 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.