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
31,330,946
2015-07-10T01:18:00.000
1
0
1
0
python,notepad++
31,330,984
3
false
0
0
What I have been doing is this: Press F5 to run. Paste this | C:\Python27\python.exe "$(FULL_CURRENT_PATH)" Replace Python27 with whatever version you use. Then run. It should take what you're writing and run it, make sure to select Python as the current language too. Sorry if this isn't what you're looking for, I'm just starting too!
3
0
0
I'm having trouble executing my programs in Notepad++. I'm currently operating on Windows 7. When attempting to run the program in the the interpreter, I have to jump through numerous hoops to actually get my program to execute. In Notepad++, I'm unable to provide additional text if I'd like to run a sys.argv command, or need to write in a name for a function. Are there any solutions? Any easier way to run my code?
Problems running Python in Notepad++
0.066568
0
0
1,372
31,330,946
2015-07-10T01:18:00.000
4
0
1
0
python,notepad++
31,331,079
3
false
0
0
Run your code from command interpreter.It will look like this C:\Python27\python.exe programe_name.py change directory where your program is save before the command.I recommend you to download IDLE editor.It is easy way to learn python.
3
0
0
I'm having trouble executing my programs in Notepad++. I'm currently operating on Windows 7. When attempting to run the program in the the interpreter, I have to jump through numerous hoops to actually get my program to execute. In Notepad++, I'm unable to provide additional text if I'd like to run a sys.argv command, or need to write in a name for a function. Are there any solutions? Any easier way to run my code?
Problems running Python in Notepad++
0.26052
0
0
1,372
31,330,946
2015-07-10T01:18:00.000
0
0
1
0
python,notepad++
31,331,737
3
true
0
0
There are better editors which can run python without a problem. Github's atom can do this easily and is a great free solution and Sublime Text 2 is also both free and paid. However, if you absolutely have to run on NotePad++, do click Run on the Menu and then Run again. Now, type in the shell command you would like to run (Path-to-python.exe + Path-To-File) and click run
3
0
0
I'm having trouble executing my programs in Notepad++. I'm currently operating on Windows 7. When attempting to run the program in the the interpreter, I have to jump through numerous hoops to actually get my program to execute. In Notepad++, I'm unable to provide additional text if I'd like to run a sys.argv command, or need to write in a name for a function. Are there any solutions? Any easier way to run my code?
Problems running Python in Notepad++
1.2
0
0
1,372
31,331,862
2015-07-10T03:15:00.000
1
0
1
0
python,python-2.7,python-3.x,python-internals
31,334,203
2
true
0
0
Python has two basic modes: normal and interactive. The normal mode is the mode where the scripted and finished .py files are run in the Python interpreter. Interactive mode is a command line shell which gives immediate feedback for each statement, while running previously fed statements in active memory. As new lines are fed into the interpreter, the fed program is evaluated both in part and in whole. The same occurs with the .cpy files. Interactive mode basically doing the entire process for each line. I highly doubt that there's a more efficient way to do so. The iPython notebook works in a similar way.
1
3
0
I want to know how Python interactive mode works. Usually when you run Python script on CPython it will go trough the process of lexical analysis, parsing, gets compiled into .pyc file, and finally the .pyc file is interpreted. Does this 4-step process happen while using interactive mode also, r is there a more efficient way of implementing?
How does Python's interactive mode work?
1.2
0
0
1,991
31,333,537
2015-07-10T06:03:00.000
0
0
1
0
python,dictionary
31,334,518
2
false
0
0
To be honest it actually works like associative map in C++..If you have ever used C++ then..If you see the source code of Python Interpreter, you will see that it uses your heap memory section to store data to two type & use pointers to point one data to other exactly like map works in C++. In my system it is 280.. Now as @Navneet said you can use sys.getsizeof to calculate the size. But remember that it is system specific & hence your system might not give you 280bytes. Understand that if it is 280bytes, it means it uses a delicate thread of several associative pointers to store an point to the data structure
1
3
0
If we create an empty dictionary, like: idict = {}, how many spaces are assigned for this dictionary ? I know for the list, if we initialize a list like ilist = [], it will always over-allocate the size, first is 4 space, then 8. What about a dictionary ?
how many space assigned for empty dictionary in python?
0
0
0
474
31,339,599
2015-07-10T11:25:00.000
1
0
1
0
python,python-2.7,python-magic,libmagic
63,376,470
3
false
0
0
I solve this issue installing the library "python-magic-bin" using the command pip install python-magic-bin
1
2
0
Hi I'm trying to use python-magic on windows 8 but when I try to import with the command import magic it gives me this error WindowsError: [Error 193] %1 is not a valid Win32 application I have tried both with 64-bit and 32-bit version of Python 2.7.10 but I always get this error. Thx
python-magic WindowsError: [Error 193] %1 is not a valid Win32 application
0.066568
0
0
1,764
31,340,239
2015-07-10T12:00:00.000
2
0
1
0
python
31,340,275
2
false
0
0
No, you shouldn't. Python has other forms of error handling, and if you really want to return a success code true and false is the better way. As a caller you should really be able to assume that everything went as expected, and then you can throw some kind of descriptive error if something went wrong.
1
6
0
In C, if I'm not wrong, the main function returns 0 if no errors occurred, and something different from 0 if an error occurs. Is is appropriate to do the same in Python (as long as a function does not have to return any specific value but one to indicate the success/failure); or instead just handle exceptions?
Error handling methodology
0.197375
0
0
833
31,341,127
2015-07-10T12:44:00.000
1
0
0
0
python,python-2.7,matplotlib,multiprocessing
38,479,294
2
false
0
0
I just had a very similar issue in which I have a class which produces plots in parallel. The first time I create a new instance of that class and run the plotting function, everything works perfectly. But if I create a new instance and plot, everything freezes. I fixed it by writing a bash script which will in turn run a python script with the code for a single class instantiation + plot call. In other words, closing python between one plot call and the next one makes a clean slate of your working environment the computer does not freeze anymore. This is not an optimal solution, but it's working :)
1
6
1
I have an issue with matplotlib and multiprocessing. I launch a first process, where I display an image and select an area, and close the figure. Then I launch another process, where I call a graph function that is regularly updated. Up this point, eveything works fine. Then when I try to launch another process with the SAME graph function, it freeze my whole computer, BUT the background processes stil work... I only have one of these errors (it's not always the same): error 1 : XIO: fatal IO error 25 (Inappropriate ioctl for device) on X server ":0.0" after 4438 requests (4438 known processed) with 30 events remaining. XIO: fatal IO error 11 (Resource temporarily unavailable) on X server ":0.0" after 4443 requests (4443 known processed) with 31 events remaining. [xcb] Unknown sequence number while processing queue [xcb] Most likely this is a multi-threaded client and XInitThreads has not been called [xcb] Aborting, sorry about that. python: ../../src/xcb_io.c:274: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost' failed. error 2 : X Error of failed request: BadIDChoice (invalid resource ID chosen for this connection) Major opcode of failed request: 53 (X_CreatePixmap) Resource id in failed request: 0x5600299 Serial number of failed request: 4793 Current serial number in output stream: 4795 XIO: fatal IO error 25 (Inappropriate ioctl for device) on X server ":0.0" after 4788 requests (4788 known processed) with 31 events remaining. XIO: fatal IO error 25 (Inappropriate ioctl for device) on X server ":0.0" after 4793 requests (4793 known processed) with 32 events remaining. The weird part is that I can totaly launch several process calling the graph function without any issue, it's the coupling with the first plot that make it unstable. When trying to debug, I found out that a simple fig=plt.figure() is enough to crash everything : in fact, any call to plt ... I read here and there that you can force matplotlib to use the agg backend and it helps with the multiprocess, but some widgets doesn't work with it so I would like to avoid this. I don't really understand why using matplotlib in differents processes could cause problems, so if anyone could explain the reasons and/or help me with a workaround, it would be very nice.
Matplotlib with multiprocessing freeze computer
0.099668
0
0
1,823
31,344,931
2015-07-10T15:41:00.000
1
0
1
0
python,django,debugging,pip,virtualenv
31,349,989
1
true
0
0
There is no magic way to see what packages are actually in use. The easiest option would be: Create and activate a new, empty virtualenv. Try to run your code. When it fails because of a missing dependency, pip install the missing package. Repeat step 2 until everything works. pip freeze > requirements.txt to record the final requirements.
1
1
0
I am still in my dev environment (in a virtual environment), So I have installed some pip packages to test or trying ways to do something. Now I am wondering if it is possible to find out which of those modules are really in use. Thanks in advance.
Find out which PIP modules are really in use
1.2
0
0
62
31,346,102
2015-07-10T16:41:00.000
0
0
0
1
python,amazon-web-services,amazon-s3,amazon-emr,amazon-data-pipeline
31,363,788
1
false
0
0
First thing you want to do is to set 'termination protection' on - on the EMR cluster -as soon as it is launched by Data Pipeline. (this can be scripted too). Then you can log on to the 'Master instance'. This is under 'hardware' pane under EMR cluster details. (you can also search in EC2 console by cluster id). You also have to define a 'key' so that you can SSH to the Master. Once you log on to the master, you can look under /mnt/var/log/hadoop/steps/ for logs - or /mnt/var/lib/hadoop/.. for actual artifacts. You can browse hdfs using HDFS utils. The logs (if they are written to stdout or stderr), are already moved to S3. If you want to move additional files, you have to have write a script and run it using 'script-runner'. You can copy large amount of files using 's3distcp'.
1
1
0
I am trying to create a basic ETL on AWS platform, which uses python. In a S3 bucket (lets call it "A") I have lots of raw log files, gzipped. What I would like to do is to have it periodically (=data pipeline) unzipped, processed by a python script which will reformat the structure of every line, and output it to another S3 bucket ("B"), preferably as gzips of the same log files originating in the same gzip in A, but that's not mandatory. I wrote the python script which does with it needs to do (receives each line from stdin) and outputs to stdout (or stderr, if a line isn't valid. in this case, i'd like it to be written to another bucket, "C"). I was fiddling around with the data pipeline, tried to run a shell command job and also a hive job for sequencing with the python script. The EMR cluster was created, ran, finished, no fails or errors, but also no logs created, and I can't understand what is wrong. In addition, I'd like the original logs be removed after processed and written to the destination or erroneous logs buckets. Does anyone have any experience with such configuration? and words of advise?
AWS ETL with python scripts
0
0
0
671
31,346,625
2015-07-10T17:13:00.000
1
0
0
0
python,xml,lxml,docx,python-docx
31,349,163
1
false
0
0
You probably need to be more specific, but the short answer is, in principle, yes. At a certain level, all python-docx does is modify strings in the XML. A couple things though: The XML you create needs to remain well-formed and valid according to the schema. So if you change the text enclosed in a <w:t> element, for example, that works fine. Conversely, if you inject a bunch of random XML at an arbitrary point in one of the .xml parts, that will corrupt the file. The XML "files", known as parts that make up a .docx file are contained in a Zip archive known as a package. You must unpackage and repackage that set of parts properly in order to have a valid .docx file afterward. python-docx takes care of all those details for you, but if you're going directly at the .docx file you'll need to take care of that yourself.
1
2
0
I want to enter data into a Microsoft Excel Spreadsheet, and for that data to interact and write itself to other documents and webforms. With success, I am pulling data from an Excel spreadsheet using xlwings. Right now, I’m stuck working with .docx files. The goal here is to write the Excel data into specific parts of a Microsoft Word .docx file template and create a new file. My specific question is: Can you modify just a text string(s) in a word/document.xml file and still maintain the integrity and functionality of its .docx encasement? It seems that there are numerous things that can change in the XML code when making even the slightest change to a Word document. I've been working with python-docx and lxml, but I'm not sure if what I seek to do is possible via this route. Any suggestions or experiences to share would be greatly appreciated. I feel I've read every article that is easily discoverable through a google search at least 5 times. Let me know if anything needs clarification. Some things to note: I started getting into coding about 2 months ago. I’ve been doing it intensively for that time and I feel I’m picking up the essential concepts, but there are severe gaps in my knowledge. Here are my tools: Yosemite 10.10, Microsoft Office 2011 for Mac
Can you modify only a text string in an XML file and still maintain integrity and functionality of .docx encasement?
0.197375
1
0
581
31,347,339
2015-07-10T17:58:00.000
0
0
0
1
python,windows,csv
31,347,743
2
true
0
0
Damn it, it's already working!, it has been like saying i cannot find my glasses and to have them on. THanks Brian, it wasn't that the error. The problem was that in my code i was dealing with ubuntu separator besides the full path to the csv output file was completely correct. But I replaced it with os.sep , and started working like a charm :) Thanks again!
1
0
0
I have to run my python script on windows too, and then it began the problems. Here I'm scraping html locally saved files, and then saving their .csv versions with the data I want. I ran it on my ubuntu and goes for +100k files with no problems. But when I go on windows, it says: IOError: [Errno 13] Permission denied It is not a permissions problems, I've rechecked it, and run it under 'Administration' powers, and it makes no difference. It breaks exactly on the line where I open the file: with open(of, 'w') as output: ... I've tried to create same first file of the 100k from the python console and from a new blank stupid script from same directory as my code, and it works... So, it seems is doable. Then I've tried with output = open(of, 'w') instead of above code but nothing. The weird thing is that it creates a directory with same name as the file, and then breaks with the IOError. I've started thinking that it could be a csv thing..., naaaeehh, apart from other tries that didn't helped me, the most interesting stuff is that with the following code: with open(of+.txt, 'w') as output: ... it happens the astonishing thing that it creates a directory ending on .csv AND a file ending in .csv.txt with the right data! Aargh! Changing the open mode file to 'w+', 'wb', it didn't make a difference either. Any ideas?
python astonishing IOError on windows creating files - Errno 13 Permission
1.2
0
0
786
31,349,125
2015-07-10T19:48:00.000
0
0
0
0
django,python-2.7,django-templates,django-views
31,349,275
2
true
1
0
Message is plain text, while html_message is a message formatted using HTML. If you set both, probably your email client is displaying the HTML version.
1
3
0
When im trying to send a mail with django send mail only the html message is coming and not the normal message i want to know the difference between both. Is there any best way to send mails through template or html files because i want a comming mailing system in my app. Note:- the difference is of more important. THIS IS WHAT I DID msg_html = (' HELLLOOOOO') msg_plain = 'Normalallalaa send_mail("titleeeee", msg_plain,"sender@test",["reciever@tese",],html_message=msg_html) My mail contained only Hello in bold Where did my message go.
what is the difference between django html_message and message in send mail
1.2
0
0
905
31,350,335
2015-07-10T21:10:00.000
1
0
0
1
linux,centos,docker,ipython-notebook
31,355,539
5
false
0
0
@maybeg's answer already explains very well why this might be happening. Regarding stopping the unresponsive container, another solution is to simply issue a docker stop <container-id> in another terminal. As opposed to CTRL-C, docker stop does not send a SIGINT but a SIGTERM signal, to which the process might react differently. Usage: docker stop [OPTIONS] CONTAINER [CONTAINER...] Stop a running container by sending SIGTERM and then SIGKILL after a grace period If that fails, use docker kill <container-id> which sends a SIGKILL immediately.
1
22
0
Having an issue with Docker at the moment; I'm using it to run an image that launches an ipython notebook on startup. I'm looking to make some edits to ipython notebook itself, so I need to close it after launch. However, hitting CTRL+C in the terminal just inputs "^C" as a string. There seems to be no real way of using CTRL+C to actually close the ipython notebook instance. Would anyone have any clues as to what can cause this, or know of any solutions for it?
Docker not responding to CTRL+C in terminal
0.039979
0
0
14,239
31,353,137
2015-07-11T03:31:00.000
0
0
0
0
python,heroku,pyodbc
61,108,863
7
false
1
0
RedHat/CentOS: dnf install -y unixODBC-devel along with unixODBC installation
4
83
0
I'm trying to install PyODBC on Heroku, but I get fatal error: sql.h: No such file or directory in the logs when pip runs. How do I fix this error?
sql.h not found when installing PyODBC on Heroku
0
1
0
62,898
31,353,137
2015-07-11T03:31:00.000
1
0
0
0
python,heroku,pyodbc
59,790,771
7
false
1
0
I recently saw this error in Heroku. To fix this problem I took the following steps: Add Apt File to the root folder, with the following: unixodbc unixodbc-dev python-pyodbc libsqliteodbc Commit that Run heroku buildpacks:clear Run heroku buildpacks:add --index 1 heroku-community/apt Push to Heroku For me the problem was that I previously installed the buildpack for python, which was not needed. By running heroku buildpacks:clearI removed all un-needed buildpacka, then add back the one I needed. So if you do follow these steps be sure to make note of the build packs you need. To view the buildpacks you have run heroku buildpacks before following these steps.
4
83
0
I'm trying to install PyODBC on Heroku, but I get fatal error: sql.h: No such file or directory in the logs when pip runs. How do I fix this error?
sql.h not found when installing PyODBC on Heroku
0.028564
1
0
62,898
31,353,137
2015-07-11T03:31:00.000
1
0
0
0
python,heroku,pyodbc
47,557,567
7
false
1
0
The other answers are more or less correct; you're missing the unixodbc-dev[el] package for your operating system; that's what pip needs in order to build pyodbc from source. However, a much easier option is to install pyodbc via the system package manager. On Debian/Ubuntu, for example, that would be apt-get install python-pyodbc. Since pyodbc has a lot of compiled components and interfaces heavily with the UnixODBC OS-level packages, it is probably a better fit for a system package rather than a Python/pip-installed one. You can still list it as a dependency in your requirements.txt files if you're making code for distribution, but it'll usually be easier to install it via the system PM.
4
83
0
I'm trying to install PyODBC on Heroku, but I get fatal error: sql.h: No such file or directory in the logs when pip runs. How do I fix this error?
sql.h not found when installing PyODBC on Heroku
0.028564
1
0
62,898
31,353,137
2015-07-11T03:31:00.000
8
0
0
0
python,heroku,pyodbc
31,358,757
7
false
1
0
You need the unixODBC devel package. I don't know what distro you are using but you can google it and build from source.
4
83
0
I'm trying to install PyODBC on Heroku, but I get fatal error: sql.h: No such file or directory in the logs when pip runs. How do I fix this error?
sql.h not found when installing PyODBC on Heroku
1
1
0
62,898
31,354,140
2015-07-11T06:24:00.000
1
0
1
0
python
31,355,098
2
false
0
0
Using global variables has its problems in general: Passing variables as parameters to functions e.g. more flexible and readable than having functions access globals. In case of a network of connected objects, it's usually more flexible for objects to have members referring to other objects then for them to access other objects using globals. Having a module export classes rather than instances allows you to have multiple instances of a class rather than one. Having said that, it's my experience that in programming there are no dogma's. A well known lemma in algorithm design is that from each resource (thing in your program) there maybe zero, one or infinitely many. If you typically can have only one instance of an object and it doesn't change identity, then exporting an instance from a module (so defining it in the modules __init__.py) is fine. It's just that at the start of design you will sometimes assume that a certain resource is unique, but later on it turns out that you'll have multiple. A typical application of exporting an variable rather than a type is when it's in fact a constant. A good example of this is math.pi, that doesn't tend to change very often... Note that since in Python everything is an object, the words 'variable' and 'instance' are used interchangeably here. In addition to that, functions and classes are (usually singleton) objects in their own right in Python.
1
0
0
There are many posts where I got to use the case of __init__.py and use to define global variable is one of them. But I want to know is there any demerit in defining a local variable in __init__.py ?
Defining any variable in __init__.py
0.099668
0
0
1,315
31,361,738
2015-07-11T20:54:00.000
0
0
1
0
python,django,intellij-idea,pycharm
31,439,322
1
true
1
0
For version 4.5.3 only. The issue is with the Django Settings file, in TEMPLATES. It's a bug with the DIRS of TEMPLATES. See bug report. I commented out the TEMPLATES and it worked for me.
1
0
0
After upgrading 4.5.3 my Tools->Run manage.py task no longer works. Clicking on the link does nothing. No window pops up. Going to "Python Console" does not work, same thing, nothing happens. Going to Django in "Languages and Frameworks" and deselecting django allows the "python console" to properly work as a python interpreter. Reselecting Django reproduces the above results. Settings for Django: Django Project Root is the same folder which contains manage.py Settings is my settings file Manage script is manage.py Settings for Django Console: proper python interpreter working directory is the same directory where manage.py is. Project runs fine Again, it all worked fine, updated to 4.5.3, and it stopped working. Any ideas? Other issues, caused by the same thing, is that my test configuration doesn't run. Edit: youtrack.jetbrains.com/issue/PY-16434 - Added Edit: It's a bug, being fixed
PyCharm 4.5.3 Django manage.py task not working after update
1.2
0
0
902
31,362,573
2015-07-11T22:43:00.000
10
0
0
0
python,performance,csv,pandas,dataframe
43,903,727
2
false
0
0
I've found that CSV and tab-delimited text (.txt) are equivalent in read and write speed, both are much faster than reading and writing MS Excel files. However, Excel format compresses the file size a lot. For the same 320 MB CSV file (16 MB .xlsx) (i7-7700k, SSD, running Anaconda Python 3.5.3, Pandas 0.19.2) Using the standard convention import pandas as pd 2 seconds to read .csv df = pd.read_csv('foo.csv') (same for pd.read_table) 15.3 seconds to read .xlsx df = pd.read_excel('foo.xlsx') 10.5 seconds to write .csv df.to_csv('bar.csv', index=False) (same for .txt) 34.5 seconds to write .xlsx df.to_excel('bar.xlsx', sheet_name='Sheet1', index=False) To write your dataframes to tab-delimited text files you can use: df.to_csv('bar.txt', sep='\t', index=False)
2
15
1
I tend to import .csv files into pandas, but sometimes I may get data in other formats to make DataFrame objects. Today, I just found out about read_table as a "generic" importer for other formats, and wondered if there were significant performance differences between the various methods in pandas for reading .csv files, e.g. read_table, from_csv, read_excel. Do these other methods have better performance than read_csv? Is read_csv much different than from_csv for creating a DataFrame?
Performance difference in pandas read_table vs. read_csv vs. from_csv vs. read_excel?
1
0
0
20,524
31,362,573
2015-07-11T22:43:00.000
28
0
0
0
python,performance,csv,pandas,dataframe
31,362,987
2
true
0
0
read_table is read_csv with sep=',' replaced by sep='\t', they are two thin wrappers around the same function so the performance will be identical. read_excel uses the xlrd package to read xls and xlsx files into a DataFrame, it doesn't handle csv files. from_csv calls read_table, so no.
2
15
1
I tend to import .csv files into pandas, but sometimes I may get data in other formats to make DataFrame objects. Today, I just found out about read_table as a "generic" importer for other formats, and wondered if there were significant performance differences between the various methods in pandas for reading .csv files, e.g. read_table, from_csv, read_excel. Do these other methods have better performance than read_csv? Is read_csv much different than from_csv for creating a DataFrame?
Performance difference in pandas read_table vs. read_csv vs. from_csv vs. read_excel?
1.2
0
0
20,524
31,364,301
2015-07-12T04:14:00.000
1
0
1
0
python,regex
31,364,349
2
false
0
0
Raw strings are still useful for writing characters like \ without escaping them. This is generally useful in regex and window paths etc.
1
0
0
In Python 2, when dealing with regular expression we use r'expression', do we still need prepend "r" in Python 3, since I know Python 3 use Unicode by default
Does Python3 still need raw string in regular expression?
0.099668
0
0
706
31,364,987
2015-07-12T06:16:00.000
0
0
0
0
python,python-2.7,user-interface,python-3.x,tkinter
31,366,766
1
true
0
1
If you want to validate the data when the widget loses focus, you would simply bind a function to the <FocusOut> event.
1
0
0
There is a command validatecommand in Entry widget. But there is not a simulated command in Text widget. How to implement the function in Text widget in tkinter?
How to validate the content of a Text widget while this Text widget loses focus?
1.2
0
0
39
31,365,093
2015-07-12T06:36:00.000
0
0
1
0
python,ipython,pycharm,ipython-notebook
42,631,771
1
true
0
0
You must start IPython Notebook from Pycharm's run Find the IPython path (ex which ipython on linux). Copy the resulting path, we will need it! On PyCharm go to Run > Edit Configuration > + button on top left most corner (add configuration) > Choose Python. Give your configuration a name. On the configuration tab, in the Script textbox, paste the path from step 1. On the script, parameters write notebook. Apply then Ok. This is essentially like calling ipython notebook from the terminal Now place your brakepoints and run the notebook from PyCarm (Shift+F10 or click the playbutton).
1
2
0
I'd like to know how to set breakpoints in IPython notebook on PyCharm. If it's possible, please let me know.
Can PyCharm set breakpoints on ipython notebook?
1.2
0
0
447
31,368,383
2015-07-12T13:41:00.000
0
0
1
0
python,kivy
31,368,591
2
false
0
1
Just open('filename') - the path is relative, so if its in the same directory you don't have to do anything special. If this appears not to work, perhaps it isn't your syntax that is the issue.
1
0
0
Is there any easy method for opening the text file if you are running your app from the same directory? I can't seem to find anything easy. I am asking because you can do that with most of the things in kivy (for image: "name.png", for .kv: load_kv("name.kv") and so on) and I don't understand why it wouldn't be similar with finding a text document.
Open (read, write) a file in same directory as main app - python/kivy
0
0
0
1,130
31,368,710
2015-07-12T14:15:00.000
11
0
1
0
python,file
58,131,092
5
false
0
0
import numpy as np data = np.load('imdb.npz', allow_pickle=True) lst = data.files for item in lst: print(item) print(data[item])
1
40
0
Someone sent me an .npz file. How can I open that file using Python, and read the data from it?
How to open an .npz file
1
0
0
83,162
31,369,558
2015-07-12T15:40:00.000
0
0
0
0
python,postgresql
31,371,403
1
false
0
0
The "right" way to do this is to have a separate table of ticket assignments. Converting the data for something like this is fairly simple on the database end. create table assign as select tech_id from ... followed by creating any necessary foreign key constraints. Rewriting your interface code can be trickier, but you're going to have to do that anyway to allow for more than one tech. You could use an array type, but sometimes database interfaces don't understand postgres array types. There isn't anything inherent in arrays that prevents duplicates or imposes ordering, but you could do that with an appropriate trigger.
1
0
0
We have a ticket software to manage our work, every ticket is assigned to a tech in one field -the normal stuff-, but now we want to assign the same ticket to several technicians eg: tick 5432: tech_id(2,4,7) where 2,4,7 are tech IDs. Of course we can do that using a separate table with the IDs of the tech and the ticket ID, but we have to convert the data.
Is any variable in PostgreSQL to store a list
0
1
0
136
31,369,633
2015-07-12T15:49:00.000
2
0
0
0
python,ssl,https,python-requests,client-certificates
31,370,879
1
false
0
0
This is actually trivial... CA_BUNDLE can be any file that you append certificates to, so you can simply append the output of ssl.get_server_certificate() to that file and it works.
1
2
0
I'm using requests to communicate with remote server over https. At the moment I'm not verifying SSL certificate and I'd like to fix that. Within requests documentation, I've found that: You can pass verify the path to a CA_BUNDLE file with certificates of trusted CAs. This list of trusted CAs can also be specified through the REQUESTS_CA_BUNDLE environment variable. I don't want to use system's certs, but to generate my own store. So far I'm grabbing server certificate with ssl.get_server_certificate(addr), but I don't know how to create my own store and add it there.
Adding server certificates to CA_BUNDLE in python
0.379949
0
1
5,838
31,370,089
2015-07-12T16:36:00.000
0
0
1
0
python,setup.py
31,370,168
1
true
0
0
In most cases, setup.py installs code into locations already along sys.path (which may or may not exist along PYTHONPATH). It doesn't modify PYTHONPATH or sys.path. Generally, the input paths listed in setup.py are assumed to be relative to the setup.py script. For packages and modules, the output paths (where files are installed) are assumed to be standard python install location for third-party packages for the current python interpreter.
1
1
0
When I download a package and run python setup.py install, the package becomes importable. What does the command do that makes the code importable?
What does setup.py install do to make code importable?
1.2
0
0
118
31,370,534
2015-07-12T17:25:00.000
0
0
0
0
python,django,oauth-2.0,google-oauth,django-allauth
31,370,619
2
false
1
0
One option is that the primary form pops up social auth in a new window then uses AJAX to poll for whether the social auth has completed. As long as you are fine with the performance characteristics of this (it hammers your server slightly), then this is probably the simplest solution.
2
2
0
I'm using django 1.8.3 and django-allauth 0.21.0 and I'd like the user to be able to log in using e.g. their Google account without leaving the page. The reason is that there's some valuable data from the page they're logging in from that needs to be posted after they've logged in. I've already got this working fine using local account creation, but I'm having trouble with social because many of the social networks direct the user away to a separate page to ask for permissions, etc. Ideally, I'd have all this happening in a modal on my page, which gets closed once authentication is successful. The only possible (though not ideal) solution I can think of at the moment is to force the authentication page to open up in another tab (e.g. using target="_blank" in the link), then prompting the user to click on something back in the original window once the authentication is completed in the other tab. However, the problem here is that I can't think of a way for the original page to know which account was just created by the previously-anonymous user without having them refresh the page, which would cause the important data that needs to be posted to be lost. Does anyone have any ideas about how I could accomplish either of the two solutions I've outlined above?
Social login in using django-allauth without leaving the page
0
0
0
610
31,370,534
2015-07-12T17:25:00.000
1
0
0
0
python,django,oauth-2.0,google-oauth,django-allauth
32,250,705
2
true
1
0
I ended up resolving this by using Django's session framework. It turns out that the session ID is automatically passed through the oauth procedure by django-allauth, so anything that's stored in request.session is accessible on the other side after login is complete.
2
2
0
I'm using django 1.8.3 and django-allauth 0.21.0 and I'd like the user to be able to log in using e.g. their Google account without leaving the page. The reason is that there's some valuable data from the page they're logging in from that needs to be posted after they've logged in. I've already got this working fine using local account creation, but I'm having trouble with social because many of the social networks direct the user away to a separate page to ask for permissions, etc. Ideally, I'd have all this happening in a modal on my page, which gets closed once authentication is successful. The only possible (though not ideal) solution I can think of at the moment is to force the authentication page to open up in another tab (e.g. using target="_blank" in the link), then prompting the user to click on something back in the original window once the authentication is completed in the other tab. However, the problem here is that I can't think of a way for the original page to know which account was just created by the previously-anonymous user without having them refresh the page, which would cause the important data that needs to be posted to be lost. Does anyone have any ideas about how I could accomplish either of the two solutions I've outlined above?
Social login in using django-allauth without leaving the page
1.2
0
0
610
31,373,742
2015-07-12T23:56:00.000
0
0
1
0
python,range,execution,maya
31,374,327
3
false
0
0
This is not possible in Python with Python source code. Instead, split the code to functions and then call individual functions. E.g. make a function out lines 20 - 45.
2
1
0
It is possible to execute some lines range in a single command in Maya scripting editor? (I'm using Python) The idea is very clear Regularly the user needs to select some parts of the code when he/she is debugging. Let's say, for example, from line 20 to line 45 from the current tab in script editor (obviously). The question is, the is any command like this: "execute(lines=[20,45]", or something like that. I've been playing with "runup" and "cmdScrollFieldExecuter", but unlucky till now.
Exec lines range in Maya script editor
0
0
0
431
31,373,742
2015-07-12T23:56:00.000
0
0
1
0
python,range,execution,maya
31,375,812
3
false
0
0
You can use the python exec statement to try and execute the lines from the history that are selected. However the utility of this is going to be extremely limited, since those lines won't do the same thing in exec that they would inside a function: they won't have access to variables defined outside that selection, for example, or to all the same namespaces the original code could see. This is really only useful in very limited situations. You do know you can select multiple lines and Ctrl+enter to execute them this way, right? Subject to the same limitations as above.
2
1
0
It is possible to execute some lines range in a single command in Maya scripting editor? (I'm using Python) The idea is very clear Regularly the user needs to select some parts of the code when he/she is debugging. Let's say, for example, from line 20 to line 45 from the current tab in script editor (obviously). The question is, the is any command like this: "execute(lines=[20,45]", or something like that. I've been playing with "runup" and "cmdScrollFieldExecuter", but unlucky till now.
Exec lines range in Maya script editor
0
0
0
431
31,375,628
2015-07-13T04:56:00.000
1
1
0
1
python,shell,unix,vim
31,391,726
1
false
0
0
When you do :! in Vim, you effectively put Vim into background and the running process, in this case py.test, gets the focus. That means you can't tell Vim to kill the process for you since Vim is not getting keystrokes from you. Ctrl-Z puts Vim into background while running py.test because Vim is the parent process of py.test. Thus the shell goes through the chain then puts all children as well as the parent into background. I would suggest that you open another terminal window and do all the housekeeping chores there.
1
3
0
I'm writing some threaded python code in vim. When I run my tests, with :! py.test test_me.py Sometimes they hang and cannot be killed with ctrl-C. So I have to background vim (actually the shell the tests are running in) and pkill py.test. Is there a better way to kill the hanging test suite? I tried mapping :map ,k:! pkill py.test but this doesn't work since while the tests are running my input is going to the shell running the test, not vim. EDIT: I'm looking for a way to kill the test process that is quicker than ctrl-Z, pkill py.test, fg <cr> to return to editing. Ideally just a hotkey.
kill a shell created by vim when ctrl-C doesn't work
0.197375
0
0
371
31,377,196
2015-07-13T07:01:00.000
0
1
0
0
python,frameworks,erpnext,frappe
31,379,032
3
false
1
0
bench clear-cache will clear the cache. After doing this, refresh and check.
3
0
0
ERPNext + frappe need to change layout(footer & header) front-end. I tried to change base.html(frappe/templates/base.html) but nothing happened. Probably this is due to the fact that the html files need to somehow compile. Maybe someone have info how to do it? UPDATE: No such command "clear-cache". Commands: backup backup-all-sites config get-app init migrate-3to4 new-app new-site patch prime-wheel-cache release restart set-default-site set-mariadb-host set-nginx-port setup shell start update
Customize frappe framework html layout
0
0
0
1,663
31,377,196
2015-07-13T07:01:00.000
0
1
0
0
python,frameworks,erpnext,frappe
58,808,805
3
false
1
0
It seems you're not in your bench folder. When you create a new bench with, for example : bench init mybench it creates a new folder : mybench. All bench commands must be run from this folder. Could you try to run bench --help in this folder ? You should see the clear-cache command.
3
0
0
ERPNext + frappe need to change layout(footer & header) front-end. I tried to change base.html(frappe/templates/base.html) but nothing happened. Probably this is due to the fact that the html files need to somehow compile. Maybe someone have info how to do it? UPDATE: No such command "clear-cache". Commands: backup backup-all-sites config get-app init migrate-3to4 new-app new-site patch prime-wheel-cache release restart set-default-site set-mariadb-host set-nginx-port setup shell start update
Customize frappe framework html layout
0
0
0
1,663
31,377,196
2015-07-13T07:01:00.000
0
1
0
0
python,frameworks,erpnext,frappe
68,402,268
3
false
1
0
If anyone stumbles on this. The command needed is bench build. That will compile any assets related to the build.json file in the public folder. (NOTE: You usually have to create build.json yourself).
3
0
0
ERPNext + frappe need to change layout(footer & header) front-end. I tried to change base.html(frappe/templates/base.html) but nothing happened. Probably this is due to the fact that the html files need to somehow compile. Maybe someone have info how to do it? UPDATE: No such command "clear-cache". Commands: backup backup-all-sites config get-app init migrate-3to4 new-app new-site patch prime-wheel-cache release restart set-default-site set-mariadb-host set-nginx-port setup shell start update
Customize frappe framework html layout
0
0
0
1,663
31,378,288
2015-07-13T08:08:00.000
0
0
0
1
google-app-engine,middleware,google-app-engine-python
31,397,559
1
false
1
0
The way I approached such scenario (in a python-only project, donno about php) was to use a custom handler (inheriting webapp2.RequestHandler which I was already using for session support). In its customized dispatch() method the user info is collected and stored in the handler object itself. The implementation of the handler exists in only one version controlled file, but which is symlinked (for GAE accessibility) in each module that references the handler. This way I don't have to manage multiple independent copies of the user and session verification code.
1
0
0
Assume that I have few modules on my GAE project (say A, B, C). They shares the users database and sessions. For example: module A will manage the login/logout actions (through cookies), module B,C will handle other actions. FYI, those modules are developed in both PHP and Python. Now, I do not want to make user & session verification codes on all 3 modules. Is there anyway for me to put a middleware that run before all 3 modules for each request. Such as X: it will add header for each request to set the user id and some user's information if the user has logged in. I.E: after I can implement my above idea. Each request will run through 1 in below 3 cases: X, A X, B X, C What do you say? Thanks Update 1: more information The middleware, I mean the request middle ware. If X is a middleware then it will be run before the request is passed to the app (or module), it will change the request only such as: Do some authentication actions Add some headers: X-User-Id: for authorized user id X-User-Scopes: for scopes of authorized user etc ... And of course, it is independent to the inside module's language (PHP or Python or Java or ...) The X middleware should be configured at app.yaml.
GAE middlewares for modules?
0
0
0
59
31,384,639
2015-07-13T13:25:00.000
0
0
1
0
python
68,257,290
5
false
0
0
On my CentOS7.9 Linux (a RedHat clone) it is found in ~/.local/lib/python3.9/site-packages/ and there is no need to include it in the PYTHONPATH variable.
1
176
0
The directory site-packages is mentioned in various Python related articles. What is it? How to use it?
What is python's site-packages directory?
0
0
0
196,583
31,385,363
2015-07-13T13:56:00.000
0
0
0
0
python,apache-spark,dataframe,apache-spark-sql,export-to-csv
69,462,087
9
false
0
0
try display(df) and use the download option in the results. Please note: only 1 million rows can be downloaded with this option but its really quick.
1
106
1
I am using Spark 1.3.1 (PySpark) and I have generated a table using a SQL query. I now have an object that is a DataFrame. I want to export this DataFrame object (I have called it "table") to a csv file so I can manipulate it and plot the columns. How do I export the DataFrame "table" to a csv file? Thanks!
How to export a table dataframe in PySpark to csv?
0
1
0
340,481
31,387,311
2015-07-13T15:22:00.000
0
0
1
0
python,kivy
31,411,920
2
false
0
1
root is global to every widget rule and refers to the top most widget which in most cases is the instance of the class...
1
1
0
What is the scope of root if I have a custom widget embedded in another custom widget? Is there a rule of thumb to avoid confusion?
Scope of root in kivy language
0
0
0
199
31,387,660
2015-07-13T15:39:00.000
0
0
0
0
kivy,qpython,qpython3
31,388,789
2
true
0
1
Edit: Kivy now supports python3 on Android, though qpython would still have to include this (or a similar build process) to have kivy work in qpython3. You can't right now, as kivy does not have a python3-supporting backend on android. We're working towards adding one, at which point I quess qpython may look at adding support in qpython3.
1
0
0
How I can use the Kivy framework in Qpython3 (Python 3.2 for android) app? I know that Qpython (Python 2.7 for android) app support this framework. pip_console don't install kivy. I have an error, when I try to install it. Please help me.
Kivy on Qpython3 (Android)
1.2
0
0
6,003
31,387,762
2015-07-13T15:44:00.000
0
0
0
0
javascript,python,django,timer
31,387,864
3
true
1
0
The only secure way would be to put the logic on the server that checks the time. Make an Ajax call to the server. If the time is under 5 seconds, do not return the HTML, if it is greater than , than return the html to show. Other option is to have the link point to your server and if the time is less than five seconds it redirects them to a different page. If it is greater than 5, it will redirect them to the correct content. Either way, it requires you to keep track of session time on the server and remove it from the client.
2
0
0
I know how to do that with javascript but I need a secure way to do it. Anybody can view page source, get the link and do not wait 5 seconds. Is there any solution? I'm working with javascript and django. Thanks!
Wait 5 seconds before download button appear
1.2
0
0
1,293
31,387,762
2015-07-13T15:44:00.000
0
0
0
0
javascript,python,django,timer
31,388,190
3
false
1
0
Use server side timeout.. whenever there is (AJAX) request from client for download link with timestamp, compare the client sent timestamp with currenttime and derive how much time is required to halt the request at server side to make up ~5 seconds. So by comparing timestamp you can almost achieve accuracy of waiting time as the network delays would be taken into account automatically.
2
0
0
I know how to do that with javascript but I need a secure way to do it. Anybody can view page source, get the link and do not wait 5 seconds. Is there any solution? I'm working with javascript and django. Thanks!
Wait 5 seconds before download button appear
0
0
0
1,293
31,388,220
2015-07-13T16:05:00.000
0
0
0
0
python,amazon-web-services
31,411,856
1
false
0
0
Unlike row-based systems, which are ideal for transaction processing, column-based systems (Redshift) are ideal for data warehousing and analytics, where queries often involve aggregates performed over large data sets. Since only the columns involved in the queries are processed and columnar data is stored sequentially on the storage media, column-based systems require far fewer I/Os, greatly improving query performance. In your example instead of doing multiple separate updatecommands you can perform a single update .. set.. from ... where ....
1
0
0
I have a fairly large redshift table with around 200 million records. I would like to update the values in one of the columns using a user-defined python function. If I run the function in an EC2 instance, it results in millions of updates to the table, and it is very slow. Is there a better process for me to speed up these updates?
How to increase performance of large number of updates to a redshift table with python functions
0
1
0
56
31,390,838
2015-07-13T18:32:00.000
0
0
0
0
python,classification,word2vec
31,619,724
2
false
0
0
For a multi-class classification problem of sentences, doc2vec can work just fine, since context rarely changes a lot within the sentence. If you want to use only python, I will recommend, doc2vec (for building features) followed by xgboost (for training classifier), which has worked for me in similar problems.
2
1
1
I want to build a classifier for forum posts that will automatically categorize these posts into some defined categories(so multiclass classification not only binary classification) by using semantic word representations. For this task I want to make use of word2vec and doc2vec and check the feasability of using these models to support a fast selection of training data for the classifier. At this moment I have tried both models and they work like charm. However, as I do not want to manually label each sentence to predict what is it describing, I want to leave this task for the word2vec or doc2vec models. So, my question is : what algorithm can I use in Python for the classifier? ( I was thinking to apply some clustering over word2vec or doc2vec - manually label each cluster (this would require some time and is not the best solution). Previously, I made use of "LinearSVC"(from SVM) and OneVsRestClassifier, however, I labeled each sentence (by manually training a vector "y_train" ) in order to predict to which class a new test sentence would belong to. What would be a good alghorithm and method in python to use for this type of classifier(making use of semantic word representations to train data)?
Using semantic word representation (e.g. word2vec) to build a classifier
0
0
0
1,109
31,390,838
2015-07-13T18:32:00.000
2
0
0
0
python,classification,word2vec
31,393,600
2
true
0
0
The issue with things like word2vec/doc2vec and so on - actually any usupervised classifier - is that it just uses context. So, for example if I have a sentence like "Today is a hot day" and another like "Today is a cold day" it thinks hot and cold are very very similar and should be in the same cluster. This makes it pretty bad for tagging. Either way, there is a good implementation of Doc2Vec and Word2Vec in gensim module for python - you can quickly use the google-news dataset's prebuilt binary and test whether you get meaningful clusters. The other way you could try is implement a simple lucene/solr system on your computer and begin tagging a few sentences randomly. Over time lucene/solr will suggest tags clearfor your document, and they do come out to be pretty decent tags if your data is not really bad. The issue here is the problem youre trying to solve isnt particularly easy nor is completely solvable - If you have very good/clear data, then you may be able to auto classify about 80-90% of your data ... but if it is bad, you wont be able to auto classify it much.
2
1
1
I want to build a classifier for forum posts that will automatically categorize these posts into some defined categories(so multiclass classification not only binary classification) by using semantic word representations. For this task I want to make use of word2vec and doc2vec and check the feasability of using these models to support a fast selection of training data for the classifier. At this moment I have tried both models and they work like charm. However, as I do not want to manually label each sentence to predict what is it describing, I want to leave this task for the word2vec or doc2vec models. So, my question is : what algorithm can I use in Python for the classifier? ( I was thinking to apply some clustering over word2vec or doc2vec - manually label each cluster (this would require some time and is not the best solution). Previously, I made use of "LinearSVC"(from SVM) and OneVsRestClassifier, however, I labeled each sentence (by manually training a vector "y_train" ) in order to predict to which class a new test sentence would belong to. What would be a good alghorithm and method in python to use for this type of classifier(making use of semantic word representations to train data)?
Using semantic word representation (e.g. word2vec) to build a classifier
1.2
0
0
1,109
31,391,729
2015-07-13T19:22:00.000
1
0
0
0
python,csv,selenium,screenshot
31,391,856
1
false
0
0
Selenium tests in Python are just python code. You can use the CSV module and a normal loop to carry out these actions on the page, and receive the values from the new DOM. You can use loops just like normal Python to capture the screenshots, but no I'm not going to write the code for ya.
1
0
0
Can someone let me know 1. How to write selenium webdriver code in python for reading the data from CSV files and input them into fields of application under test and print the results into CSV file after execution. 2. I have written capture screenshot for every statement to get the screenshots. Is there any that we can capture screenshots in a single go, like using any loop statements etc..If yes, then can you post the code Thanks for your time and response is appreciated....
Selenium webdriver code for reading/Writing data from CSV in Python
0.197375
0
1
629
31,392,285
2015-07-13T19:56:00.000
3
0
0
0
python,postgresql,sqlalchemy,alembic
31,392,595
3
false
0
0
This works for me: 1) Access your session, in the same way you did session.create_all, do session.drop_all. 2) Delete the migration files generated by alembic. 3) Run session.create_all and initial migration generation again.
1
7
0
Everything I found about this via searching was either wrong or incomplete in some way. So, how do I: delete everything in my postgresql database delete all my alembic revisions make it so that my database is 100% like new
Clear postgresql and alembic and start over from scratch
0.197375
1
0
7,991
31,393,074
2015-07-13T20:42:00.000
0
0
1
0
python,user-interface,wxpython,toolbar,wxwidgets
31,393,184
1
false
0
1
No. That widget is part of the toolbar. Just use a BitmapButton or a PlateButton. They both support images and would be more flexible to use anyway.
1
0
0
I want to create a ToolBarToolBase object without adding it visibly to the toolbar. I've tried instantiating ToolBarToolBase, but I'm using wxPython version 2.8.12.1 (I can't upgrade, I'm doing this for work) so I don't think it's fully implemented. Is there any way to do this?
wxPython Create a LabelTool without adding it to a Toolbar
0
0
0
25
31,396,712
2015-07-14T02:36:00.000
4
1
0
0
python,import.io
31,427,417
2
false
0
0
One slightly less elegant solution would be to create a crawler. And before you run it insert the the 10k URLs in the "where to start crawling" box. Under advanced options set the crawl depth to zero, that way you will only get the pages you put in the where to start crawling input box. That should do the trick. Plus the cawler has a bunch of other options like wait between pages and concurrent pages etc.
2
4
0
I have set up an Import.io bulk extract that works great with say, 50 URLs. It literally zips through all of them in seconds. However, when I try to do an extract of 40,000 URLs, the extractor starts very fast for the first thousand or so, and then progressively keeps getting slower every incremental URL. By 5,000 it literally is taking about 4-5 seconds per URL. One solution that seems to work is breaking them into chunks of 1,000 URLs at a time and doing a separate bulk extract for each. However, this is very time consuming, and requires splicing back together all of the data at the end. Has anyone experienced this, and if so do they have a more elegant solution? Thanks, Mike
Import.io bulk extract slows down when more URLs are in list
0.379949
0
1
155
31,396,712
2015-07-14T02:36:00.000
0
1
0
0
python,import.io
32,215,417
2
false
0
0
Mike, would you mind trying again? We have worked on the Bulk Extract, now it should be slightly slower at the beginning, but more constant Possibly 40k are still too many, in which case you may try to split, but I did run 5k+ in a single run Let me know how it goes!
2
4
0
I have set up an Import.io bulk extract that works great with say, 50 URLs. It literally zips through all of them in seconds. However, when I try to do an extract of 40,000 URLs, the extractor starts very fast for the first thousand or so, and then progressively keeps getting slower every incremental URL. By 5,000 it literally is taking about 4-5 seconds per URL. One solution that seems to work is breaking them into chunks of 1,000 URLs at a time and doing a separate bulk extract for each. However, this is very time consuming, and requires splicing back together all of the data at the end. Has anyone experienced this, and if so do they have a more elegant solution? Thanks, Mike
Import.io bulk extract slows down when more URLs are in list
0
0
1
155
31,397,675
2015-07-14T04:30:00.000
0
0
1
0
python,linux,ubuntu
31,399,878
1
false
0
0
try pip freeze to find whether the module numpy is installed, If its not then try pip install numpy, also check weather in the environmental variable that the /Scripts is added because that's where all the packages reside.
1
0
1
Currently I am trying to import numpy using the python command but I am getting the error which is: Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named numpy I have already installed the latest version of numpy and my python version is 2.7.10.
Cannot import python-numpy using Ubuntu
0
0
0
103
31,399,631
2015-07-14T06:50:00.000
0
0
0
0
python,events,binding,tkinter,mouse
31,418,783
1
false
0
1
No, you can't bind to "mouse stopped moving". However, you can bind to <B1-Motion>, and with each callback set a timer to run in the future. If the mouse hasn't moved within that time the function will be called. Within that function you could use event_generate to generate a custom <<MouseStopped>> event. If the mouse moves before the timer expires, reset the timer. You get the exactly the same effect as if you bound to the mouse not moving.
1
0
0
Is it possible to trigger a function when the mouse stop moving? For example, I have a scale, and I want to trigger a function when I still holding a button and stop dragging. I used 'ButtonRelease-1' but I had to release a mouse button to be able to trigger a function, it's not what I want. Hope you guys can help me. Thank you in advance.
Binding mouse events on 'stop' motion in tkinter python3
0
0
0
753
31,399,735
2015-07-14T06:56:00.000
0
0
0
1
python,tornado
31,399,949
2
false
0
0
Only way u can change function parse_body_arguments in tornado.httputil file. Otherwise remove Content-Encoding in headers arguments
2
2
0
I'm processing requests in Tornado that comes with Content-Encoding: gzip header in the body request. The problem is that Tornado shows a warning: [W 150713 17:22:11 httputil:687] Unsupported Content-Encoding: gzip I'm doing the unzip operation inside the code and it works like a charm but I'd like to get rid of the message. Is there any way of accepting that Content-Encoding in Tornado? Thanks!
Accept "Content-Encoding: gzip" in Tornado
0
0
0
1,594
31,399,735
2015-07-14T06:56:00.000
4
0
0
1
python,tornado
31,408,024
2
false
0
0
You must opt-in to handling of gzipped requests by passing decompress_request=True to the HTTPServer constructor (or Application.listen).
2
2
0
I'm processing requests in Tornado that comes with Content-Encoding: gzip header in the body request. The problem is that Tornado shows a warning: [W 150713 17:22:11 httputil:687] Unsupported Content-Encoding: gzip I'm doing the unzip operation inside the code and it works like a charm but I'd like to get rid of the message. Is there any way of accepting that Content-Encoding in Tornado? Thanks!
Accept "Content-Encoding: gzip" in Tornado
0.379949
0
0
1,594
31,401,890
2015-07-14T08:44:00.000
2
0
1
0
ipython-notebook
55,136,264
8
false
0
0
if you are using python version 2 pip install jupyter in case using python 3.x pip3 install jupyter to be on the safe side also check that notebook module is installed or not pip install notebook or pip3 install notebok
1
158
0
What do you recommend guys for this error when I type in console ipython notebook and got ImportError: No module named notebook.notebookapp ? I installed ipython notebook with pip and really I don't know what is going on.
ImportError: No module named notebook.notebookapp
0.049958
0
0
87,447
31,403,321
2015-07-14T09:53:00.000
0
0
0
0
javascript,python-2.7,pdf,acrobat
31,418,813
1
false
1
0
Not possible. And that is good so, because allowing such things would be extremely unsafe.
1
0
0
I'm bit new to adobe acrobat JavaScript. I was wondering if it is possible to have a click button in the pdf, once i click it, it will run a JavaScript which will run a python code automatically? Thanks in advance.
How can i use the Javascript in adobe Acrobat to run a Python Script?
0
0
0
169
31,406,106
2015-07-14T12:05:00.000
-1
0
0
0
python,django,testing,django-rest-framework
31,435,440
3
true
1
0
Just found the problem!! I was using APIRequestFactory() and should have been using the build in client factory from the APITestCase test class from Django Rest Framework
1
4
0
I want to test some views in DRF project. The problem comes when I try to check views that have arguments in the urls. urls.py url(r'^(?Pcompany_hash>[\d\w]+)/(?Ptimestamp>[\.\d]*)/employees/$', EmployeeList.as_view(), name='employeelist'), [edit: "<" in url has been deleted in purpose, just it isnt considered a tag and thus not shown] views.py class EmployeeList(ListCreateAPIView): serializer_class = EmployeeDirectorySerializer def inner_company(self): company_hash = self.kwargs['company_hash'] return get_company(company_hash) def get_queryset(self): return Employee.objects.filter(company=self.inner_company()) test.py class ApiTests(APITestCase): def setUp(self): self.factory = APIRequestFactory() self.staff = mommy.make('directory.Employee', user__is_staff=True) self.employee = mommy.make('directory.Employee') self.hash = self.employee.company.company_hash def getResponse(self, url, myView, kwargs): view = myView.as_view() request = self.factory.get(url, kwargs) force_authenticate(request, user=user) response = view(request) return response def test_EmployeeList(self): kwargs = {'timestamp': 0, 'company_hash': self.hash} url = reverse('employeelist', kwargs=kwargs) testedView = EmployeeList response = self.getResponse(url, testedView, kwargs=kwargs) self.assertEqual(response.status_code, 200) I'm getting this error company_hash = self.kwargs['company_hash'] KeyError: 'company_hash' That is the args aren't been passed to the view. I've tried in so many different ways to pass by the args, can't find a solution. Any help is welcomed!
How can i correctly pass arguments to classbasedviews testing Django Rest Framework?
1.2
0
0
3,215
31,410,922
2015-07-14T15:27:00.000
1
0
1
0
python,testing,assert,assertion
31,411,396
1
false
0
0
If you're writing "public" function, I believe that pythonic way would be to check arguments (using if, not assert), and, if they're invalid, raise exception with type and info / message designed to provide as much info as possible. If you're writing function designed for internal use, then using assert to check the arguments seems to be good idea for me.
1
0
0
I'm confused as when to exactly use assertion testing in my python functions. If I specify assumptions regarding the input arguments to a function, should I assume that correct input is being fed to the function or should I use assertions to check the conditions on the input args enumerated in the specification?
Does precondition assertion testing replace assumptions in a function specification or vice versa?
0.197375
0
0
299
31,412,919
2015-07-14T17:01:00.000
0
1
0
0
python,python-2.7,twitter
31,413,075
1
true
0
0
is there any way to constantly "listen" to a website and run some code when it updates? If the site offers a feed or stream of updates, use it. However, if you are looking to scrape a page and trigger code on differences, then you need to poll the site like you are doing (clumsily) with TaskScheduler.
1
1
0
is there any way to constantly "listen" to a website and run some code when it updates? i'm working on earthquake data, specifically, parsing earthquake data from a site that updates and lists earthquake details in real time. so far, my only (and clunky) solution has been to use task scheduler to run every 30 minutes, which of course would have a time difference of 1-29 minutes depending on when the event will happen between the 30 minute downtime between running the code. i also thought of using some twitter API, since the site also has an automated twitter account tweeting details every time an earthquake happens, but again this would require constantly "listening" to the twitter stream via python as well. would appreciate help, thanks.
constantly "listen" to website using python
1.2
0
1
381
31,412,936
2015-07-14T17:01:00.000
0
0
0
0
python,django,amazon-s3
31,523,646
1
true
1
0
The reason my admin styles weren't loading was because I had DEBUG = True in a different settings file than my main settings file (which had DEBUG = False).
1
0
0
I'm using Django 1.8 with static files and also using django-offsite-storage. When I browse the Django admin in my browser on my local machine it's requesting the CSS file /admin/css/base.css from my S3 bucket but without the hashed version. I want it to use the hashed file name version because that's what get's uploaded to the S3 bucket. I've tried switching DEBUG = True or False, but neither do the trick. How can I get it to do this on my local machine?
How can I get my Django admin styles to load?
1.2
0
0
110
31,417,091
2015-07-14T20:51:00.000
0
0
1
0
python,list,pickle
31,429,440
1
false
0
0
If you really want to keep it simple and use something like pickle, the best thing is to use cPickle. This library is written in C and can handle bigger files and is faster than pickle.
1
0
1
I have a very large list that I want to write to file. My list is 2 dimensional, and each element of the list is a 1 dimensional list. Different elements of the 2 dimensional list has 1 dimensional lists of varying size. When my 2D list was small, pickle dump worked great. But now it just gives me memory error. Any suggestions on how to store and reload such arrays to disk? Thanks!
Python pickle dump memory error
0
0
0
1,136
31,417,288
2015-07-14T21:01:00.000
4
0
1
0
python,python-3.x,boolean
31,417,397
8
false
0
0
"Do nothing" isn't an option. The mathematical expression x or y must have a value (which is true if either x, y, or both is true). And x and y must have a value (which is true if and only if x and y are both true). The way your book defines them is mathematically correct, but confusing (until you get into things like short-circuit evaluation).
4
0
0
I am reading about booleans in my book, and it says: x and y------------If x is false, return x. Otherwise, return y. x or y--------------If x is true, return x. Otherwise, return y. This doesn't make sense to me from the everyday usage of "or" and "and" To me, it would make sense if it said: x and y------------If x is false, do nothing. If y is false, do nothing. If x and y are true, return x and y x or y--------------If x is true, return x. If x is false, check y. If y is false, do nothing. If y is true, return y Do I just need to blindly accept the actual definitions, or can I understand them because they actually make sense.
Need help understanding Booleans?
0.099668
0
0
137
31,417,288
2015-07-14T21:01:00.000
0
0
1
0
python,python-3.x,boolean
31,417,441
8
false
0
0
The first set of descriptions are shortcuts: following these will give you exactly the same results as the "usual definitions" of true and false. But your own descriptions don't make much sense. You can't "do nothing"; you have to return some value from a comparison, either true or false. And you can't return both a and b, either: again, the result of a boolean comparison must be a boolean, not a pair of booleans.
4
0
0
I am reading about booleans in my book, and it says: x and y------------If x is false, return x. Otherwise, return y. x or y--------------If x is true, return x. Otherwise, return y. This doesn't make sense to me from the everyday usage of "or" and "and" To me, it would make sense if it said: x and y------------If x is false, do nothing. If y is false, do nothing. If x and y are true, return x and y x or y--------------If x is true, return x. If x is false, check y. If y is false, do nothing. If y is true, return y Do I just need to blindly accept the actual definitions, or can I understand them because they actually make sense.
Need help understanding Booleans?
0
0
0
137
31,417,288
2015-07-14T21:01:00.000
1
0
1
0
python,python-3.x,boolean
31,417,492
8
false
0
0
While the book presents it in a slightly confusing way, it is correct. Boolean logic must evaluate to either true or false. For X and Y in order to return true they both must be true, if X is false then it returns false. If X is true then it returns Y which is either true or false and also the correct answer. For X or Y to return false they both must be false. If X is true then it can return true (X). If X is false then it returns whatever the value of Y is.
4
0
0
I am reading about booleans in my book, and it says: x and y------------If x is false, return x. Otherwise, return y. x or y--------------If x is true, return x. Otherwise, return y. This doesn't make sense to me from the everyday usage of "or" and "and" To me, it would make sense if it said: x and y------------If x is false, do nothing. If y is false, do nothing. If x and y are true, return x and y x or y--------------If x is true, return x. If x is false, check y. If y is false, do nothing. If y is true, return y Do I just need to blindly accept the actual definitions, or can I understand them because they actually make sense.
Need help understanding Booleans?
0.024995
0
0
137
31,417,288
2015-07-14T21:01:00.000
0
0
1
0
python,python-3.x,boolean
31,417,701
8
false
0
0
Its probably easier if you think about it in each literal case x and y------------If x is false, return x. Otherwise, return y. x or y--------------If x is true, return x. Otherwise, return y. CASE 1: x = true, y = true "if x is false, return x. Otherwise, return y." Then this will return y which is true. This makes sense because x and y are both true. (true and true == true) "If x is true, return x. Otherwise, return y." The this will return x which is true. This makes sense because one of x or y is true. (true or true == true) CASE 2: x = false, y = true "if x is false, return x. Otherwise, return y." Then this will return x which is false. This makes sense because x and y are not both true. (false and true == false) "If x is true, return x. Otherwise, return y." The this will return y. This makes sense because one of x or y is true. (false or true == true) CASE 3: x = true, y = false "if x is false, return x. Otherwise, return y." Then this will return y which is false. This makes sense because x and y are not both true. (true and false == false) "If x is true, return x. Otherwise, return y." Then this will return x which is true. This makes sense because x or y is true (true or false == true) CASE 4: x = false, y = false "if x is false, return x. Otherwise, return y." Then this will return x which is false. This makes sense because x and y are not both true. (false and false == false) "If x is true, return x. Otherwise, return y." The this will return y which is false. This makes sense because neither x nor y is true. (false or false == false)
4
0
0
I am reading about booleans in my book, and it says: x and y------------If x is false, return x. Otherwise, return y. x or y--------------If x is true, return x. Otherwise, return y. This doesn't make sense to me from the everyday usage of "or" and "and" To me, it would make sense if it said: x and y------------If x is false, do nothing. If y is false, do nothing. If x and y are true, return x and y x or y--------------If x is true, return x. If x is false, check y. If y is false, do nothing. If y is true, return y Do I just need to blindly accept the actual definitions, or can I understand them because they actually make sense.
Need help understanding Booleans?
0
0
0
137
31,417,487
2015-07-14T21:12:00.000
16
0
0
0
python,scikit-learn,classification,regression
31,417,912
7
true
0
0
That is not a built-in feature. You can "add" it by wrapping the LogisticRegression class in your own class, and adding a threshold attribute which you use inside a custom predict() method. However, some cautions: The default threshold is actually 0. LogisticRegression.decision_function() returns a signed distance to the selected separation hyperplane. If you are looking at predict_proba(), then you are looking at logit() of the hyperplane distance with a threshold of 0.5. But that's more expensive to compute. By selecting the "optimal" threshold like this, you are utilizing information post-learning, which spoils your test set (i.e., your test or validation set no longer provides an unbiased estimate of out-of-sample error). You may therefore be inducing additional over-fitting unless you choose the threshold inside a cross-validation loop on your training set only, then use it and the trained classifier with your test set. Consider using class_weight if you have an unbalanced problem rather than manually setting the threshold. This should force the classifier to choose a hyperplane farther away from the class of serious interest.
1
29
1
I am using LogisticRegression from the sklearn package, and have a quick question about classification. I built a ROC curve for my classifier, and it turns out that the optimal threshold for my training data is around 0.25. I'm assuming that the default threshold when creating predictions is 0.5. How can I change this default setting to find out what the accuracy is in my model when doing a 10-fold cross-validation? Basically, I want my model to predict a '1' for anyone greater than 0.25, not 0.5. I've been looking through all the documentation, and I can't seem to get anywhere.
sklearn LogisticRegression and changing the default threshold for classification
1.2
0
0
39,588
31,417,491
2015-07-14T21:12:00.000
2
0
1
0
ipython,ipython-notebook,jupyter,ipython-magic
31,419,788
1
true
0
0
the difference is that kernel are native, ie, Kernels are processes that speak a protocol that allow remote execution and code completions. So you can hence an R kernel, purely in R, and a julia Kernel, purely in Julia. in the other hand, magics (%%R, %%fortran) are at the beginning Python-only, they ask the Python kernel to execute a piece of code into another language, through bindings libraries. Most of the times, the magics are just a syntactic sugar for Python libraries call. From a user perspective, the difference is small, but can have some consequences. It is harder to exchange variables in between kernel for example. With magics, data exchange is easier, but completion and introspection is harder. Hope that helps.
1
0
0
In Jupyter, kernels provide support for different languages we want to use in the notebook (such as IRkernel). How is this different from using the magics to write in other languages (%load_ext rmagic and using %%R throughout the code)?
Extensions Vs Kernels in IPython
1.2
0
0
181
31,420,095
2015-07-15T01:39:00.000
1
0
0
0
python,numpy,pandas
31,422,570
1
true
0
0
It seems that you have a list of int in your data frame. To convert it to you need to select the value inside and form data frame. I suggest you this code to convert for col in df: df[col] = df[col].apply(lambda x: x[0])
1
0
1
I am learning the book Python for Data Analysis, after running the code from the book I got a pandas dataframe diversity like this: sex F M year 1880 [38] [14] 1881 [38] [14] When I want to use diversity.plot() to draw some pictures, there is TypeError: Empty 'DataFrame': no numeric data to plot So, my question is how to deal with this dataframe to make it as numeric?
How to make dataframe in pandas as numeric?
1.2
0
0
352
31,420,879
2015-07-15T03:16:00.000
2
0
0
1
python,io,parallel-processing,netcdf
31,568,148
2
false
0
0
It's too bad PyPnetcdf is not a bit more mature. I see hard-coded paths and abandoned domain names. It doesn't look like it will take a lot to get something compiled, but then there's the issue of getting it to actually work... in setup.py you should change the library_dirs_list and include_dirs_list to point to the places on your system where Northwestern/Argonne Parallel-NetCDF is installed and where your MPI distribution is installed. then one will have to go through and update the way pypnetcdf calls pnetcdf. A few years back (quite a few, actually) we promoted a lot of types to larger versions.
1
5
0
Is there any way of doing parallel IO for Netcdf files in Python? I understand that there is a project called PyPNetCDF, but apparently it's old, not updated and doesn't seem to work at all. Has anyone had any success with parallel IO with NetCDF in Python at all? Any help is greatly appreciated
Is there any parallel way of accessing Netcdf files in Python
0.197375
0
0
1,241
31,421,793
2015-07-15T04:55:00.000
0
1
0
1
python,ruby,windows,heroku,travis-ci
31,445,471
1
false
1
0
If you hadn't had Heroku Toolbelt setup to the $PATH environment variable during installation, here are some steps to check: Check if Heroku toolbelt is set in PATH variable. If not, cd to your Heroku toolbelt installation folder, then click on the address bar and copy it. Go to the Control Panel, then click System and Advanced System Protection. Go to Environment Variables, then look for $PATH in the System Variables After the last program in the variable, put a ; then paste in your Heroku CLI folder and click OK. (This requires cmd to be restarted manually) Login to Heroku CLI grab the token key from heroku auth:token run travis setup heroku if the setup goes smoothly, you shouldn't get the command not found and prompt you for heroku auth key. It will ask that you want to encrypt the auth key (highly recommend) and verify the information you provided with the toolbelt and Travis CLI. commit changes you should be able to get your app up and running within your tests.
1
1
0
Hi there I'm trying to deploy my python app using Travis CI but I'm running into problems when I run the "travis setup heroku" command in the cmd prompt. I'm in my project's root directory, there is an existing ".travis.yml" file in that root directory. I've also installed ruby correctly and travis correcty because when I run: "ruby -v" I get "ruby 2.2.2p95 (2015-04-13 revision 50295) [x64-mingw32]" "travis -v" I get "1.7.7" When I run "travis setup heroku" I get this message "The system cannot find the path specified" then prompts me for a "Heroku API token:" What's the issue?
travis setup heroku command on Windows 7 64 bit
0
0
0
456
31,422,350
2015-07-15T05:46:00.000
1
0
1
0
python,python-2.7,file-io
31,422,893
3
false
0
0
There is no function in any knows underlying file systems that allows to insert bytes into a file. You can only : add bytes (characters) at the end of the file (append mode) rewrite bytes in place anywhere in the file truncate a file at current position. So if you want to add anything not at the end of the file, the common way (that is used by many text editors) is : rename the old file to a temp name (it is known as a backup copy) create a new file with the original name and write what you want to it (here the prefix, the original content and the postfix) (optionaly) delete the backup copy. That way allows you to recover your file even if bad things occur while writing the new copy : you can at least get the previous copy and restart your edition.
1
0
0
I want to write a couple characters into a file where there is already text inside. What would be the code to add characters to the front of the file and to the back of the text file if I want the text that was initially in the file to remain in the center?
Python: Putting Charater in front or behind a file
0.066568
0
0
52
31,423,456
2015-07-15T06:56:00.000
0
1
0
0
python,sentry
31,424,387
1
true
0
0
If you're talking about notifications you can disable them per-account or entirely on a project via the integration. That said if all the messages are the same you should look into why they're not grouping. A common case would be you're using a logging integration and there's a variable in the log message itself.
1
0
0
In case sentry sends lots of similar messages, is there a way to stop it? We have a lot of clients and the sentry messages are basically all the same so sentry spams me.
Stop sentry from sending messages
1.2
0
1
1,004
31,426,367
2015-07-15T09:20:00.000
0
0
0
0
python,sqlite,matrix
48,332,928
1
false
0
0
As CL recommended, not to use 420 columns. I would recommend an algorithmic approach to save much processing power. Here is an example, since the size is always 390x420, have a table with 10 columns, and 16380 rows. Referencing any point on this matrix can be done with a simple algorithm, and would be much more efficient. Remember, in sql, it is always better to have more rows than columns because of how the data is managed.
1
0
0
I have a 2D array, M 390x420 with float values in it that I would like to save as a table in a sqlite db with python. the row number of the table should be 390, the column number 420. executemany from sqlite is not optimal because then I would have to write ~ 420 of "?" , as far as I've understood. Thank you!
save a matrix (or a 2 dimensional array) in a sqlite db with Python
0
1
0
1,249
31,426,536
2015-07-15T09:28:00.000
-1
0
1
1
python
31,427,309
2
false
0
0
You may try to read a directory directly (as a file) and pick data from there. How successfull would this be is a question of a filesystem you are on. Try first ls or dir commands to see who returns faster. os.listdir() or that funny little program. You'll se that both are in trouble. Here the key is just in that that your directory is flooded with new files. That creates kind of bottle neck.
1
1
0
I have a huge directory that keeps getting updated all the time. I am trying to list only the latest 100 files in the directory using python. I tried using os.listdir(), but when the size of directory approaches 1,00,000 files, it seems as though listdir() crashes( or i have not waited long enough). I only need the first 100 files (or filenames) for further processing, so i dont want listdir() to be filled with all the 100000 files. Is there a good way of doing this in Python? PS: I am very new to programming
How to copy first 100 files from a directory of thousands of files using python?
-0.099668
0
0
2,371
31,428,726
2015-07-15T11:07:00.000
1
0
1
0
revit,revit-api,revitpythonshell
31,429,221
3
false
0
0
You have 2 options: change the TransactionMode to Automatic at the class attribute [Transaction(TransactionMode.Automatic)] open a transaction within your command Transaction tr = new Transaction(commandData.Application.ActiveUIDocument.Document); tr.Start("Command name here"); // your code tr.Commit();
1
0
0
Modifying is forbidden because the document has no open transaction. The document has no open transaction. In Revit Document.
Revit: Modifying is forbidden because the document has no open transaction
0.066568
0
0
1,586
31,433,422
2015-07-15T14:37:00.000
4
0
0
1
python,xcode,macos,terminal
53,036,986
2
false
0
0
Try on 10.14: sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
1
1
0
I've tried pretty much everything on stackoverflow and other forums to get the /usr/include/ folder on my mac (currently using OS X 10.9.5) Re-installed Xcode and command line tools (actually, command line tool wasn't one of the downloads available - so I'm guessing it's was already downloaded) tried /Applications/Install Xcode.app command line on terminal I haven't tested if there is no standard library on Xcode, but I'm only trying to build cloudera/hue from github and it won't install because there is no /usr/include/python2.7 (and couldn't really ask their forum because the error isn't coming from cloudera/hue). How do I get the /usr/include folder?
/usr/include folder missing in mac
0.379949
0
0
3,414
31,435,024
2015-07-15T15:42:00.000
7
0
0
0
python,scikit-learn,numba
31,441,162
2
true
0
0
Scikit-learn makes heavy use of numpy, most of which is written in C and already compiled (hence not eligible for JIT optimization). Further, the LogisticRegression model is essentially LinearSVC with the appropriate loss function. I could be slightly wrong about that, but in any case, it uses LIBLINEAR to do the solving, which is again a compiled C library. The makers of scikit-learn also make heavy use of one of the python-to-compiled systems, Pyrex I think, which again results in optimized machine compiled code ineligible for JIT compilation.
1
9
1
Has anyone succeeded in speeding up scikit-learn models using numba and jit compilaition. The specific models I am looking at are regression models such as Logistic Regressions. I am able to use numba to optimize the functions I write using sklearn models, but the model functions themselves are not affected by this and are not optimized, thus not providing a notable increase in speed. Is there are way to optimize the sklearn functions? Any info about this would be much appreciated.
Using Numba with scikit-learn
1.2
0
0
6,532
31,438,478
2015-07-15T18:39:00.000
1
0
1
1
python
35,230,270
2
false
0
0
If putting the file in C:\Users\<your_user> doesn't work, additionaly try setting your HOME environment variable to C:\Users\<your_user>. Worked for me. Thanks to @WayneWerner for the solution.
2
2
0
I am using .pdbrc to store my debugging alias. And I want it to be available globally. Where should this file be on windows?
Where should I put the .pdbrc file on windows so that it is globally visible?
0.099668
0
0
274
31,438,478
2015-07-15T18:39:00.000
1
0
1
1
python
31,438,577
2
false
0
0
After several tries, I found it. You can put it in C:\users\your_win_user\.pdbrc
2
2
0
I am using .pdbrc to store my debugging alias. And I want it to be available globally. Where should this file be on windows?
Where should I put the .pdbrc file on windows so that it is globally visible?
0.099668
0
0
274
31,441,307
2015-07-15T21:18:00.000
0
1
0
0
java,android,python,android-studio,admob
31,441,510
1
false
1
0
To access Java already implemented version you can use pyjnius. I tried to use it for something else and I didn't succeed. Well, I yielded pretty quickly because it wasn't necessary for my project. Otherwise, I am afraid, you will have to implement it yourself from scratch. I never heard about a finished solution for your problem. If you succeeded to use PGU, it wouldn't be so hard. If not, well, I wish you luck, and put your solution online for others. There is an Eclipse plug-in for Python. I think that Android studio does not support PGS4A. Never needed it. Console is the queen.
1
0
0
I'd like to have advertisements in an android App I've written and built using PGS4A. I've done my research and all, but there doesn't seem to be any online resources that explains how to do that just yet. I haven't much knowledge on Java either, which is clearly why I've written that in Python. Has anyone found a way to achieve that? If not, how difficult would it be to convert the project files into an Android Studio (or even an Eclipse) project? (so then one can just implement the ads following the Java Admob documentation found everywhere) Thank you in advance.
Admob Ads with Python Subset For Android (PGS4A)
0
0
0
199
31,443,662
2015-07-16T00:51:00.000
-1
0
1
0
python,macos,python-2.7
31,443,715
2
false
0
0
When creating your virtual environment (you are using a virtual environment, right?) use pyvenv <foo> instead of virtualenv <foo>, and that will create a Python 3 virtual environment, free of Python 2. Then you are free to use pip and it will install the modules into that venv.
2
0
0
I'm fairly new to python and want to start doing some more advanced programming in python 3. I installed some modules using pip on the terminal (I'm using a mac) only to find out that the modules only installed for python 2. I think that it's because I only installed it to the python 2 path, which I think is because my system is running python 2 by default. But I have no idea how to get around this. Any ideas?
Python Modules Only Installing For Python 2
-0.099668
0
0
33
31,443,662
2015-07-16T00:51:00.000
0
0
1
0
python,macos,python-2.7
31,443,681
2
true
0
0
You need to use pip3. OS X will default to Python 2 otherwise.
2
0
0
I'm fairly new to python and want to start doing some more advanced programming in python 3. I installed some modules using pip on the terminal (I'm using a mac) only to find out that the modules only installed for python 2. I think that it's because I only installed it to the python 2 path, which I think is because my system is running python 2 by default. But I have no idea how to get around this. Any ideas?
Python Modules Only Installing For Python 2
1.2
0
0
33
31,447,971
2015-07-16T07:30:00.000
0
1
0
1
python,debian,remote-server,directory-structure
31,448,678
1
false
0
0
Basically you're stuffed. Your problem is: You have a script, which produces no error messages, no logging, and no other diagnostic information other than a single timestamp, on an output file. Something has gone wrong. In this case, you have no means of finding out what the issue was. I suggest any of the following: either adding logging or diagnostic information to the script. Contacting the developer of the script and getting them to find a way of determining the issue. Delete the evidently worthless script if you can't do either option 1, or 2, above, and consider an alternative way of doing your task. Now, if the script does have logging, or other diagnostic data, but you delete or throw them away, then that's your problem and you need to stop discarding this useful information. EDIT (following comment). At a basic level, you should print to either stdout, or to stderr, that alone will give you a huge amount of information. Just things like, "Discovered 314 records, we need to save 240 records", "Opened file name X.csv, Open file succeeded (or failed, as the case may be)", "Error: whatever", "Saved 2315 records to CSV". You should be able to determine if those numbers make sense. (There were 314 records, but it determined 240 of them should be saved, yet it saved 2315? What went wrong!? Time for more logging or investigation!) Ideally, though, you should take a look at the logging module in python as that will let you log stack traces effectively, show line numbers, the function you're logging in, and the like. Using the logging module allows you to specify logging levels (eg, DEBUG, INFO, WARN, ERROR), and to filter them or redirect them to file or the console, as you may choose, without changing the logging statements themselves. When you have a problem (crash, or whatever), you'll be able to identify roughly where the error occured, giving you information to either increase the logging in that area, or to be able to reason what must have happened (though you should probably then add enough logging so that the logging will tell you what happened clearly and unambiguously).
1
0
0
I have written a python script that is designed to run forever. I load the script into a folder that I made on my remote server which is running debian wheezy 7.0. The code runs , but it will only run for 3 to 4 hours then it just stops, I do not have any log information on it stopping.I come back and check the running process and its not there. Is this a problem in where I am running the python file from? The script simply has a while loop and writes to an external csv file. The file runs from /var/pythonscript. The folder is a custom folder that I made. There is not error that I receive and the only way I know how long the code runs is by the time stamp on the csv file. I run the .py file by ssh to the server and sudo python scriptname.I also would like to know the best place in the linux debian directory to run python files from and limitations concerning that. Any help would be much appreciated.
Where to run python file on Remote Debian Sever
0
0
0
85
31,453,751
2015-07-16T12:08:00.000
1
1
1
0
python,python-unittest
31,455,230
2
true
0
0
From the OP: "This is called even if the test method raised an exception, so the implementation in subclasses may need to be particularly careful about checking internal state." The first things this conveys is that you can be sure that teardown is called whatever happens in your test methods. Consequently this means that you should not have any teardown code in your test method, you should move it into the teardown method. However, if you do have an exception in your test method, this may mean that the state of your test instance may be different on different test runs and the teardown method must take this into account, or you must structure your code so that it will always work. An example may be that you test code involves the creation of tables in the database. If you have an exception, then maybe not all the tables are created, so teardown should make sure it doesn't try to drop non-existent tables. However, the better way might be for setup to start a transaction and teardown to rollback the transaction.
1
1
0
I am new to python. I read unittest docs. In the documentation about tearDown() method, I found following lines "This is called even if the test method raised an exception, so the implementation in subclasses may need to be particularly careful about checking internal state." What does this statement conveys ? Can you let me understand me with the help of some good example, where the internal statement can create havoc ? Thanks in advance. EDIT : I got some answers, but they are quite simple. I need some examples, where some state is involved, like tests involving database and so on.
teardown method in unittest python
1.2
0
0
353
31,454,547
2015-07-16T12:44:00.000
1
0
1
0
python,anaconda,spyder
31,454,881
1
false
0
0
An interpreter is simply an instance of the python executable being run by the operating system. When you call python interactively from a terminal or command prompt, you are calling the python interpreter to wait for user input and evaluate code line by line. Spyder provides a method to effectively have this same window within the IDE (plus some other features). A console (Probably IPython console?) is a heavily modified interactive interpreter designed to look and feel somewhat like mathematica, and provide a number of interactive features that speed up development. IPython Consoles are typically the method of choice when demonstrating code live to an audience. A kernel (in refrence to the console) is actually the python interpreter running in the background that evaluates code when it is sent in. This is a result of the back-end (kernel) / front-end (GUI) style of the IPython console interface. This again borrows some terminology from Mathematica. Lastly, a shell is generically any command line interface, and will likely be an instance of your computer's command line interface (terminal or cmd).
1
1
0
I am new to Python, coming from a MATLAB background. I am using the Anaconda / Spyder 2.2.5 IDE. I am having trouble understanding the terminology used for the development environment. There are "interpreters", "consoles", "kernels", and "shells". Are these all specific entities, or is "interpreter" used interchangeably with "shell"? Can anyone define these for me, and tell me which ones I need to use? I am editing some scripts in the editor, using the python debugger. It seems like the interpreter (shell?) is the window that allows me to interact with my current "variable explorer" workspace.
python Spyder IDE terminology
0.197375
0
0
281
31,456,035
2015-07-16T13:45:00.000
0
0
0
0
python,django,forms
31,518,565
1
true
1
0
If anyone has the same problem here is the solution (to my problem at least): I tried to use the clean_<fieldname> method to change the user entered string to database id. The method wasn't executing because the validation process was stopping earlier because of the difference between the form field and the widget. I redefined the form field to CharField so that step of the validation was working and then the clean_<fieldname> method executes without a problem.
1
1
0
First of all I have tried to research my problem but have not been able to find what I need. My problem might be related to the design of my project (any help would be appreciated). The problem I am facing is as follows: I have a few models I have a model that would be used specifically to create a ModelForm In this model I have ForeignKey field that is represented by default as a select/option input widget in the ModelForm (for each the value attribute is the ForeignKey and text between the tags is the __str__() of the model the ForeignKey points to. The user sees the __str__() and value attribute of the option tag is submitted which is great). So far so good but I want to replace the widget with an input text field so I can implement it as a search field. Now when the user submits the form the string entered in the text input field is submitted and of course django doesn't like that since it expects a foreign key I already can think of a few solutions to the problem and I am sure I can make it work but each of them feels like I would be violating some best practices. So my question is what should I do? Do I exclude this particular field from the ModelForm and implement it as an input text field then after form submission make a query with it's value and then store the ForeignKey to the DB Do I manipulate the data with JavaScript upon submission so that Django receives correct information Can I clean this fields data with Django and transform it from string to FK? Am I going the wrong way with this or there is a Django feature for this type of situation?
Django ForeignKey form field widget
1.2
0
0
1,873
31,456,406
2015-07-16T14:00:00.000
0
0
0
0
python-2.7,openerp,odoo
31,456,810
1
true
1
0
Yes you can, for every class new_class(... with a unique _name="new.class" is created a table in the data base, if you want more than one table, you need to create more than one class in your .py file For more reference look the account module in account_invoice.py you have class account_invoice(models.Model): _name = "account.invoice" and class account_invoice_line(models.Model): _name = "account.invoice.line" for each class are a table in the data base. I Hope this will can help you!
1
0
0
Each module in odoo have a table in the database. I'd like to know if I can create two tables in the odoo database for one module.
Is there any way to create two tables in the database for one odoo module?
1.2
1
0
592
31,457,146
2015-07-16T14:30:00.000
1
0
0
0
javascript,python,flask,jinja2
31,458,066
1
true
1
0
That doesn't make sense! Flask/Jinja can't read from javascript vars. However, (as you said it is a POST request) you could: Three ways: Passing (dynamically modifying DOM link or form action URL) counter var value to POST request URL, like: /path/postaction?counter=4; If it's a POST request from form you could modify form action (see above) or adding a input hidden to form; Setting a cookie and get it in the next request (I don't like this option);
1
0
0
I am working on a little flask project and in my javascript script I have a variable which works as a counter. When I receive a POST request I would like my python script to extract this counter variable. I tried to set a jinja2 variable by doing {%set extractor_var = js_counter%} but it seems to be impossible to use a javascript variable inside a jinja2 template. Can anyone lead me to another solution?
Extract a javascript variable with flask
1.2
0
0
257
31,459,477
2015-07-16T16:15:00.000
0
0
0
0
python,postgresql,sqlalchemy
34,866,070
1
false
0
0
First off, I'd advise against doing 'from import *' that can bring unknown things into your namespace that are quite difficult to debug. Second, the sqlalchemy module simply doesn't have a 'DOUBLE_PRECISION' column type. So the reason it says it's not defined, is because sqlalchemy does not define any such name. Perhaps you are looking for 'Float'?
1
0
0
I am running a migrate script in postgres, and at the top of one of the files I have from sqlalchemy import * in the file I create tables with entries such as 1Column('tmp1', DOUBLE_PRECISION(precision=53)) However, when I run the script I get the error: name 'DOUBLE_PRECISION' is not defined Why is this?
name 'DOUBLE_PRECISION' is not defined - PostgreSQL - SQLAlchemy
0
1
0
622
31,462,392
2015-07-16T18:59:00.000
2
1
1
0
php,python,return
31,463,247
1
false
0
0
You can print your result in JSON format and the exec() function will return the string. This string can be used to retrieve your value using any JSON decoder.
1
1
0
I run a python script from a php script and i want to php take return value from python(return value is a list). I use exec() function for running python. How can i do that? Thx
Take return value from python script from php
0.379949
0
0
361
31,464,191
2015-07-16T20:44:00.000
0
0
0
0
python,wxpython,right-click,wxwidgets,popupmenu
31,477,578
1
true
0
1
As far as I can tell, that is not supported. Besides, no user is going to expect that they need to right click on a context menu anyway. You should rethink your design so it's more intuitive. Perhaps by using a sub-menu instead of a secondary popup menu
1
0
0
I have a wx Popupmenu appear when I left-click on a toolbar LabelTool. I already have a binding to have a handler run when I left click an item in the menu, but I want another popup menu to appear when I right click an item in the original popup menu. I've already tried binding it to wx.EVT_RIGHT_DOWN but it doesn't do it. Whenever I try right clicking on a menu object, it seems it still calls the wx.EVT_MENU, which calls the same handler as a left-click would. How would I implement this?
Have a popupmenu appear on a popupmenu on right-click
1.2
0
0
67
31,464,223
2015-07-16T20:47:00.000
4
0
0
0
python,amazon-web-services,boto
31,464,224
1
false
0
0
ICMP does not have ports in the protocol, unlike TCP. So when making the Boto call, use -1 for the source and destination ports to avoid the above error. AWS considers -1 to be All. Using 0 is also valid, however I haven't verified that it allows all traffic. It should, given that ICMP has no ports in the protocol.
1
1
0
When creating an AWS security group rule for ICMP using Boto, I received the following error. I was specifying the port range as 0 to 65535, which is the way to specify all ports for TCP. ICMP code (65535) out of range (InvalidParameterValue) How do I address this?
Python Boto: ICMP code (65535) out of range (InvalidParameterValue)
0.664037
0
1
840
31,464,366
2015-07-16T20:56:00.000
0
0
0
1
python,web
66,746,290
4
false
0
0
keep the files in a some folder which you want to access from a localhost In command prompt go to that location and type python -m http.server 8080 now type localhost :8080 in browser you will able to access files in that folder if u want to use some js files for paticular html files then <script src="http://localhost:8080/main.js"</script> make sure you run this program on another port
1
3
0
I want to access files in my local machine by using urls. For example "file:///usr/local/home/thapaliya/constants.py". What would be the best way to achieve this?
Access local files from locally running http server
0
0
0
3,484
31,466,493
2015-07-17T00:02:00.000
0
0
0
0
java,http,post,httpclient,python-requests
31,466,587
1
false
0
0
If you try to PUT without any knowledge of the server this request will "fail" (or not - depends on the implementation e.g. it can redirect you to main page). Failure is indicated by the server response code along with headers. E.g. 405 Method Not Allowed or 400 bad request etc. Or redirect you to main page: 302 Found You, as a client, must adapt to the server's API. Moreover different requests to the same API may give you different specs e.g. One response is gzipped & with ETag & cached, the other one is not. Or plain GET / will give you HTML and GET /?format=json will give you JSON.
1
0
0
Please bear with me as I have been reading and trying to understand HTTP and the different requests available in its protocol but there are still a few loose connections here and there. Specifically, I have been using Apache's HttpClient to send requests, but I'm unsure of a few things. When we make a request to a URI, how can we know before hand how to properly format say a PUT request? You might be trying to transmit data to fill out a form, or send an image, etc. How would you know if the server is capable of receiving that format of request?
How to determine how to format an HTTP request to some server
0
0
1
25
31,466,828
2015-07-17T00:48:00.000
0
1
0
0
python,sentry
31,466,945
2
false
1
0
I found it - found even two different ways: I can make projects public (under project settings) so everyone (with a sentry account) can access it. I can give a users access to a project and that user has to opt-out of emails by going to his Account (top right) and then notifications.
2
1
0
Can I give a user access to a sentry project but not send him all the emails? Sometimes I want to forward the error message to our mobile developers, so they can see the parameters, but they don't need to get all the other reports.
Sentry limit notifications to certain users
0
0
0
162
31,466,828
2015-07-17T00:48:00.000
0
1
0
0
python,sentry
31,466,990
2
false
1
0
The best way to deal with this is to make the organization "open membership". Members can then choose to join or leave teams, and opt-out of project-specific notifications when they want.
2
1
0
Can I give a user access to a sentry project but not send him all the emails? Sometimes I want to forward the error message to our mobile developers, so they can see the parameters, but they don't need to get all the other reports.
Sentry limit notifications to certain users
0
0
0
162
31,468,049
2015-07-17T03:41:00.000
1
0
1
0
python,python-2.7,python-3.x,yield-keyword
31,468,079
4
false
0
0
print was a keyword defined by the language specification in Python 2, and became a builtin function (defined by the standard library specification) Python 3. yield was, and still is, a keyword.
1
7
0
In Python, I have many times seen the yield function used to create a generator. Both this and the print function technically both perform the action of methods because they return a value. However, during the change from Python 2 to Python 3, the print function gained parentheses like a normal method call, but yield stayed the same. Also, yield gains a yellowish color of a reserved keyword while print is the purple of a reserved method. Why is yield not considered a method and colored this way along with not using parentheses syntax? (In a similar vein, why does return also lack parentheses?) Let me add some more stuff, yield and continue are not given parentheses in many other languages as well. I just wanted to know what makes it different other than it is reserved. There are many other reserved methods out there which get parentheses.
Why does the yield function not require parentheses in Python?
0.049958
0
0
1,230