Q_Id
int64
337
49.3M
CreationDate
stringlengths
23
23
Users Score
int64
-42
1.15k
Other
int64
0
1
Python Basics and Environment
int64
0
1
System Administration and DevOps
int64
0
1
Tags
stringlengths
6
105
A_Id
int64
518
72.5M
AnswerCount
int64
1
64
is_accepted
bool
2 classes
Web Development
int64
0
1
GUI and Desktop Applications
int64
0
1
Answer
stringlengths
6
11.6k
Available Count
int64
1
31
Q_Score
int64
0
6.79k
Data Science and Machine Learning
int64
0
1
Question
stringlengths
15
29k
Title
stringlengths
11
150
Score
float64
-1
1.2
Database and SQL
int64
0
1
Networking and APIs
int64
0
1
ViewCount
int64
8
6.81M
27,493,323
2014-12-15T21:19:00.000
1
0
1
0
python,version-control,version,updates,conflict
27,493,427
4
false
0
0
Of course there is always a chance that upgrading a system component could cause errors. The Python devs do, however, take backwards compatibility fairly seriously. If this is a serious concern you should make sure your software has adequate unit tests, and run them on the updated Python before installing it on your production system.
2
0
0
Question: I'm a new python user. I'm currently using v2.7.6 in a tied relations with other systems and files written in different languages. Does updating to v2.7.9 might cause any issues? Any hidden conflicts for using py files that were written in 2.7.6 and/or using files written in other languages? Could is a bit of explanation on why it might cause issue/why it couldn't. Thanks for your time.
Python - Can updating 2.7.6 to 2.7.9 cause any problems/conflicts?
0.049958
0
0
656
27,494,758
2014-12-15T23:03:00.000
118
0
1
1
python,command-line
27,494,871
6
true
0
0
Add a shebang line to the top of the script: #!/usr/bin/env python Mark the script as executable: chmod +x myscript.py Add the dir containing it to your PATH variable. (If you want it to stick, you'll have to do this in .bashrc or .bash_profile in your home dir.) export PATH=/path/to/script:$PATH
2
72
0
How can I run a python script with my own command line name like 'myscript' without having to do 'python myscript.py' in the terminal?
How do I make a python script executable?
1.2
0
0
145,067
27,494,758
2014-12-15T23:03:00.000
1
0
1
1
python,command-line
66,843,453
6
false
0
0
The simplest way that comes to my mind is to use "pyinstaller". create an environment that contains all the lib you have used in your code. activate the environment and in the command window write pip install pyinstaller Use the command window to open the main directory that codes maincode.py is located. remember to keep the environment active and write pyinstaller maincode.py Check the folder named "build" and you will find the executable file. I hope that this solution helps you. GL
2
72
0
How can I run a python script with my own command line name like 'myscript' without having to do 'python myscript.py' in the terminal?
How do I make a python script executable?
0.033321
0
0
145,067
27,497,044
2014-12-16T03:27:00.000
1
0
0
0
python,linux,django,amazon-web-services,amazon-ec2
27,500,649
1
true
1
0
Just install blinker by typing pip install blinker in the console. Be sure you install it in your virtualenv if by any chance you use one, just by activating it before executing the pip command. You may also review your staging procedure to correctly install project dependencies.
1
0
0
I am getting this error: signalling support is unavailable because the blinker library is not installed. I am running Django 1.6.5 under python 2.6.9. Is it possible that the error will go away if i update python on the server to 2.7.x? If so how can I update the server without losing everything I have done upto this point creating my website on the instance? Thanks so much in advance.
Runtime error alongside Django on Amazon AWS EC2 Linux AMI issue
1.2
0
0
274
27,499,268
2014-12-16T07:05:00.000
2
0
0
0
python,windows,audio
27,499,520
1
false
1
0
Sound cards are for playing audio, not sending data. You can't rely on an arbitrary signal not being altered by the hardware, much less the software. For example, many sound cards have a capacitor in series with the output to filter out DC bias. If you try to pass a DC-biased (or very low frequency) signal through such a sound card, it will be distorted. And there's nothing you can do about it at the software level.
1
1
0
We have a python program which outputs specific waveforms over the audio to drive an LED, for an easy and cheap robot programming device. With the windows systems that we've tested everything works fine, but on some systems the waveform seems to be altered. We've used the control panel to disable any 'enhancements' for the audio output endpoint but it doesn't seem to help. So, is it possible, using python, to instruct Windows to play audio unchanged? Or do some of the audio gurus here have another theory of what could be affecting the audio?
Is it possible to ensure audio isn't modified when playing back under Windows
0.379949
0
0
39
27,499,546
2014-12-16T07:24:00.000
3
0
0
0
python,post,scrapy
27,499,859
2
false
1
0
Use some traffic monitoring software , i personally use fiddler. it will help you to check the requests sent from python as well as from browsers
2
4
0
How to debug a scrapy Request object? requestobj= FormRequest.from_response(response, formxpath =form_xpath,callback=self.parse1) I need to check formdata of requestobj .But I didn't find any documentation for debugging Request object
scrapy debug Request object
0.291313
0
1
764
27,499,546
2014-12-16T07:24:00.000
1
0
0
0
python,post,scrapy
27,615,272
2
false
1
0
try sending request to: http://httpbin.org/ or http://echo.opera.com/ you will get a response with information your request
2
4
0
How to debug a scrapy Request object? requestobj= FormRequest.from_response(response, formxpath =form_xpath,callback=self.parse1) I need to check formdata of requestobj .But I didn't find any documentation for debugging Request object
scrapy debug Request object
0.099668
0
1
764
27,503,003
2014-12-16T10:55:00.000
10
0
1
1
python,installation
27,523,478
4
true
0
0
I found the solution. The registry had wrong entries. As I have a 32 bit version installed I went to HKEY_LOCAL_MACHINE|HKEY_CURRENT_USER\SOFTWARE\wow6432node\Python\PythonCore\2.7\InstallPath and the value was set to C:\Python27 while my installation is in D:\Python27. So I changed all the registry values to match the correct location and it now works fine. It's been quite a while I installed Python 2.7, but I assume I had Python 2.7 installed first. Then I deleted it and installed pythonxy in this new location. I probably didn't uninstall the previous version correctly.
1
6
0
I'm on Windows 7. I have Python 2.7 installed for years. I installed recently Python 3.4. I'm trying to use the new py launcher. When I open the cmd terminal and type py -2, I get this error message: Requested Python version (2) not installed. How can make py aware of my python 2.7 installation? Note: python 2.7 is installed in a non-standard directory (not in C:\Python27), in case this is the problem.
py launcher does not find my Python 2.7
1.2
0
0
21,363
27,509,088
2014-12-16T16:16:00.000
0
0
0
0
python,openerp,pycharm,openerp-7
27,548,485
1
false
1
0
Any change made directly in the OpenERP/Odoo GUI is not written back to the module and will overwritten in the next module upgrade. Use those direct changes only for experimenting or fast prototyping. Changes you mean to be final should always be made in your module files.
1
4
0
SO i'm using Open ERP 7 and wanted to make a custom module. I've put everything into PyCharm to edit parts there, but sometimes I edit some forms or add some fields with in OpenERP itself under the Database structure. Any changes I make under the Database Structure (e.g adding a field) won't show up in my PyCharm. Is there a way to keep them both in sync? Thanks in advance
Keeping custom module synced in OpenERP7
0
0
0
46
27,510,077
2014-12-16T17:08:00.000
2
0
1
0
python,self-modifying
27,510,374
1
true
0
0
My first inclination is to say "don't do that". Self-modifying Python (really any language) makes it extremely difficult to maintain a versioned library. You make a bug fix and need to redistribute - how do you merge data you stored via self-modification. Very hard to authenticate packaging using a hash - once the local version is modified it's hard to tell which version it originated because SHAs won't match. It's unsafe - You could just save and load a Python class that's not stored with your package, however, if it's user writable, a foreign process could add any arbitrary Python code to that file to evaluate. Kind of like SQL injection but Python style. Python makes is so trivial to load and dump JSON files, that for simple things, I wouldn't think of anything else. Even CSV files are trivial and can be bound to maps but can be more easily manipulated as data using your favorite spreadsheet editor. My suggestion - don't use self-modifiying Python unless you're just wanting to experiment; It's just not a practical solution in the real world, unless you're working in an embedded environment where disk and memory are a premium.
1
0
0
I've considered storing the high scores for my game as variables in the code itself rather than as a text file as I've done so far because it means less additional files are required to run it and that attributing 999999 points becomes harder. However, this would then require me to run self-modifying code to overwrite the global variables representing the scores permanently. I looked into that and considering that all I want to do is really just to change global variables, all the stuff I found was too advanced. I'd appreciate if someone could give me an explanation on how to write self-modifying Python code to do just that, preferably with an example too as it aids understanding.
Self-modifying Python code to keep track of high scores
1.2
0
0
414
27,513,601
2014-12-16T20:43:00.000
1
0
1
0
python,shell
27,517,551
1
false
0
0
You can't. You're entering a literal tab character. Python isn't responsible for how it displays; your terminal is. It's possible your terminal has a way to configure this, but I'd advise against it, as other programs are very likely to assume the de facto standard tabstop of 8.
1
0
0
How does one set number of spaces per tab key in interactive shell - I can't seem to find it, in the docs.
Python how to set number of spaces per tab key in interactive shell
0.197375
0
0
188
27,514,985
2014-12-16T22:17:00.000
4
0
0
1
python,google-app-engine
34,706,288
2
false
1
0
Yes!! What you are trying to do is not possible. The reason is that there are absolute references in the backup files to the original backup location (bucket). So moving the files to another GCS location will not work. Instead you have to leave the backup files in the original GCS bucket and give your new project read access to that folder. That is done in the "Edit bucket permissions" option. eg. add: Project - owners-12345678 - Reader Now you are able to import from that bucket in your new project in "Import Bucket Information".
2
8
0
My goal was to duplicate my Google App Engine application. I created new application, and upload all needed code from source application(python). Then I uploaded previously created backup files from the Cloud Storage of the source application (first I downloaded those files to PC and than uploaded files to GCS bucket of the target app) After that I tried to restore data from those files, by using "Import Backup Information" button. Backup information file is founded and I can add it to the list of available backups. But when I try to do restore I receive error: "There was a problem kicking off the jobs. The error was: Backup not readable" Also I tried to upload those files back to original application and I was able to restore from them, by using the same procedure, so the files are not corrupted. I know there are another methods of copying data between applications, but I wanted to use this method. If for example, my Google account is being hacked and I can not access my original application data, but I have all backup data on my hard drive. Then I can simply create new app and copy all data to the new app... Has anyone before encountered with the similar problem, and maybe found some solution? Thanks!
Backup in one and restore in another Google App Engine application by using Cloud Storage?
0.379949
1
0
961
27,514,985
2014-12-16T22:17:00.000
1
0
0
1
python,google-app-engine
29,852,870
2
false
1
0
Given the message, my guess is that the target application has no read access to the bucket where the backup is stores. Add the application to the permitted users to that bucket before creating the backup so that the backup objects will inherit the permission.
2
8
0
My goal was to duplicate my Google App Engine application. I created new application, and upload all needed code from source application(python). Then I uploaded previously created backup files from the Cloud Storage of the source application (first I downloaded those files to PC and than uploaded files to GCS bucket of the target app) After that I tried to restore data from those files, by using "Import Backup Information" button. Backup information file is founded and I can add it to the list of available backups. But when I try to do restore I receive error: "There was a problem kicking off the jobs. The error was: Backup not readable" Also I tried to upload those files back to original application and I was able to restore from them, by using the same procedure, so the files are not corrupted. I know there are another methods of copying data between applications, but I wanted to use this method. If for example, my Google account is being hacked and I can not access my original application data, but I have all backup data on my hard drive. Then I can simply create new app and copy all data to the new app... Has anyone before encountered with the similar problem, and maybe found some solution? Thanks!
Backup in one and restore in another Google App Engine application by using Cloud Storage?
0.099668
1
0
961
27,517,192
2014-12-17T01:59:00.000
0
0
0
0
python,cherrypy
27,565,293
2
false
1
0
Set tools.sessions.persistent to False
1
0
0
In cherrypy is there a configuration option so that sessions do not have a "timeout", or if they do, expire immediately when the browser is closed? Right now tools.sessions.on is true and tools.sessions.timeout is 60 minutes.
Cherrypy session timeout on browser closed?
0
0
1
474
27,517,255
2014-12-17T02:05:00.000
0
0
1
1
python,windows,command-line,command
27,557,706
2
false
0
0
Issue resolved. Since no feasible solution was found in 2 days, I decided to wipe all keys containing 'python' from registry as well as some files that were not parts of other programs. This resolved the issue after re-installing python. If anyone finds the true cause of this misbehavior and other - less brutal - solution, please write it here for future reference.
1
1
0
I seem to have problem launching python from command line. I tried various things with no success. Problem: When trying to run python from the command line, there is no response i.e. I do not get message about 'command not found' and console does not launch. Only option to open python console is to run C:\Python34\python.exe directly. Running using python command does not work even when in the python directory but python.exe launches. Issue with the launching this way is that python console is launched in new window. This whole problem is present only on one machine while on my other machine I am able to run python correctly and console launches in the command prompt window from which the python command was executed. PATH is correctly set to C:\Python34\;C:\Python34\Scripts;... and where python correctly returns C:\Python34\python.exe. I verified that running other commands imported through PATH (such as javac) run correctly. Things I tried: Completely re-installing python both with x86 and x64 python installations with no success. Copy installation from my second machine and manually set the path variables - again no success. Can anyone hint how to resolve this behavior? (Additional info: Win 8.1 x64, python 3.4.2)
Python console not launching properly from command line
0
0
0
632
27,517,939
2014-12-17T03:40:00.000
1
1
0
1
python,c++,protocol-buffers
27,687,619
1
false
0
1
So this is a happy non-answer using my experience. The pure-python bindings for google protobuf are a terrible port of C/C++ stuff. However, I had quite a bit of success wrapping C google protobuf generated bindings using cffi. Someone should go ahead and create a more generic binding, but that would just a short consulting stint.
1
2
0
Protobuf with pure python performance 3x slowly on pypy than CPython do. So I try to use c++ implementation for pypy. These are two error (PyFloatObject undefined and const char* to char*) when I compile protobuf(2.6.1 release) c++ implementation for pypy. I compile successfully after I modify python/google/protobuf/pyext/message.c,But I get 'Segmentation fault' error finally when I use protobuf with c++ implementation on pypy. I don't know how to fix it, help me please!
Is there any way to use Google Protobuf on pypy?
0.197375
0
0
567
27,519,480
2014-12-17T06:21:00.000
1
0
1
0
python,class,oop,iterator,python-3.4
27,519,520
3
false
0
0
I don't quite get what you are meaning by body. I suppose you are talking about the definition of the method __iter__. Well sometimes you could use yield to return a generator. In this case, you could write the generating logic in the body of __iter__. Or returning another iterator might involve some logic. So it's not always simply a return.
2
1
0
What is the significance of the body of the __iter__ method in a class definition in Python? It is my understanding that an __iter__ method must return an iterator; then shouldn't every __iter__ method only contain a return statement which returns an iterator (defined elsewhere) ? Why is there a body in the __iter__ method in some cases?
What is the point of the body of the __iter__ method?
0.066568
0
0
76
27,519,480
2014-12-17T06:21:00.000
-1
0
1
0
python,class,oop,iterator,python-3.4
27,519,544
3
false
0
0
The iter method returns an iterator or defines a getitem method, taking sequential indexes starting from zero and raising an IndexError when the indexes are no longer valid.
2
1
0
What is the significance of the body of the __iter__ method in a class definition in Python? It is my understanding that an __iter__ method must return an iterator; then shouldn't every __iter__ method only contain a return statement which returns an iterator (defined elsewhere) ? Why is there a body in the __iter__ method in some cases?
What is the point of the body of the __iter__ method?
-0.066568
0
0
76
27,519,822
2014-12-17T06:50:00.000
1
0
1
0
python,class,numpy
27,519,855
1
false
0
0
You can't. Stick a numpy array on your instance, and put whatever you want inside that.
1
1
0
For example, I would like to store attributes in a numpy array.
How can I change the container type for a class in python?
0.197375
0
0
43
27,519,960
2014-12-17T07:02:00.000
10
0
0
0
python,django,bokeh
27,520,156
1
false
1
0
No need to reinvent. bokeh-server is a webserver and can listen on arbitrary port. you can have your django webserver listen on some other arbitrary port. ... and integrate the two: have redirects from django to bokeh-server, or webserver in front, e.g. nginx which does reverse-proxy.
1
13
0
From what I read the dynamic and big data rendering capabilities of Bokeh are accessible by use of the bokeh-server. In Bokeh documentation there is a brief mention of embedding the bokeh-server in a Flask application using the blueprint api. This option retains all of the Bokeh's dynamic and big data rendering capabilities. I would like to do the same for a django1.7 application. Has this been done? If so are there any examples?
How to embed Bokeh server in Django application
1
0
0
5,749
27,521,836
2014-12-17T09:09:00.000
1
0
1
0
python,numpy
27,522,080
1
false
0
0
Objects of type numpy.array are n-dimensional, meaning they can represent 2-dimensional matrices, as well as 3D, 4D, 5D, etc. The numpy.matrix, however, is designed specifically for the purpose of 2-dimensional matrices. As part of this specialisation, some of the operators are modified, for example * refers to matrix multiplication. Use whichever is most sensible for your work, but make sure you remain consistent. If you'll occasionally have to deal with higher-dimensional data then it makes sense to use numpy.array all the time (you can still do matrix multiplication with 2D numpy.array, but you have to use a method as opposed to the * operator).
1
0
1
It seesms like we can have n dimensional array by numpy.array also numpy.matrix is exact matrix I want. which one is generally used?
Which object in Numpy Python is good for matrix manipulation? numpy.array or numpy.matrix?
0.197375
0
0
83
27,523,124
2014-12-17T10:13:00.000
1
0
0
1
python,google-app-engine,google-cloud-datastore
27,540,122
1
true
1
0
No, it is done asynchronously and you are not able to control this process. Hooks available only for by key gets, not for index queries. Try to build your datastore with parent-child relationships, so you can do ancestor queries, they are always consistent.
1
1
0
Is there a way to know / detect if an object (after being put to the datastore) has been written to an index i.e. object would be visible in a relevant query? Maybe something like a hook method? Thanks!
Completion of App Engine Index Writes (Python)
1.2
0
0
45
27,528,859
2014-12-17T15:19:00.000
3
0
0
1
python,google-app-engine,cron
27,530,878
1
false
1
0
You can schedule a cron job to run every hour, because every hour there is 9 am somewhere.
1
0
0
I want to schedule a task for 9:00 AM in every country. (basically 9:00 AM in every time zone). How can I schedule that in google appengine? Will it take multiple timezones for time zone parameter? Thanks in advance
Multiple Time Zones in Google Appengine Cron Job
0.53705
0
0
571
27,534,078
2014-12-17T20:16:00.000
1
0
0
0
python,django,django-models,django-templates,django-admin
27,534,164
1
true
1
0
Well you have to save it somewhere in order to map the user and the image.... So I can think of 2 solutions - Have a field that stores the path. Then you can access it via the template, something like this - <img src="{{author.photo_path}}"> If you're saying the path might change, you can have a user ID for each user, and store his photo with that ID. Then you can simply do <img src="/path/{{author.id}}_picture.gif"> Using the second solution, you can also have the path as a variable in your code, and then pass it to the template, and access the picture like this - <img src="/{{path}}/{{author.id}}_picture.gif">, which doesn't force you to have a hardcoded path, and once the path changes you only change it once, not in all your model instances/template files
1
0
0
I'm creating a basic blog in Django. One of my classes is for the authors. Each contains Name, Position, Biography, etc., and I'm attempting to associate existing images with each author to be used as avatars, essentially. FileField and ImageField aren't what I want to use as I already have images stored statically elsewhere- I just want to specify each image's path manually in the Django admin as a URL (CharField/TextField, whatever) and have that image served when I call {{ author.photo }} in a template, for example. I also don't necessarily want to source the image path from the class model, as the structure and paths of the existing images may change. Any ideas?
Associate Existing Image File with Django Model
1.2
0
0
360
27,538,582
2014-12-18T03:03:00.000
0
0
0
1
python,scripting,hotkeys,hid
28,269,358
1
true
0
0
Uinput is the definitive, Kernel-guru sanctioned way to do this on Linux. Thanks to @Reily Grant for the Mac info!
1
0
0
I couldn't find a way to do this on Mac and Linux. With Windows one could use ctypes and then use console.SendKeys. So far as I can tell there is certainly no way that Apple would let a humble user take over the mouse and keyboard, but how might an average Joe do this on Linux? Despite no findings, I would assume there is some way to do this through an X-server? Any input, in any programming language, is very welcome
Keyboard emulation in python, cross platform
1.2
0
0
509
27,538,753
2014-12-18T03:22:00.000
0
0
1
0
python,terminal,pycharm
27,539,114
1
false
0
0
I can't reproduce the issue you're experiencing. I remapped "Hide Active Tool Window" to Ctrl-Shift-H in PyCharm 4.0.3 on OS X and it worked fine. Preferences -> (Search box) "keymap" -> (Keymap Search box) "hide active" Right-click, Add Keyboard Shortcut
1
2
0
When using the terminal window in PyCharm, I cannot find a way to use a keyboard shortcut to close the terminal window, other than SHIFT+ESC. This particular keyboard shortcut is going to give me carpal tunnel. Trying to assign a custom keyboard shortcut like COMMAND+\ does not work. Also pressing the ESC key alone doesn't loose focus. Does anyone know a way that makes it easier to close the window without a mouse? I know it seems like a minor thing but if you switch back and forth between the editor and terminal as much as I do... it matters.
PyCharm 4.0 Terminal Window
0
0
0
317
27,539,852
2014-12-18T05:35:00.000
1
0
1
0
python,string,parsing,format,character
27,539,969
4
false
0
0
Do you mean the list method? s='abccda' list(s) # ['a', 'b', 'c', 'c', 'd', 'a']
1
2
0
In Python 2.7 how do I parse 'abc' into 'a b c' for a very long string (like 1000 chars)? Or how would I convert 'abccda' to '1 2 3 3 4 1'? (where each unique letter maps to a unique digit, 1-4) I imagine I could pop the chars off, one by one, but I'm new to Python and wonder if there is a simple function that does it.
python parse string into individual chararcters
0.049958
0
0
116
27,542,828
2014-12-18T09:08:00.000
2
0
0
0
python-3.x,gtk2
27,592,574
1
true
0
1
Technically, it is possible, but not advisable. If you compile GTK 2.24 yourself with GObject introspection turned on, and don't have GTK 3.x installed, then you should be able to use from gi.repository import Gtk to access the GTK 2 API. However, this is not supported in any way, and even prints out a warning message to that effect. I don't even know if it still works. Even if it does work, it's still a bad idea; if your application only works on an unsupported configuration like this, then how are you going to distribute it?
1
1
0
I want to create some GTK+2 applications using Python 3. I searched many places, but can only find tutorials for using GTK+2 together with Python 2, using PyGtk, or GTK+3 together with Python 3, using PyGobject. Is there any way to create GTK+2 applications using Python 3?
Is it possible to create GTK+2.x applications using Python 3?
1.2
0
0
824
27,553,319
2014-12-18T18:30:00.000
0
0
0
0
python,python-3.x,urllib
27,556,712
1
false
0
0
Now how do I store the last known absolute url to extract the netloc from it and append it to relative url? Should I save the last known absolute URL in a text file? What do you think is wrong with this? Seems to make sense to me... (depending on context, obviously)
1
0
0
I am new to Python programming. While making an application, I ran into this problem. I am parsing URL using urllib library of python. I want to convert any relative url into its corresponding absolute url. I get relative and absolute URLs in random fashiion and they may not be from the same domain. Now how do I store the last known absolute url to extract the netloc from it and append it to relative url? Should I save the last known absolute URL in a text file? Or is there any better option to this problem?
URL parsing issue in python
0
0
1
117
27,555,520
2014-12-18T20:55:00.000
1
0
1
0
python,class
27,555,893
2
false
0
0
If your program starts assuming big dimensions, yes, you could split your classes or simply your functions according to what they do. Usually functions that do similar tasks or that work on the same data are put together. To import a file containing a set of functions that you defined, if the file is in the same folder where your main script is, you can simply use this statement, if, for example, the name of the script containing your function that you want to imported is called functions.py, you can simply do import functions or from functions import *, or, better, from functions import function_1. Let's talk about the 3 ways of importing files that I have just mentioned: import functions Here, in order to use one of your functions, for example foo, you have to put the name of the module in front of the name of the function followed by a .: functions.foo('this is a string') from functions import * In this case, you can directly call foo just typing foo('this is a new method of importing files'). * means that you have just imported everything from the module functions. from functions import function_1 In this last case, you have imported a specific function function_1 from the module functions, and you can use just the function_1 from the same module: function_1('I cannot use the function "foo" here, because I did not imported it')
1
0
0
I am wondering if it would be a good idea to use different .py scripts for different parts of a Python program. Like one .py file for a calculator and another for class files and etc. If it is a good idea, is it possible? If possible, where can I find how to do so? I am asking this because I find it confusing to have so much code in a single file, and have to find it anytime fixing is needed.
Is it a good idea to make use different Python scripts for programs?
0.099668
0
0
545
27,558,514
2014-12-19T01:27:00.000
-2
1
0
0
python,pycharm,remote-access,interpreter
53,589,468
3
false
0
0
i meet the same error, file->settings checking your interpreter setting, You don't set the 'host' and 'post',or your set but the content was clear. check again, and it truly work
2
6
0
I have a remote interpreter set up in PyCharm. Everytime I close and reopen PyCharm, the connection seems to be broken, and the process to "reopen" the connection doesn't feel efficient to me. Before doing the following, it is not possible to run any script. Here is what I usually do: File -­> Settings Project -> Project Interpreter Click on the gear icon on the right. Choose "More" With my remote interpreter selected, click on "Edit" Change "SSH Credentials" for "Deployment Configuration" (all the info is already filled) Click "ok" multiple times to close everything up. At that point, I can run any scripts on the remote machine. What is the best/fastest way to do this? (any way to "save the settings"?)
Connecting to remote interpreter when starting PyCharm
-0.132549
0
0
10,796
27,558,514
2014-12-19T01:27:00.000
2
1
0
0
python,pycharm,remote-access,interpreter
27,585,038
3
false
0
0
This was a bug in version 4.0.2 of PyCharm and was corrected in version 4.0.3. Edit: No longer true. I tried with another computer and having the most recent version doesn't fix the problem.
2
6
0
I have a remote interpreter set up in PyCharm. Everytime I close and reopen PyCharm, the connection seems to be broken, and the process to "reopen" the connection doesn't feel efficient to me. Before doing the following, it is not possible to run any script. Here is what I usually do: File -­> Settings Project -> Project Interpreter Click on the gear icon on the right. Choose "More" With my remote interpreter selected, click on "Edit" Change "SSH Credentials" for "Deployment Configuration" (all the info is already filled) Click "ok" multiple times to close everything up. At that point, I can run any scripts on the remote machine. What is the best/fastest way to do this? (any way to "save the settings"?)
Connecting to remote interpreter when starting PyCharm
0.132549
0
0
10,796
27,559,330
2014-12-19T03:32:00.000
1
0
1
0
python,django,terminal,komodoedit
27,559,411
1
true
1
0
Let's start from the beginning: You are in your project folder eg /home/me/myproject You create a new virtualenv, eg virtualenv /home/me/virtualenvs/myprojectenv You activate the new virtualenv: source /home/me/virtualenvs/myprojectenv/bin/activate ...this means that python and pip commands now point to the versions installed in your virtualenv You install your project dependencies pip install django You can ./manage.py runserver successfully Now, the virtualenv has only been activated in your current terminal session. If you cd outside your project directory the virtualenv is still active. But if you open a new terminal window (or turn off the computer and come back later) the virtualenv is not activated. If the virtualenv is not activated then the python and pip commands point to the system-installed copies (if they exist) and Django has not been installed there. All you need to do when you open a new terminal is step 3. above: source /home/me/virtualenvs/myprojectenv/bin/activate Possibly the tutorial you followed got you to install virtualenvwrapper which is an additional convenience layer around the virtualenv commands above. In that case the steps would look like this: You are in your project folder eg /home/me/myproject You create a new virtualenv, eg mkvirtualenv myprojectenv ...virtualenv has already been activated for you now! You install your project dependencies pip install django You can ./manage.py runserver successfully and whenever you start a new shell session you need to: workon myprojectenv in order to re-activate the virtualenv
1
0
0
I sincerely apologize for the noobish dribble thats about to come out here: Okay so I am following along with a youtube tutorial using terminal/django/komodo edit to make a simple website. This is my first time really using terminal, I am having issues. I have read up on the terminal and searched this site for my question but to no avail. Im hoping someone will take the time to answer this for me as it is most infuriating. This is my first time working with virtual env's as well. So my question is, How do I uhmm, I suppose "save" my virtual env settings? So I have set up a new virualenv. Downloaded django and started up my server so I can see things such as the admin page, log in page, from the internet page. Things go as they should along with the tutorial until it comes time to eventually turn off my computer. When I reload the virtualenv I cannot run the server, it gives me: Import error, no module named django.core.management. I use pip freeze and it shows that django is no longer installed. If trying to reinstall django it gives a long block of error messages. All the work done within the virtualenv file is still visible for the komodo edit pages however, but it seems the terminal does not want to work properly. My only option thus far has been to completely remake a virualenv, re-set it all up with the proper imports, files, django and restart the project. so my questions are: how do I save my terminal and/or virtualenv settings? What do I need to do before logging off to ensure I will be able to continue with my project? Lets say I am going to continue with my project, How do I start up the project again via terminal? Is that where I am going wrong? I've assumed up until now that I must go into terminal, start the server again and then from komodo edit continue with my project, but inside the terminal everything goes wrong. Im not even explicitly saying I cannot continue with my project, I am more saying the terminal is not recognizing I had django installed within my virtualenv, and it is not letting me start the server again. I have tried doing the research on my own, I am not one to sit back and wait for an answer but being completely new, this is baffling. I am sorry for the noob questions, feel free to link another answered question or website that has the answer. Thank you all!!
Terminal/django/komodo edit
1.2
0
0
323
27,561,003
2014-12-19T06:48:00.000
1
0
0
1
python,svn,jenkins
27,594,747
1
false
0
0
I'd not do this. There isn't an OOTB solution as this would generally be seen as a terrible idea - committing on at least two levels: 1. committing derived artifacts is sub-optimal 2. committing binaries is sub-optimal However if I absolutely had too I'd setup a job that did the binary commit that shared the same workspace as the compile job. I'd' have the commit job triggered on success of the compile - this job could run your script (python, or a simple bash build step that invokes svn cli. Be sure to set the compile job to block when downstream job is building, you wouldn't want the binaries changing during the commit.
1
0
0
Is there any OOTB way to get a post build step to push the results of a Jenkins build back to a (Subversion) repository? We use one repository for sources and another to record the binaries for every commit to trunk (very useful for debugging). The Jenkins pull on the source SVN repository change works perfectly, the build step is fine, but now we need the 'what next' step. A Python script to handle the push back to SVN is easy enough to write providing it can find the build result details but how best to integrate this with Jenkins? I see some posts/plugins about GIT, but not so much about SVN. Failing a plugin for the job I'll hook in a post-build script using the postbuild-task plugin.
Jenkins: How to push build artifacts back to source control?
0.197375
0
0
620
27,564,320
2014-12-19T10:42:00.000
2
1
1
0
python,regex,raspberry-pi,raspbian
27,578,046
1
false
0
0
Python itself supports regexes (via a built-in module). If you're just interested in playing around with them, import re in an interactive shell, and you have access to Python's regular expression engine.
1
2
0
Is there an editor that I could install on the Raspbian OS to practice Regex with? If not, what about through Python? If so, is there a good python IDE out there for Raspbian that supports Regexs?
Using Regular Expressions on my Raspberry Pi
0.379949
0
0
335
27,567,450
2014-12-19T13:48:00.000
0
0
0
1
python-2.7,subprocess
27,570,551
1
false
0
0
REINSTALLING the python bindings resolved my issue. I don't see GDAL on the paths below but its working now. Is it supposed to be there so since its not, I might probably have another round of GDAL head scratching in the future? ::::::::::::::::::::::::::::::::::::::: THIS is what I currently have when I type in sys.path on python: Microsoft Windows [Version 6.2.9200] (c) 2012 Microsoft Corporation. All rights reserved. C:\Users\User>python Python 2.7.8 (default, Jun 30 2014, 16:08:48) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. import sys sys.path ['', 'C:\windows\SYSTEM32\python27.zip', 'C:\Python27\DLLs', 'C:\Python27\lib', 'C:\Python27 \lib\plat-win', 'C:\Python27\lib\lib-tk', 'C:\Python27', 'C:\Python27\lib\site-packages', ' C:\Python27\lib\site-packages\wx-3.0-msw']
1
0
0
I get an error when trying to run ogr2ogr thru subprocess but I am able to run it using just the windows command prompt. The script will be part of a series of processes that start with batch importing gpx files unto a postgres db. Can somebody please tell me what's wrong? Thanks! :::::::::::::::::::::::::::: Running THIS script gives me an ERROR: 'ogr2ogr' is not recognized as an internal or external command, operable program or batch file. import subprocess import sys print sys.executable track= "20131007.gpx" subprocess.call(["ogr2ogr", "-f", "PostgreSQL", "PG:dbname=TTBASEMain host=localhost port=5432 user=postgres password=minda", track], shell=True) ::::::::::::::::::::::::::::: THIS CODE does its job well. ogr2ogr -f PostgreSQL PG:"dbname='TTBASEMain' host='localhost' port='5432' user='postgres' password='minda'" "20131007.gpx" ::::::::::::::::::::::::::::: THIS is what I have in my environment path: C:\Users\User>path PATH=C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\OpenCL SDK\3.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\3.0\bin\x64;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine C omponents\IPT;C:\Program Files\Lenovo\Bluetooth Software\;C:\Program Files\Lenovo\Bluetooth Software\syswow64;C:\lastools\bin;C:\Python27;C:\Python27\Scripts;C:\Python27\DLLs;C:\Python27\Lib\site-packages;C:\Users\User\AppData\Roaming.local\bin;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\GDAL
ERROR: 'ogr2ogr' is not recognized as an internal or external command, operable program or batch file when running ogr2ogr in python script
0
1
0
1,962
27,567,560
2014-12-19T13:56:00.000
18
0
1
0
python,anaconda,miniconda
27,584,745
1
true
0
0
You can safely delete the tar.bz2 files. They are only used as a cache. The command conda clean -t will clean them automatically.
1
22
0
On my desktop PC I have anaconda installed, and on my laptop - to save space - I thought i'd install miniconda and be selective about the modules I install. So I installed a handful, numpy, scipy etc. I didn't install anything which isn't part of the default anaconda install, but I just realized my miniconda install is taking up more space than the anaconda install! (1.8GB vs 2.2GB). (no environments in either) The bulk of the difference comes from the pkgs folder. The miniconda install seems to have the tar.bz2 of all of the installed packages as well as the exploded versions. Are these safe to delete? Will they be deleted automatically after a while? Is there an option to not cache these? P.S. I'm developing on both windows and mac (i've tried installed anaconda and miniconda on both mac and windows to see, and I get very similar results).
Anaconda vs miniconda space
1.2
0
0
10,520
27,568,886
2014-12-19T15:18:00.000
1
0
1
0
python,python-2.7,opencv,numpy,upgrade
27,580,194
2
false
0
0
Upgrading to new version can give you more stable and featured version. Usually this is the case - version 2.7 is mature and stable. I think you do not need to re-install/reconfigure the packages again because of this stability (2.7.6 and 2.7.9 are 2.7 anyway). Problems are hardly possible, although they may be in very small number of cases. And folder with the subversion X.X will be overwrited, because there are no any folders for minor versions X.X.X Unfortunately, I can not give more precise answer.
1
4
1
I'm using Python for my research. I have both version of Python on my system: 3.3.2 and 2.7.6. However due to the compatibility with the required packages (openCV, Numpy, Scipy, etc.) and the legacy code, I work most of the time with Python 2.7.6. It took me quite a lot of effort at the beginning to set up the environment ready for my works. E.g. I didn't follow the "easy" way of installing all-in-one Anaconda or Enthought Canopy software, instead I installed packages one by one (using pip..), some packages,(scipy, sympy, pandas, lxml) could not be installed by pip and I had to installed using a MSI file. Now all of them are working fine. I see that Python released the newer version: 2.7.9. My questions are: (1) is it worth upgrading from 2.7.6 to 2.7.9, any benefit in performance, security, stability,...? (2) will it break/overwrite the current setup of my 2.7.6 environment? I notice there are 2 folders on my C:\, which are Python27 and Python33. As the logic, Python 2.7.9 will also be in the same folder Python27 (as 2.7.6). Do I need to re-install/reconfigure the packages again? (If there will be a lot of hassles, then perhaps I'll follow the mantra: "if it is not broken, don't fix it"...) EDIT: Thanks for the comments, but as my understanding, this site is about Q&A: got question & get answered. It's a simple and direct question, let me make it clearer: e.g. Python has Lib/site-packages folder with my packages inside. Will the new installation overwrite that folder, etc. People may know or not know about this fact, based on their knowledge or experience. I don't want to experiment myself so I asked, just for my curiosity. I know there's a trend to reform SO to get better question and answer quality, but I don't know since when the people can be so ridiculously sensitive :) If this one is asked in "Stack Exchange Programming" site, then I can understand that it's not well-suited for that site. Now I understand another effect of the trolls: they make a community become over-sensitive and drive the new/naive newbie away.
Install Python 2.7.9 over 2.7.6
0.099668
0
0
11,082
27,572,366
2014-12-19T19:04:00.000
3
0
1
1
python,windows,cmd
27,572,488
3
false
0
0
You'll have to make changes to the PATH environmental variable. To do this, click the Start button, right click on "Computer", hit "Properties", click "Advanced System Settings" in the left sidebar. Then click the Environmental Variables button. Under User or System variables, there will be a variable called "PATH" that includes a path to you Python installation. You can change this to the Python 3 install path. You can also change the name of the Python 3 executable to "python3.exe", and add the directory to the path variable, separating it from other directories with a semicolon. Then you can use both 2 and 3 by calling python and python3 respectively.
2
4
0
I have both Python 2.7 and 3.4 installed on my Windows Machine. When I type Python in CMD it defaults to Python2.7. How do I switch to 3.4?
Changing between Python 2.x and 3.x in windows CMD?
0.197375
0
0
6,850
27,572,366
2014-12-19T19:04:00.000
2
0
1
1
python,windows,cmd
33,028,953
3
false
0
0
Simply changing the name of the python.exe to anything (ex:pytoioion.exe) in your C:/Python34 or C:/Python27 will switch between the two versions. To verify, run this on your command prompt C:Users/(your_name)>python
2
4
0
I have both Python 2.7 and 3.4 installed on my Windows Machine. When I type Python in CMD it defaults to Python2.7. How do I switch to 3.4?
Changing between Python 2.x and 3.x in windows CMD?
0.132549
0
0
6,850
27,577,032
2014-12-20T04:49:00.000
3
0
0
0
python,html
27,577,078
1
true
0
0
Yes. Cloudflare can block bots from downloading files. Blocking is usually done by detecting the user-agent or including javascript in a webpage. I would examine the pdf file in notepad and see what it contains also try adding a user-agent option in your python code.
1
1
0
I am writing a program in python that will automatically download pdf files from a website once a day. When trying to test I noticed that the files downloaded had the correct extension but they are very small (<1kB) compared to the normal size of about 100kB when downloaded manually. Can a website block a program from automatically downloading files? Is there anything that can be done about this?
Can a website stop a program from downloading files automatically?
1.2
0
1
76
27,577,522
2014-12-20T06:03:00.000
-3
0
1
0
python,list
27,577,549
2
false
0
0
Couldn't you do max([m(p) for p in pairs])
1
0
0
Suppose I have a list of tuples: pairs = [(4,5),(2,6),(6,9),(8,7),(1,1)]. And I have a function def m(pair): return pair[0]**2 + pair[1]**2. I seek to find the element of pairs for which m returns the greatest output. Specifically, I want to do this as pythonically as possible. It is clear to me that I could do this with a loop through pairs and a variable to store the maximum-yielding pair seen, but that feels inelegant. I feel as if this should be done with a list comprehension. It is also clear that I could find the pair I want by declaring temp = [m(p) for p in pairs] and then selecting pairs[temp.index(max(temp))], but I'd prefer not to create another list as long as the list of pairs -- again, this feels inelegant. Looking for pythonic suggestions.
Most Pythonic Way to Select Particular Tuple from List of Tuples
-0.291313
0
0
66
27,577,584
2014-12-20T06:13:00.000
0
0
0
0
python,selenium
27,580,663
2
false
0
0
chromedriver needs to be installed on the machine that will launch the instance of the Chrome browser. If the machine that launches the Chrome instance is the same machine as where the Python script resides, then the answer to your question is "yes". If the machine that launches the Chrome instance is a machine different from the machine that runs your Python script, then the answer to your question is "no".
1
0
0
I have tried searching the official documentation, but no result. Does Chrome Web Driver needs to be in client's system for a python script using Selenium to run? I basically want to distribute compiled or executable file versions of the application to the end user. How do i include Chrome Web driver with that package?
Does Chrome Web Drivers needs to be in Client's System while using Selenium
0
0
1
179
27,584,321
2014-12-20T21:05:00.000
2
0
0
0
python,amazon-dynamodb,boto,sample
27,599,549
2
true
0
0
Use Table.scan(max_page_size=1000)
1
2
0
I am using amazon dynamodb and accessing it via the python boto query interface. I have a very simple requirement I want to get 1000 entries. But I don't know the primary keys beforehand. I just want to get 1000 entries. How can I do this? ...I know how to use the query_2 but that requires knowing primary keys beforehand. And maybe afterwards I want to get another different 1000 and go on like that. You can consider it as sampling without replacement.How can I do this? Any help is much appreciated.
python dynamodb get 1000 entries
1.2
0
1
1,903
27,584,508
2014-12-20T21:29:00.000
0
0
0
0
python,django,mysql-python,selinux
27,734,160
4
false
1
0
Couple of permission issues that I notice: Make sure your credentials for mySQLdb have access to the database. If you are using IP and Port to connect to the database, try using localhost. Make sure the user (chmod permissions) have access to the folder where mySQL stores stuff. Sometimes when storing media and things it need permission to the actual folder. Lastly, I would try to reset Apache server (not the entire machine).
1
8
0
I'm using the mySQLdb module within my django application which is linked to Apache via WSGI. However I'm getting permission issues (shown below). This is down to SElinux and if I set it to passive everything is ok. ImproperlyConfigured: Error loading MySQLdb module: /opt/django/virtenv/django15/lib/python2.7/site-packages/_mysql.so: failed to map segment from shared object: Permission denied What is the best way to update SELinux to include this without having to turn off the whole the thing. The error is shown below: ImproperlyConfigured: Error loading MySQLdb module: /opt/django/virtenv/django1/lib/python2.7/site-packages/_mysql.so: cfailed to map segment from shared object: Permission denied
Python MySQLdb with SELinux
0
1
0
1,090
27,586,108
2014-12-21T02:02:00.000
0
0
0
0
python-3.x,tkinter,exe,py2exe
29,677,578
1
false
0
1
As far as I understand there is not a version of py2exe for python3.x You'd be best of going for cx_freeze (Sentdex also has a tutorial on that on that)
1
0
0
I have made a small program in Python that involves tkinter, and I made it a pyw file because it has a shortcut on the desktop and I do not want the command prompt to get in the way. I used py2exe following the sentdex tutorial on youtube, and I got an output file, but the output file shows an error and exits before I can read it. The pyw file on its own works fine, but I don't know how to get the exe output file to work correctly. Information: Python - 3.4.2; OS - Windows 8.1; Folder - Multiple items (photos and audio for the program); Program - A simple animation in tkinter If you need the program, tell me and I can upload the folder containing the program.
Python py2exe with tkinter (pyw file)
0
0
0
216
27,587,347
2014-12-21T06:52:00.000
0
0
1
0
python
35,722,925
1
false
0
0
Your description is too generic, but I'll answer as to what is the most likely issue: your environment. Fundamentally, eclipse does NOT use the pythonpath set in your environment. It has its own internal configuration (python interpreter, pythonpath, etc...). So make sure your environment variables match your eclipse configuration. That is likely to solve your problem.
1
0
0
I made a small game of pong in python and the idle I used was eclipse and all of it works (for the most part). But when I try to run the game through the python launcher rather than eclipse it crashes immediately. In fact any program that I make in eclipse won't run outside of it. I'm basically trying to figure out how I will be able to put my game on other peoples computers. What is the problem?
running python modules in python launcher
0
0
0
60
27,592,456
2014-12-21T18:32:00.000
119
0
1
0
python,pandas,series,floor,ceil
27,592,508
5
true
0
0
You can use NumPy's built in methods to do this: np.ceil(series) or np.floor(series). Both return a Series object (not an array) so the index information is preserved.
1
92
1
I have a pandas series series. If I want to get the element-wise floor or ceiling, is there a built in method or do I have to write the function and use apply? I ask because the data is big so I appreciate efficiency. Also this question has not been asked with respect to the Pandas package.
Floor or ceiling of a pandas series in python?
1.2
0
0
103,550
27,594,703
2014-12-21T23:04:00.000
1
0
0
0
python,django,sqlite
27,594,818
1
true
1
0
The user accessing the database (www-data?) needs to have write privileges to the folder the data resides in as well as the file itself. I would probably change the group ownership (chgrp) of the folder to www-data and add a group sticky bit to the folder as well (chmod g+s dbfolder). The last one makes sure that any new files created belongs to the group owner. If you're on bluehost you should also have access to MySql (which is a much better choice for web-facing db).
1
2
0
I am trying to get writing privileges to my sqlite3.db file in my django project hosted on bluehost, but I cannot get any other chmod command to work besides the dangerous/risky chmod 777. When I chmod 777 the db file and the directory, everything works perfectly. However, in order to be more prudent, I’ve tried chmodding 775 the directory of the sqlite file and chmod 664 the actual db file itself. No luck. I still get OperationalError: Attempt to Write to a Read Only Database whenever I access a feature that requires writing to the db. I appreciate any assistance.
Django on CentOS/Bluehost: Attempt to Write a Readonly Database, which Chmod besides 777 to use?
1.2
1
0
310
27,596,890
2014-12-22T05:11:00.000
0
0
0
0
python,excel,charts
27,599,618
1
true
0
0
It seems that all the python module could only create excels but not activate existing charts. Try xlrd and xlwt. Good luck.
1
0
0
I use python 2.7.3 and Windows7. I want to decorate the Excel chart by using Python. It's not necessary to make charts from start to end. First step(EXCEL STEP), I store data in the Excel sheet and make line chart roughly. (by selecting data range and using hot-key 'ALT+N+N+enter') Next step(PYTHON STEP), I want to modify chart made in first step. Specifically border line color and width, chart size, label fonts, fonts size and so on. How can I select or activate existing Excel chart by Python?(Not create chart from Python)
Selecting or activating existing Excel chart
1.2
1
0
191
27,597,017
2014-12-22T05:29:00.000
2
0
1
0
python-3.4,spyder,splinter
27,599,980
1
true
0
0
Okay. So, I could make it work with a work-around. Inspite of adding C:\Python34 & its Lib (site-packages) folder to PATH environment variable and Spyder's Python Path Manager, it failed to recognize splinter package while running the code in Spyder. So, I copied & pasted Splinter (followed by Selenium) package-folders from C:\Python34\Lib\site-packages (location where PIP installed the packages) to C:\Users\ramprasad.g\AppData\Local\Continuum\Anaconda3\Lib\site-packages (Anaconda's package location which alone Spyder seems to recognize) and boom! It started working!
1
1
0
Though splinter is installed on my Windows Vista, spyder gives an error when I import it. When I import in windows command prompt, it successfully imports & also shows path to the init file. Have added explicit path in PYTHONPATH Manager of Spyder and Updated module list. Yet, did not help. Have checked my PATH environment variable. It contains the path to Python, Python/Scripts & Python/Lib/site-packages. PATH contains no spaces and PATH is indeed named as PATH & not as Path (probably thats why able to import successfully via command prompt) When I try to install splinter again (just to confirm if it exists or not), pip says it already exists. When I try to upgrade, pip says it is already up-to-date Have read lots & lots of articles on stackoverflow & across the web, but no solution helped. Spyder recognizes other packages like os, numpy, etc. Had run this code successfully on a temporary testing machine. Now trying to run on my system and its failing with error ImportError: No module named 'splinter' Python ver. 3.4; Spyder ver. 3.4 Hoping for a solution... Complete trackeback: runfile('E:/Rampy/DS/Python/Code/AGMARK.py', wdir='E:/Rampy/DS/Python/Code') Traceback (most recent call last): File "", line 1, in runfile('E:/Rampy/DS/Python/Code/AGMARK.py', wdir='E:/Rampy/DS/Python/Code') File "C:\Users\ramprasad.g\AppData\Local\Continuum\Anaconda3\lib\site->packages\spyderlib\widgets\externalshell\sitecustomize.py", line 580, in runfile execfile(filename, namespace) File "C:\Users\ramprasad.g\AppData\Local\Continuum\Anaconda3\lib\site->packages\spyderlib\widgets\externalshell\sitecustomize.py", line 48, in execfile exec(compile(open(filename, 'rb').read(), filename, 'exec'), namespace) File "E:/Rampy/DS/Python/Code/AGMARK.py", line 8, in from splinter import Browser ImportError: No module named 'splinter'
Spyder not recognizing splinter
1.2
0
0
1,149
27,600,761
2014-12-22T10:24:00.000
1
0
0
0
python,scrapy
27,602,635
1
true
1
0
If the request has the dont_filter attribute set, the offsite middleware will allow the request even if its domain is not listed in allowed domains.
1
1
0
So I've been wondering regarding a spider, if maybe some of my requests might be getting filtered because they are to the url endpoint but with different body arguments (form data). Does the dont_filter=True make sense with FormRequest object?
scrapy: does it make sense to disable filtering on a formrequest?
1.2
0
1
134
27,603,128
2014-12-22T12:52:00.000
2
1
0
0
python,design-patterns,sequence,bioinformatics
27,603,419
3
false
0
0
I would do this in two steps. First, translate the nucleotide sequence into the amino acid sequence, using a mapping of codon to amino acid (CAT maps to H, CAC maps to H, CGT maps to R, CGC maps to R, etc.). Second, use the Boyer-Moore algorithm to search for specific amino acid sequences, or regular expressions if you need "wildcards" or groups of options.
2
0
0
I am trying to generate a nucleotide motif that will code chosen amino acids. For example - histidine is coded by CAT, CAC. Arginine is CGT, CGC, CGA, CGG,AGA and AGG. The pattern is: position in codon - C or A position in codon - A or G position - A, T, C or G by that rule you can define chosen amino acids (H and R) but also the amino acids that i dont want (for example AAA is lysine, AAT is asparagine...). So I need to define the pattern that matches only my chosen AAs, in case above it can be: [C][A or G][T], that pattern defines only histidine and arginine, but not the other amino acids. I am trying to work out an algorithm which will do this thing with any amino acids which i choose (more than two) and if the pattern does not exist it should find the possibilities for less amino acids (for example if pattern for 5 amino acids does not exist, it will find the patterns for four amino acids from the query) - this final optimization problem is probably the hardest part. Any suggestions? Thanks a lot and sorry for my poor english.
Bioinformatics - common motif for amino acids
0.132549
0
0
235
27,603,128
2014-12-22T12:52:00.000
0
1
0
0
python,design-patterns,sequence,bioinformatics
27,894,330
3
true
0
0
The problem was solved: 1) I made a library of all codons from the aminoacids of choise (ex. Met and Trp are AUG and UGG - so library of all combinations consists of [A/U][U/G][G] - AUG,AGG,UUG,UGG 2) Created two lists - first of "good" aminoacids - AUG, UGG and second of "bad" - AGG, UUG 3) Calculated the amount of "good" aminoacids left, if I remove a specific nucleotide (say if I remove U in second position I lose my AUG for methionine - so for U in second position the number is 1) for each nucleotide in each position 4) Next "bad" codons were analyzed for occurence of each nucleotide in each position (for codons AGG and UUG I have 2x G in third, 1x G in second, 1x U in first etc.) 5) After these steps I simply took the highest number from the step 4), looked to the list in step 3) and if the G in third position can be harmlessly removed without any losses in good aminoacids (not possible in our example, but can be done in larger codon sets) - I remove all codons with G in third position, edit the list of "good" and "bad" codons, and proceed again to step 3)
2
0
0
I am trying to generate a nucleotide motif that will code chosen amino acids. For example - histidine is coded by CAT, CAC. Arginine is CGT, CGC, CGA, CGG,AGA and AGG. The pattern is: position in codon - C or A position in codon - A or G position - A, T, C or G by that rule you can define chosen amino acids (H and R) but also the amino acids that i dont want (for example AAA is lysine, AAT is asparagine...). So I need to define the pattern that matches only my chosen AAs, in case above it can be: [C][A or G][T], that pattern defines only histidine and arginine, but not the other amino acids. I am trying to work out an algorithm which will do this thing with any amino acids which i choose (more than two) and if the pattern does not exist it should find the possibilities for less amino acids (for example if pattern for 5 amino acids does not exist, it will find the patterns for four amino acids from the query) - this final optimization problem is probably the hardest part. Any suggestions? Thanks a lot and sorry for my poor english.
Bioinformatics - common motif for amino acids
1.2
0
0
235
27,604,441
2014-12-22T14:16:00.000
0
0
1
0
python
27,604,701
3
false
0
0
%f stands for Fixed Point and will force the number to show relative to the number 1 (1e-3 is shown as 0.001). %e stands for Exponential Notation and will give you what you want (1e-3 is shown as 1e-3).
2
0
1
I have some values that I need to print in scientific notation (values of the order of 10^-8, -9) But I would like to don't print a long number, only two digits after the . something as: 9.84e-08 and not 9.84389879870496809597e-08 How can I do it? I tried to use "%.2f" % a where 'a' is the number containing the value but these numbers appear as 0.00
how to print finite number of digits USING the scientific notation
0
0
0
93
27,604,441
2014-12-22T14:16:00.000
2
0
1
0
python
27,604,491
3
true
0
0
try with this : print "%.2e"%9.84389879870496809597e-08 #'9.84e-08'
2
0
1
I have some values that I need to print in scientific notation (values of the order of 10^-8, -9) But I would like to don't print a long number, only two digits after the . something as: 9.84e-08 and not 9.84389879870496809597e-08 How can I do it? I tried to use "%.2f" % a where 'a' is the number containing the value but these numbers appear as 0.00
how to print finite number of digits USING the scientific notation
1.2
0
0
93
27,608,053
2014-12-22T18:02:00.000
1
0
0
0
python,opencv,image-processing
27,689,079
1
true
0
0
There is a standard Python functionimghdr.what. It rulez! ^__^
1
1
1
I read an image (of unknown format, most frequent are PNGs or JPGs) from a buffer. I can decode it with cv2.imdecode, I can even check if it is valid (imdecode returns non-None). But how can I reveal the image type (PNG, JPG, something else) of the buffer I've just read?
OpenCV: how to get image format if reading from buffer?
1.2
0
0
2,355
27,608,372
2014-12-22T18:27:00.000
6
0
0
0
python,flask
27,608,409
2
true
1
0
Anything that is static, app-wide, doesn't change much, and has important information for all users, should use config. (e.g. secret keys, options to modify the app from project to project, emails, generic messages) Session should only be used to store relevant user data as the data is modified through each page. (e.g. user login data, user preferences, user inputs from previous pages) If you have to save something from Page 1 to Page 5 in your website for that particular user, then use session. Sessions should mainly be used based on the individual user.
2
1
0
Is there a rule for when to use Flask.config vs. flask.session to store variables?
When should I use the Flask.config vs. use flask.session?
1.2
0
0
170
27,608,372
2014-12-22T18:27:00.000
4
0
0
0
python,flask
27,608,411
2
false
1
0
Yes, most definitely. The config is for global, project-level variables: the location of files, keys for any APIs you might be using, your database access settings, things like that. The session is for variables related to the current user's session on the site: their previous choices on a multi-page form, preferences, login details, etc. You definitely don't want to get these mixed up.
2
1
0
Is there a rule for when to use Flask.config vs. flask.session to store variables?
When should I use the Flask.config vs. use flask.session?
0.379949
0
0
170
27,614,494
2014-12-23T05:21:00.000
0
0
0
0
python,django,django-migrations
27,615,457
2
false
1
0
I have done the migration from 1.6 to 1.7 on an existing project. It was fairly painless. I renamed my old South migrations folders and let the django 1.7 migrations create a new one. (i.e. $mv appname/migrations appname/migrations.south) That will make it easier to go back to South for any reason and will keep from having a jumbled mess of both in your migrations folders.
1
0
0
I have a Django application initially created for version 1.6 and I've just finished the upgrade for the last version. All the models has managed = False and prior none of them was managed by south and now I want to start using Django migrations for 1.7 version. Which would be the best and seamless way to do it? I'm afraid that just changing managed = True in all models and run manage.py makemigrations will make a mess in both migrations files and database. Thanks EDIT As was suggested I ran manage.py makemigrations. It created the script 0001_initial with some model definitions but not for all the objects in models package. It creates 11 tables but I have 19 tables. All models has managed = True and I don't have any database router.
Best way to add Django migrations to a django project
0
0
0
635
27,615,219
2014-12-23T06:33:00.000
0
0
0
0
wxpython,customdialog
27,622,152
1
true
0
1
Just create self.C in your custom dialog's __init__ method. Then bind your OK button to a handler and update it as you mentioned. Then you should be able to get its value just as you stated: value = dlg.C.GetValue(). One thing to keep in mind is that when you create the OK button, do not set its id to wx.OK. If you do, it may not call your custom event handler as wx.OK is a special id that has a special default handler.
1
1
0
I have create some custom dialogs in wxpython that I am very happy with. I can execute pretty much anything I want based on user interaction and then once "OK" is selected collect the information from whatever functions I have run. What I am wondering is there a way to execute a final function at the time "OK" is selected. I do not have any sample code because I am not sure where to start and the demo does not do this, if it did my question would be answered by that. So lets say that in the dialog I have calculated A and B and when "OK" is selected I want to execute C = str(A) + "whatever" + str(B) So that upon exit I can dlg.C.GetValue() =
WXPYTHON CUSTOM DIALOG
1.2
0
0
237
27,615,239
2014-12-23T06:34:00.000
3
0
1
0
python,interpreter
27,615,291
3
false
0
0
The .py extension is a convention. You can, in fact, invoke the interpreter on any file. In some cases, however, keeping with the convention is important. For example, if you write a module (something that you import) then the interpreter won't "guess" that your python source code is hiding in a .txt file. It will search only files that adhere to the conventional naming.
3
1
0
I found this fact Interesting , The interpreter seems to be working fine with python ex1.txt , though It should have been ex1.py . What may be the reason for this ? Is there any documentation on this type of behaviour . The ex1.py or ex1.txt are the having the same print "hello", will this change if I have any code change . What may be some conditions in which that python ex1.txt would not work.I have googled it and found nothing good .
What's the difference between .py and .txt for an Interpreter in python?
0.197375
0
0
2,252
27,615,239
2014-12-23T06:34:00.000
9
0
1
0
python,interpreter
27,615,288
3
true
0
0
There should be no difference once the Python has been launched; that is, the interpreter itself does not handle Python source-code differently depending on the source file's extension. However, the .py extension has special meaning for the import statement, which looks for modules. A module is (generally) either a text file with a .py extension (though it may be precompiled as .pyc) or a directory containing a file named __init__.py. (The imp module provides a workaround for importing files without the .py extension. Also, in Python 3, the __init__.py file technically isn't necessary.) Additionally, in Windows (though not in Linux!) a file's extension determines what program is used to launch the file; when Python is first installed, you are (for, I believe, most versions of the Python installer) prompted to choose whether or not to associate the .py extension with Python files. This means that when you double-click on a .py file, it will be launched using Python (equivalent to Python <filename>.py at the command line). In Linux (and in fact in any *NIX-style environment, even Cygwin on Windows), file extensions do not have this special meaning whereby the operating system itself associates a particular action with a particular extension; thus, it's not uncommon on Linux to see scripts written in Python (or other scripting language) that have no file extension, thus making the look (and behave) more like a simple command. This idiom makes use of the "shebang" notation at the beginning of a file (#!/usr/bin/python or similar) to indicate that Python should be called to interpret the file. Thus, in a *NIX-style shell, to make a new command called foo written in Python, simply implement the command in the file foo, put #!/usr/bin/python at the beginning of the file, and put the file somewhere on your $PATH (such as in ~/bin).
3
1
0
I found this fact Interesting , The interpreter seems to be working fine with python ex1.txt , though It should have been ex1.py . What may be the reason for this ? Is there any documentation on this type of behaviour . The ex1.py or ex1.txt are the having the same print "hello", will this change if I have any code change . What may be some conditions in which that python ex1.txt would not work.I have googled it and found nothing good .
What's the difference between .py and .txt for an Interpreter in python?
1.2
0
0
2,252
27,615,239
2014-12-23T06:34:00.000
2
0
1
0
python,interpreter
27,615,307
3
false
0
0
Extensions are more like recommendations. There are generally two types of files - binary and ASCII. Binary files are pretty much just ones and zeroes, and are usually executable, but not editable. Binary files include something like a .docx file, because even though you can open it in Microsoft Word (which can decode the binary content), opening it in notepad would just result in garbage. ASCII files, (like .txt and .py files) are editable by something like notepad, and this is what gives us the ability to write code or text in them with many editors. The extension for these files, and any other file, has only one purpose - to tell your computer how to open it. That's why you can set applications to open .py and .txt files separately. However, at their core, these are both still ASCII files. As long as the python interpreter (or any compiler) can read that ASCII data, it can run it. The extension is just to indicate the type of contents to the user and the computer. The .py extension also helps Python indicate additional files for importing, which is why we usually need it for large programs.
3
1
0
I found this fact Interesting , The interpreter seems to be working fine with python ex1.txt , though It should have been ex1.py . What may be the reason for this ? Is there any documentation on this type of behaviour . The ex1.py or ex1.txt are the having the same print "hello", will this change if I have any code change . What may be some conditions in which that python ex1.txt would not work.I have googled it and found nothing good .
What's the difference between .py and .txt for an Interpreter in python?
0.132549
0
0
2,252
27,616,098
2014-12-23T07:44:00.000
0
0
0
0
python,web,pyramid
27,616,278
2
false
1
0
You need a table with current editor, record_id and timeout. The first editor asks per POST-request to edit a record and you put a new line in this table, with a reasonable timeout, say 5 min. The first editor gets an "ok" in return. For the second editor you find a match for the record_id in the table, look at the timeout, and if it's not timed out, (s)he gets an "error" in return to the post request. In an second POST-request, an editor send it's changes. You look in the table, if (s)he's the editor and send "changed" or "rejected" accordingly.
1
1
0
I'm developing intranet web app that is based on Pyramid with SQLAlchemy. It eventually may (will) happen that 2 users will edit the same record. How can I handle the requirement to notify the user who started editing later that particular record is being edited by the first user?
Notifying user's browser of change without websockets
0
1
0
55
27,616,903
2014-12-23T08:49:00.000
1
0
1
0
python,argparse,python-2.x,optparse
27,628,187
2
true
0
0
Based on discussions that I've seen on the Python bug issue site, optparse is not really deprecated. Don't expect further development, but it isn't going to disappear any time soon. All of argparse is contained in one file, argparse.py. So you could grab that from almost anywhere, and put it on your load path. A possible exception is a recent Python3 version that has a gratuitous (IMO) 'nested-with' statement. It's possible that there are other incompatibilities with Python 2.5, but it wouldn't be hard to test a 2.7 argparse.py in the 2.5 environment. There is also a unittesting Lib/test/test_argparse.py file. Though that is more likely to be incompatible, since it is using some newer unittest functionality.
1
0
0
I did a quick research into documentation and did not find any evidence that suggests argparse is supported before 2.6. We have development network as well as servers that use Python 2.5.1 to do a lot of things. I had an idea to upgrade it, but didn't realise that there is a change request process that needs to be gone through. I am wondering if I can have an alternative method to use something similar to argparse. I know optparse is the other option, but it is also deprecated in 2.7.x versions. Does anyone know anything else?
Availability of argparse in Python 2.x versions
1.2
0
0
607
27,626,783
2014-12-23T19:28:00.000
0
0
0
0
python,selenium
70,415,232
2
false
0
0
Try relocating elements each time it goes back to previous page. That will surely work but it is time consuming.
1
44
0
I have created a little screen scraper and everything seems to be working great, the information is being pulled and saved in a db. The only problem I am having is sometimes Python doesn't use the driver.back() so it then trys to get the information on the wrong page and crashes. I have tried adding a time.sleep(5) but sometimes it still isn't working. I am trying to optimise it to take as little time as possible. So making it sleep for 30 seconds doesn't seem to be a good solution.
Python selenium browser driver.back()
0
0
1
58,493
27,627,619
2014-12-23T20:34:00.000
0
0
0
0
python,browser,size
27,627,672
1
false
1
0
I am not sure about what you are trying to do, but I have pretty good reasons to believe that this is something you want to handle in your css/js side of the application. I am not familiar with app-engine, but the browser does not send it's viewport size with requests (unless you put it yourself in request data). So if you are using ajax request - put the data about viewport in the data send to backend. If not - use css or js to handle your frontend.
1
0
0
I am using WebApp2 with python (and app-engine). Is there a way to tell the screen size of the browser in python? I am trying to figure if the browser size is less than 768.
how to tell browser screen size in python
0
0
0
209
27,628,174
2014-12-23T21:22:00.000
2
0
0
0
python,heroku,host,crossbar
27,666,089
1
true
1
0
For the host use 0.0.0.0. For the port number it's slightly more complicated... When it creates a web dynamo Heroku sets a PORT environment variable with the dynamo's port. To set this in crossbar you need to create a script that reads that variable and writes it into your config wherever the port is requested. Then you make sure that the script returns 0 on exit and put the following in your Procfile: web: ./your_config_helper_script && crossbar start That runs your script first (which should get your config file ready) before running crossbar
1
3
0
I'm trying to get a Crossbar.io app running on Heroku. Crossbar.io requires you to put the app's host in a config file that's used to launch the app. I've tried the following: my-app-name.herokuapp.com: No dice. I imagine Heroku does some fancy redirection internally that prevents this from working. $HOSTNAME: running a script that outputs the HOSTNAME and using the result in the config file doesn't work either. The HOSTNAME is a GUID that contains no useful information. IP: I tried getting the external IP of the app, but no luck. The IP changes each time I start the app. Is there an established way to do this on Heroku? Also the config requires a port and Heroku seems to assign these dynamically. Any way to access the port as well (ideally before the app runs)
Get host and port for Heroku app
1.2
0
0
1,682
27,628,753
2014-12-23T22:10:00.000
1
0
0
0
python,network-programming,client-server,port,server
27,628,809
3
false
0
0
In order to do that the server must listen on a certain port(s). This means the client(s) will need to interact on these ports with it. So... no it is impossible to do that on some random unknown port.
3
1
0
I'm trying to build a simple python server that a client can connect to without the client having to know the exact portnumber. Is that even possible? The thought is to choose a random portnumber and using it for clients to connect. I know you could use bind(host, 0) to get a random port number and socket.getsockname()[1] within the server to get my portnumber. But how could my client get the portnumber? I have tried socket.getnameinfo() but I don't think I understand how that method really works.
How to give a python client a port number from a python server
0.066568
0
1
689
27,628,753
2014-12-23T22:10:00.000
0
0
0
0
python,network-programming,client-server,port,server
27,630,673
3
false
0
0
Take a look at Zeroconf, it seems to be the path to where you are trying to get to.
3
1
0
I'm trying to build a simple python server that a client can connect to without the client having to know the exact portnumber. Is that even possible? The thought is to choose a random portnumber and using it for clients to connect. I know you could use bind(host, 0) to get a random port number and socket.getsockname()[1] within the server to get my portnumber. But how could my client get the portnumber? I have tried socket.getnameinfo() but I don't think I understand how that method really works.
How to give a python client a port number from a python server
0
0
1
689
27,628,753
2014-12-23T22:10:00.000
0
0
0
0
python,network-programming,client-server,port,server
27,628,855
3
false
0
0
You need to advertise the port number somehow. Although DNS doesn't do that (well, you could probably cook up some resource record on the server object, but that's not really done) there are many network services that do. LDAP like active directory (you need write rights), DNS-SD dns service discovery, universal plug and play, service location protocol, all come to mind. You could even record the port number on some web page somewhere and have the client read it.
3
1
0
I'm trying to build a simple python server that a client can connect to without the client having to know the exact portnumber. Is that even possible? The thought is to choose a random portnumber and using it for clients to connect. I know you could use bind(host, 0) to get a random port number and socket.getsockname()[1] within the server to get my portnumber. But how could my client get the portnumber? I have tried socket.getnameinfo() but I don't think I understand how that method really works.
How to give a python client a port number from a python server
0
0
1
689
27,629,227
2014-12-23T22:57:00.000
-1
0
0
0
python,scipy,least-squares,intel-mkl
45,621,086
1
false
0
0
You could try Intel's python distribution. It includes a pre-built scipy optimized with MKL.
1
6
1
I'm doing a Monte Carlo simulation in Python in which I obtain a set of intensities at certain 2D coordinates and then fit a 2D Gaussian to them. I'm using the scipy.optimize.leastsq function and it all seems to work well except for the following error: Intel MKL ERROR: Parameter 6 was incorrect on entry to DGELSD. The problem occurs multiple times in a simulation. I have looked around and understand it is something to do with a bug in Intel's MKL library. I can't seem to find a solution to the problem and so I was looking at an alternative fitting function In could use. If someone does know how to get rid of the problem that would be good also.
Intel MKL Error with Gaussian Fitting in Python?
-0.197375
0
0
860
27,629,281
2014-12-23T23:03:00.000
0
0
1
0
python,python-idle
27,642,836
2
false
0
0
No, not now. Since you are at least the second person to ask this, I added the idea to my personal list of possible enhancements. However, while running a selection would not be a problem, producing accurate tracebacks for exception would be. Doing so is an essential part of Python's operation. Currently, one can disable code that you need to not run by commenting it out (Alt-F3) or by making it a string. One can stop execution after a particular statement by adding 1/0. Or you can copy code to a new editor window. Do you have a specific use case in mind, or are you just wondering?
1
0
0
I am new to python programming... Just wanted to know does IDLE has a concept of 'executing selected statements'?? F5 runs the whole program... Is there any way to do this?
Python: Executing selected statements
0
0
0
211
27,632,485
2014-12-24T06:25:00.000
1
1
1
0
python,c++,ide,cloud,saas
27,633,513
1
true
0
0
Based on Wikipedia: Software as a service (SaaS) is a software licensing and delivery model in which software is licensed on a subscription basis and is centrally hosted There are many implementations of SaaS. Such as ERP, CRM, CMS, etc. Find out by your self what kind of service will you offer to your customers. Then choose the right SaaS implementation.
1
0
0
I want to make simple online IDE with cloud storage feature, let us say this should be implement in C++,Python ,etc... Does it SaaS (I mean the IDE :-) ) ? I'm new in SaaS and Cloud world , where to start to make something like what I said above ? Thanks.
Integrated Development Environment with SaaS
1.2
0
0
140
27,633,641
2014-12-24T08:09:00.000
1
0
0
0
javascript,python,amazon-s3
27,647,682
1
true
1
0
I'd suggest spinning up one or more EC2 instances and running your thumbnail job there. You'll eliminate almost all lot of the bandwidth costs (free from ec2 instances in the right region to s3), and certainly the transfer speed will be faster within the AWS network. For 600K files to process, you may want to consider loading each of those 'jobs' into an SQS queue, and then have multiple EC2 instances polling the queue for 'work to do' - this will allow you to spin up as many ec2 instances as you want to run in parallel and distribute the work. However, the work to setup the queue may or may not be worth it depending on how often you need to do this, and how quickly it needs to finish - i.e. if this is a one time thing, and you can wait a week for it to finish, a single instance plugging away may suffice.
1
0
0
I have about 600k images url (in a list) and I would like to achieve the following : Download all of them generate a thumbnail of specific dimensions upload them to Amazon s3 I have estimated my images average to about 1mb which would be about 600gb of data transfer for downloads. I don't believe my laptop and my Internet connection can take it. Which way should I go? I'd like preferably to have a solution that minimizes the cost. I was thinking of a Python script or a JavaScript job, run in parrallel if possible to minimize the time needed Thanks!
Bulk download of web images
1.2
0
1
83
27,635,631
2014-12-24T10:46:00.000
1
0
1
0
python,pip
28,909,169
2
false
0
0
I don't know how long the following solution has been around for, but I found you can simply run pip install my_compressed_package.tar.gz and pip will know what to do. All done locally, no network access needed.
1
1
0
I am unable to install multiple packages listed in a file using single command line, I know that we can install multiple packages listed in a file using -r switch and we can use local sources to install using --no-index --find-links switches, but I am not sure if we can combine these two, I tried but its not working, so pls suggest, below is my exact requirement. I have two packages pkg1-1.1.tar.gz and pkg2-2.2.tar.gz in directory /home/rafiq/newpkgs Need to install them using pip command and the package names are listed in pkglist.txt. phglist.txt contents: pkg1==1.1 pkg2==2.2 please help me with pip command to install list of packages listed in pkglist.txt with sources present in newpkgs directory.
pip install multiple packages listed in file with sources from local directory
0.099668
0
0
4,130
27,637,281
2014-12-24T12:53:00.000
27
0
0
0
python,r,pandas
27,637,837
8
true
0
0
summary() ~ describe() head() ~ head() I'm not sure about the str() equivalent.
1
69
1
I'm only aware of the describe() function. Are there any other functions similar to str(), summary(), and head()?
What are Python pandas equivalents for R functions like str(), summary(), and head()?
1.2
0
0
53,740
27,641,616
2014-12-24T19:51:00.000
1
1
0
0
python,database,numpy,dataset,storage
27,641,772
1
true
0
0
Reading 500 files in python should not take much time, as the overall file size is around few MB. Your data-structure is plain and simple in your file chunks, it ll not even take much time to parse I guess. Is the actual slowness is bcoz of opening and closing file, then there may be OS related issue (it may have very poor I/O.) Did you timed it like how much time it is taking to read all the files.? You can also try using small database structures like sqllite. Where you can store your file data and access the required data in a fly.
1
0
1
I've accumulated a set of 500 or so files, each of which has an array and header that stores metadata. Something like: 2,.25,.9,26 #<-- header, which is actually cryptic metadata 1.7331,0 1.7163,0 1.7042,0 1.6951,0 1.6881,0 1.6825,0 1.678,0 1.6743,0 1.6713,0 I'd like to read these arrays into memory selectively. We've built a GUI that lets users select one or multiple files from disk, then each are read in to the program. If users want to read in all 500 files, the program is slow opening and closing each file. Therefore, my question is: will it speed up my program to store all of these in a single structure? Something like hdf5? Ideally, this would have faster access than the individual files. What is the best way to go about this? I haven't ever dealt with these types of considerations. What's the best way to speed up this bottleneck in Python? The total data is only a few MegaBytes, I'd even be amenable to storing it in the program somewhere, not just on disk (but don't know how to do this)
Better way to store a set of files with arrays?
1.2
0
0
66
27,642,293
2014-12-24T21:26:00.000
0
0
0
0
android,qpython3
27,642,399
1
false
0
1
Try to run it in console because you can communicate with the interpreter directly
1
0
0
Im using Qpython3 on Android 4.2.2. Im currently able to list the latest sms from a particular contact and extract a 10 digit phone number. I want to update a contact's phone number with this number. How should I do this ? To be more precise, I want to be able to: Access the contact list. Update contact phone number with this phone number Is this possible with Qpython3 ?
How do I add a phone number to a contact using Qpython3
0
0
0
90
27,645,172
2014-12-25T07:32:00.000
0
1
0
0
python,nginx,uwsgi
27,646,090
1
false
1
0
The limit here is nginx. It cannot avoid (unless when in websockets mode) buffering the input. You may have more luck with apache or the uWSGI http router (albeit i suppose they are not a viable choice)
1
0
0
I have an api with publishers + subscribers and I want to stop a publisher from uploading a lot of data if there are no subscribers. In an effort to avoid another RTT I want to parse the HTTP header, see if there are any subscribers and if not return an HTTP error before the publisher finishes sending all of the data. Is this possible? If so, how do I achieve it. I do not have post-buffering enabled in uwsgi and the data is being uploaded with a transfer encoding of chunked. Therefore, since uWSGi is giving me a content-length header, it must have buffered the whole thing somewhere previously. How do I get it to stop? P.S. uWSGi is being sent the data via nginx. Is there some configuration that I need to set there too perhaps?
Can uWSGI return a response before the POST data is uploaded?
0
0
1
244
27,647,676
2014-12-25T13:34:00.000
2
0
1
0
python-3.x,python-asyncio
27,649,541
2
false
0
0
Well, it uses reactor for posix. Windows implementation has proactor event loop too.
2
3
0
asyncio is an event driven core lib of python 3.4. I know twisted, a similar lib for asyncio, implements the Reactor pattern, but what kind of pattern does asyncio implement?
What pattern of event driven procession does asyncio implement?
0.197375
0
0
582
27,647,676
2014-12-25T13:34:00.000
0
0
1
0
python-3.x,python-asyncio
66,377,064
2
false
0
0
As @AndrewSvetlov answered, Python already will select the most performant selector for you, depending on your operating system. Different selector event loops will be, ensuring to get the tightest loop, the most performant selector available on your operating system. So it implements both patterns.
2
3
0
asyncio is an event driven core lib of python 3.4. I know twisted, a similar lib for asyncio, implements the Reactor pattern, but what kind of pattern does asyncio implement?
What pattern of event driven procession does asyncio implement?
0
0
0
582
27,648,619
2014-12-25T15:41:00.000
1
0
1
0
python,multithreading
27,648,660
2
false
0
0
Threads won't help you due to the GIL serializing them. However, you can still use multiprocessing and share the data between processes using the mmap module or equivalent. This will require the data to be structured to be readable from the file, so you won't be able to use, say, dictionaries - but using a file-based storage such as sqlite will be fine.
1
1
0
Is it possible to deal in python with shared memory parallel tasks? My task should be parallel over several cores (though threading module does not fit here, as far as I know the only facilities to do that is multiprocessing). There are lots of tasks for which I create a thread (in a python case process) pool. Then I need to initialize this threads (processes) with a lot of data from the main thread (process). Threads process this data and return new ones (again a lot of) to the main thread (process). What I see a huge overhead is that each task must copy the data to the new process in case of processes and do that same after finishing. But in case of threads this is eliminated. And it should be a huge speed up. Can I achieve this speed up with python?
Memory sharing multithreading programming in Python
0.099668
0
0
2,821
27,651,530
2014-12-25T23:26:00.000
1
0
0
0
python,http,python-requests
27,651,589
2
false
1
0
Basically you don't. If the web server is returning a 302 unless it decides to include the old html(which would be very odd ) you are basically out of luck. Now if you hit it with a web browser and it doesn't redirect you, then perhaps it is doing something like user agent sniffing and redirecting based on that. So in that case you would need your code to claim to be that ua.
1
0
0
I'm trying, in Python, using the requests library, to get the HTML for a website that automatically redirects to another one. How do I avoid this and get the HTML for the original site, if possible? I know it exists and has HTML for it because I have accessed it via the Chrome view-source function. Any help appreciated.
If a website gives a 302 HTTP response code, can I get the original link's raw HTML still?
0.099668
0
1
66
27,654,405
2014-12-26T07:54:00.000
1
0
0
0
python,django
27,654,493
1
false
1
0
so there are developers A and B. if it is very important you both have notification enabled in git so that you know what your friend has pushed. lets imagine, A and B are working at the same time on same django app, possibly on the same models.py. if A pushes changes on models.py, B needs to apply these changes in his local version before he pushes. if B pushes his changes, A needs to apply them first before he pushes. in this way, both local versions will have the same migration history. this is how I do with my friends.. any improvement to what i say is highly appreciated
1
4
0
We are 2 developers working on a django application. As we are in the initial stages of the app our models are changing rapidly and so are django migration files. So if one of us pushes the migrations to git and when the other one pulls them and tries to apply them, django is not able to find a common migration point as he also would have made some model changes. Please suggest a clean way to resolve this issue.
How to manage migrations in django 1.7 among developers?
0.197375
0
0
56
27,654,494
2014-12-26T08:06:00.000
5
0
0
0
python,python-3.x,tkinter,label
32,515,869
3
false
0
1
Use can use grid_remove() to hide the label. like self.myLabel.grid_remove(). If you want to show it again then use self.myLabel.grid(). This will show widget on its original position on grid.
1
4
0
How could I hide an existing Label when a button is clicked in Python(Tkinter)?
Hide label when a button is clicked in Python
0.321513
0
0
29,265
27,661,082
2014-12-26T19:25:00.000
2
1
0
1
python,ssh,paramiko,activestate,pypm
27,667,123
1
true
0
0
I feel really foolish. After reading that paramiko has replaced ssh module there still is an ssh module available. Ooops!!
1
0
0
I am new to python scripting and started to look into a script to allow me to SSH to a box and check it is still running. I have installed ActiveState (Python 2.7) on my windows desktop. Using PyPM I have installed paramiko and pycrypto but when I try to execute my scripts I get the following error: Script: python C:\Python27\Scripts\RunOnEnv\ssh-matic.py Error:ImportError:no Modules named ssh When passing: '>>>help('modules') I can not see ssh in the list. I have tried uninstalling and installing the modules with no problems. What else am I missing?
Installing modules with PyPM on ActiveState
1.2
0
0
320
27,664,809
2014-12-27T05:55:00.000
0
1
1
1
python,terminal,ide
27,664,945
1
true
0
0
As soon as you don't mess up with the system files, you might not do any damages. Be sure what files you might be disturbing. If your code is too, ummmm, core, try to give ideone.com a try. This might help you with the things you might b touching. Terminal might not give you enough interactions, but as you told that you are new to coding, terminal is important. Get along with it. Find error without syntax highlighting feature. It will definitely help in the future. But yes, this is applicable if you are going for it seriously, gradually.
1
0
0
I get slightly nervous posting in here because these are not my waters yet. Please bear with, I am very new to the world of code. I do my best to find answers to questions before I ask them; time is very valuable so I appreciate yours. When I run code under Python in Terminal do I run the risk of damaging my system if I run bad code? My guess is no but I'd rather ask than regret. To follow up that question is there an editor that includes a built in interpreter so that I can write code and see it interpreted in the same window? Or is the best practice to write in an editor and run it in Terminal? Since syntax highlighting isn't available in Terminal I'm assuming that writing in Terminal is less than efficient. Thank you for your help.
Where To Test Python Code
1.2
0
0
629
27,664,896
2014-12-27T06:12:00.000
0
1
0
1
python,c++,linux,openshift,openshift-client-tools
27,665,587
1
true
0
0
all the 'rhc port-forward appname' does is set up SSH tunnels behind the scenes. If you want people to tunnel into your appication you will need to get their public SSH key into your application as an approved key. Then you can set up an SSH tunnel whatever way you chose.
1
0
0
I'm trying to test and distribute my python application in script or executable form (client). I already have my openshift server setup and running. I'm confused on setting up port forwarding with other users to test it out with. Do other clients (publicly) need to download rhc and run 'rhc port-forward appname' on their own machine or are there alternatives out there which can be accomplished using python internally by code? This is kind of confusing and any help would be much appreciated. Thanks.
Public Client App Port Forwarding with OpenShift
1.2
0
0
211
27,665,320
2014-12-27T07:32:00.000
2
0
1
0
python,anaconda,conda
28,100,853
2
false
0
0
Python virtualenvs (or pyvenvs) are very Python specific. The create an environment that pretends to be a distinct installation of Python, while reusing some data from the base Python. Only Python packages can be installed into a virtualenv, because that's really the only thing that makes sense. Conda environments are not Python specific. Any kind of package can be a conda package (Python packages, C libraries, R packages, Python itself, ...), and any conda package can be installed into a conda environment. Each conda environment is essentially a completely separate installation of every file from every package (including all of Python itself). This is done efficiently using hard links.
1
2
0
Are conda's envs a wrapper around pyenv, a similar version or are they a distinct implementation? They seem identical, but I do not know for sure. Are they interchangeable?
Are environments in conda a wrapper for pyenv?
0.197375
0
0
589
27,666,895
2014-12-27T11:44:00.000
0
0
1
0
string,loops,python-3.x
27,669,014
3
false
0
0
Remember that position is the index, while S[position] is the character at that position.
1
0
0
How to read the index value of a specific character (say '+') from a string without using any function. They told me to do this using for loop. (Home work, I am not allowed to use homework tag due to low reputation) I was doing this: S = input() for position in range(0,len(S)): if S[position] == '+': print(S[position]) What I am getting as output is + sign itself instead of its index. Thankyou!
How to get the index value of a character from a string in Python?
0
0
0
106
27,667,517
2014-12-27T13:06:00.000
0
0
0
1
python,file,ntfs
27,667,551
2
false
0
0
This is a problem of the underlying file system. Use a file system that is better suited for large amount of files. Built a directory tree, sort the files into directories after the first, second, third ... character of the filename.
1
1
0
I have a folder with about 220,000 text files. I need to open them in a certain order, and do something with the content. At the moment, I just use open, and it takes, on average, about half a second to open a file. Is there any faster way to do it? If it matters - I'm on Windows.
How to open files from a very large folder quickly?
0
0
0
516
27,669,710
2014-12-27T17:31:00.000
0
0
1
0
python-2.7,data-structures
27,693,828
1
false
0
0
If you plan on sorting it, just use an array. Arrays just make it so much simpler when it comes to sorting. Choosing a data structure mainly lies in your goals for the application. Would you like quick indexing and look up times? Use an array. Is your input size unknown, and search times are not as important? Use a linked list. Are search times incredibly important? Use a hash table
1
0
0
I'm pretty new to python and just need some advice. I'm basically making a python reddit tool that will help me find the top comments, their score, and save them so they can be sorted by highest score at a later time. Initially I was going to save them to a dictionary with a 'score:comment' format but was told this was not ideal. Any suggestions for the best route to go in this situation?
Best data-structure to save a word to a corresponding number?
0
0
0
31
27,676,834
2014-12-28T13:27:00.000
1
0
1
0
python,json,django,multithreading,django-models
27,676,874
2
false
1
0
I don't know where you would have read that signals are executed in threads, because it is not at all true. Django does not do anything with threads, and neither should you: if you want to execute something out of process, use a task queue system like Celery.
1
5
0
I have post_save signal on one of my models which calls json.dumps on a large python dictionary. I want to call this json.dumps in a separate thread so it may not slow down the save call on my model. I was wondering if it is okay to spawn a new thread from inside a post_save signal? I have read that post_save signals are themselves thread so would it be okay to spawn another Python thread from it? EDIT: I cannot use a celery task for some reason.
Is it okay to spawn a thread from django post save signal?
0.099668
0
0
826
27,678,990
2014-12-28T17:47:00.000
0
0
0
0
python,cassandra,load-testing
27,688,141
1
false
0
0
For a few million, I'd say just use CSV (assuming rows aren't huge); and see if it works. If not, inserts it is :) For more heavy duty stuff, you might want to create sstables and use sstable loader.
1
0
1
I am generating load test data in a Python script for Cassandra. Is it better to insert directly into Cassandra from the script, or to write a CSV file and then load that via Cassandra? This is for a couple million rows.
Python/Cassandra: insert vs. CSV import
0
1
0
364
27,682,975
2014-12-29T03:17:00.000
3
0
0
0
python,web-scraping
27,683,149
1
true
0
0
The infinite scroll is probably using an Ajax query to retrieve more data as you scroll. Use your browser's dev tools to inspect the request structure and try to hit the same endpoint directly. In this way you can get the data you need, often in json or xml format. In chrome open the dev tools (Ctrl + shift + I in windows) and switch to the network tab. Then begin to scroll, when more content is loaded you should see new network activity. Specifically a Ajax request, you can filter by "xhr". Click on the new network item and you will get detailed info on the request such as headers, the request body, the structure of the response, and the url (endpoint) the request is hitting. Scraping this url is the same as scraping a website except there will be no html to parse through just formatted data. Some websites will try to block this type of behavior. If that happens I suggest using phantomjs without selenium. It can be very fast (in comparison to selenium) for mimicking human interaction on websites.
1
0
0
I am trying to use python to scrape a website implemented with infinite scroll. Actually, the web is pinterest. I know how to use selenium webdriver to scrape a web with infinite scroll. However, the webdriver basically imitates the process of visiting the web and is slow, much slower than using BeautifulSoup and urllib for scraping. Do you know any time efficient ways to scrape a web with infinite scroll? Thanks.
Is there any fast ways to scrape a website with infinite scroll?
1.2
0
1
3,050
27,683,900
2014-12-29T05:36:00.000
1
1
1
0
python,time,timeit
27,684,364
2
false
0
0
The time it takes to run the setup code doesn't affect the timeit module's timing calculations. You should be able to pass your matrix into the setup parameter using import, eg "from __main__ import mymatrix"
1
2
0
I am trying to use the timeit module to time the speed of an algorithm that analyzes data. The problem is that I have to do run some setup code in order to run this algorithm. Specifically, I have to load some documents from a database, and turn it into matrix representation. The timeit module does not seem to allow me to pass in the matrix object, and instead forces me to set this up all over again in the setup parameter. Unfortunately this means that the running time of my algorithm is fuzzed by the running time of pre-processing. Is there some way to pass in objects that were created already, to timeit in the setup parameter? Otherwise, how can I deal with situations where the setup code takes a nontrivial amount of time, and I don't want that to fuzz the code block I actually am trying to test? Am I approaching this the wrong way?
Timeit module - Passing objects to setup?
0.099668
0
0
601
27,684,920
2014-12-29T07:17:00.000
-1
0
1
1
python,linux,windows,ubuntu,exe
27,685,003
2
false
0
0
if you can't get the python to run on windows a packaged exe version is impossible.
1
0
0
I have python program that I've been writing on Ubuntu. For some reasons I could not properly installed on windows few libraries that I used, there are some problems I can't solve in libraries. I used PyInstaller to build run file in Ubuntu. And it is works perfectly. But now I faced a problem, I need to run this application on windows. And it specifically need to be an exe file, so I would not need to install ubuntu vmware on every PC in which I use this app. So is there any solution to compile/convert run file to exe?
How to compile linux application into win *.exe file
-0.099668
0
0
257
27,690,197
2014-12-29T13:51:00.000
3
1
1
1
python,bash,shell,operating-system,temp
27,708,677
2
true
0
0
As a general rule, you should remove the temporary files that you create. Recall that the $TEMP directory is a shared resource that other programs can use. Failure to remove the temporary files will have an impact on the other programs that use $TEMP. What kind of impacts? That will depend upon the other programs. If those other programs create a lot of temporary files, then their execution will be slower as it will take longer to create a new temporary file as the directory will have to be scanned on each temporary file creation to ensure that the file name is unique. Consider the following (based on real events) ... In years past, my group at work had to use the Intel C Compiler. We found that over time, it appeared to be slowing down. That is, the time it took to run our sanity tests using it took longer and longer. This also applied to building/compiling a single C file. We tracked the problem down. ICC was opening, stat'ing and reading every file under $TEMP. For what purpose, I know not. Although the argument can be made that the problem lay with the ICC, the existence of the files under $TEMP was slowing it and our development team down. Deleting those temporary files resulted in the sanity checks running in less than a half hour instead of over two--a significant time saver. Hope this helps.
1
2
0
It's a common question not specifically about some language or platform. Who is responsible for a file created in systems $TEMP folder? If it's my duty, why should I care where to put this file? I can place it anywhere with same result. If it's OS responsibility, can I forgot about this file right after use? Thanks and sorry for my basic English.
Should I delete temporary files created by my script?
1.2
0
0
1,430