Q_CreationDate stringlengths 23 23 | Title stringlengths 11 149 | Question stringlengths 25 6.53k | Answer stringlengths 15 5.1k | Score float64 -1 1.2 | Is_accepted bool 2
classes | N_answers int64 1 17 | Q_Id int64 0 6.76k |
|---|---|---|---|---|---|---|---|
2017-09-23 21:55:03.870 | How can I create a workspace in Visual Studio Code? | I have this very beginner question that I happened to install Visual Studio Code on my Mac, and every time I tried to run a simple Python program on that, it said that I need a workspace to run, so how do I create the workspace? | I am not sure how you try to run this program, but you can just go to menu View → Terminal and type python your_program.py in TERMINAL from the folder where your program is located.
And please check if you have not accidentally installed Visual Studio instead of Visual Studio Code (those are two completely different pr... | 0.386912 | false | 2 | 5,120 |
2017-09-23 21:55:03.870 | How can I create a workspace in Visual Studio Code? | I have this very beginner question that I happened to install Visual Studio Code on my Mac, and every time I tried to run a simple Python program on that, it said that I need a workspace to run, so how do I create the workspace? | VSCode workspaces are basically just folders. If you open an empty folder in VSCode it will get treated as a workspace, and you can add any scripts you want to it. VSCode will create a new hidden folder in the folder you chose that will hold settings for the workspace. For python, make sure you install the python exten... | 0 | false | 2 | 5,120 |
2017-09-24 17:04:20.560 | Generating Random Numbers Under some constraints | I happen to have a list y = [y1, y2, ... yn]. I need to generate random numbers ai such that 0<=ai<=c (for some constant c) and sum of all ai*yi = 0. Can anyone help me out on how to code this in python? Even pseudocode/logic works, I am having a conceptual problem here. While the first constraint is easy to satisfy, I... | If you need random integer values between 0 and c use random.randint(0, c). For random floating point values between 0 anc c use random.uniform(0, c). | 0 | false | 2 | 5,121 |
2017-09-24 17:04:20.560 | Generating Random Numbers Under some constraints | I happen to have a list y = [y1, y2, ... yn]. I need to generate random numbers ai such that 0<=ai<=c (for some constant c) and sum of all ai*yi = 0. Can anyone help me out on how to code this in python? Even pseudocode/logic works, I am having a conceptual problem here. While the first constraint is easy to satisfy, I... | I like splitting this problem up. Note that there must be some positive and some negative values of y (otherwise sum(ai*yi) can't equal zero).
Generate random positive coefficients ai for the negative values of y, and construct the sum of ai*yi over only the negative values of y (let's say this sum is -R).
Assuming ... | 0 | false | 2 | 5,121 |
2017-09-24 21:16:47.430 | Is it possible to analyze mp3 file using music21? | I am looking for python library to find out a key and tempo of the song recorded in MP3 format. I've found the music21 lib that allows doing that. But it seems like it works only with midi files.
Does somebody know how to parse MP3 files using music21 and get the required sound characteristics? If it is impossible, pl... | There are ways of doing this in music21 (audioSearch module) but it's more of a proof of concept and not for production work. There are much better software packages for analyzing audio (try sonic visualizer or jMIR or a commercial package). Music21's strength is in working with scores. | 0.386912 | false | 3 | 5,122 |
2017-09-24 21:16:47.430 | Is it possible to analyze mp3 file using music21? | I am looking for python library to find out a key and tempo of the song recorded in MP3 format. I've found the music21 lib that allows doing that. But it seems like it works only with midi files.
Does somebody know how to parse MP3 files using music21 and get the required sound characteristics? If it is impossible, pl... | No, this is not possible. Music21 can only process data stored in musical notation data formats, like MIDI, MusicXML, and ABC.
Converting a MP3 audio file to notation is a complex task, and isn't something that software can reliably accomplish at this point. | 1.2 | true | 3 | 5,122 |
2017-09-24 21:16:47.430 | Is it possible to analyze mp3 file using music21? | I am looking for python library to find out a key and tempo of the song recorded in MP3 format. I've found the music21 lib that allows doing that. But it seems like it works only with midi files.
Does somebody know how to parse MP3 files using music21 and get the required sound characteristics? If it is impossible, pl... | Check out librosa. It can read mp3s and give some basic info such as tempo. | 0.135221 | false | 3 | 5,122 |
2017-09-25 03:36:23.177 | remove the profile but the camera always be disabled | I have a strange problem at my iphone,
when I remove the mdm profile,
the camera always be disabled, it's not come back , the mdm profile is only one , how to reset it? | Did you remove the Profile from the Device settings or through the Apple Configurator?
Many times even if you remove profile from Device settings, its still there in the Device.
You can see if its still there in the Device using Apple Configurator and try removing it from there. | 1.2 | true | 1 | 5,123 |
2017-09-26 08:29:20.430 | Why does retrieving a single resource execute serializer.to_representation() multiple times in Django REST framework? | Lets say I have a model called Thingy, and there are 20 Thingies in my database. When I retrieve all Thingies, serializer.to_represenatation() is executed 20 times. This is good.
However, when I retrieve just a single Thingy from /api/thingies/1, I observe that serializer.to_representation() is executed four (4!!!) tim... | That's because you are using the browsable API.
JSON renderer will only call it once.
Browsable API needs several calls:
for the result itself
for the raw data tab when you can modify a resource through PUT
for the raw data tab when you can modify a resource through PATCH
for the HTML form tab | 1.2 | true | 1 | 5,124 |
2017-09-26 17:29:43.880 | Pywinauto how do I get the list of returned elements | I'm using a WPF application that has custom stack panel, which is basically a list. The item in the list is exactly the same so I'm not able to select a specific text to uniquely identify the elements. And some other values such as time are dynamic.
Is there a way for me to get the list of elements returned. I know it'... | You can add found_index=0 or other index to the window specification object. This is the first way to disambiguate the search.
Also there are methods .children() and .descendants() with additional params like control_type or title (as I remember title should work), but some window specification params are not supported... | 1.2 | true | 1 | 5,125 |
2017-09-27 09:20:36.523 | Is it possible to write protect old data of JSON Files and only enable appending? | I need to store some date stamped data in a JSON file. It is a sensor output. Each day the same JSON file is updated with the additional data. Now, is it possible to put some write protection on already available data to ensure that only new lines could be added to the document and no manual tampering should occur with... | Write protection normally only exists for complete files. So you could revoke write permissions for the file, but then also appending isn't possible anymore.
For ensuring that no tampering has taken place, the standard way would be to cryptographically sign the data. You can do this like this, in principle:
Take the... | 0 | false | 1 | 5,126 |
2017-09-29 15:39:08.803 | Connecting to an online database through python sqlite3 | I have a question about sqlite3. If I were to host a database online, how would I access it through python's sqlite3 module?
E.g. Assume I had a database hosted at "www.example.com/database.db". Would it be as simple as just forming a connection with sqlite3.connect ("www.example.com/database.db") or is there more I n... | SQLite3 is embedded-only database so it does not have network connection capabilities. You will need to somehow mount the remote filesystem.
With that being said, SQLite3 is not meant for this. Use PostgreSQL or MySQL (or anything else) for such purposes. | 0.545705 | false | 1 | 5,127 |
2017-10-01 19:56:19.773 | How to plot a cluster in python prepared using categorical data | I have a high-dimensional dataset which is categorical in nature and I have used Kmodes to identify clusters, I want to visualize the clusters, what would be the best way to do that? PCA doesn't seem to be a recommended method for dimensionality reduction in a categorical dataset, how to visualize in such a scenario? | Agreeing with @DIMKOIM, Multiple Correspondence Analysis is your best bet. PCA is mainly used for continuous variables. To visualize your data, you can build a scatter plot from scratch. | 0 | false | 1 | 5,128 |
2017-10-03 03:44:38.850 | Tensorflow GPU doesn't work in Pycharm | When i'm running my tensorflow training module in pycharm IDE in Ubuntu 16.04, it doesn't show any training with GPU and it trains usually with CPU. But When i run the same python script using terminal it runs using GPU training. I want to know how to configure GPU training in Pycharm IDE. | Actually the problem was, the python environment for the pycharm project is not the same as which is in run configurations. This issue was fixed by changing the environment in run configurations. | 1.2 | true | 1 | 5,129 |
2017-10-04 10:10:59.720 | How to handle Rest API user authentication securely? | For the last few months i've been working on a Rest API for a web app for the company I work for. The endpoints supply data such as transaction history, user data, and data for support tickets. However, I keep running into one issue that always seems to set me back to some extent.
The issue I seem to keep running into ... | Put an API Gateway in front of your API , your API Gateway is publicly ( i.e in the DMZ ) exposed while the actual API are internal.
You can look into Kong.. | 0 | false | 1 | 5,130 |
2017-10-05 10:31:27.253 | Load portions of matrix into RAM | I'm writing some image processing routines for a micro-controller that supports MicroPython. The bad news is that it only has 0.5 MB of RAM. This means that if I want to work with relatively big images/matrices like 256x256, I need to treat it as a collection of smaller matrices (e.g. 32x32) and perform the operation o... | Sorry, but your question contains the answer - if you need to work with 32x32 tiles, the best format is that which represents your big image as a sequence of tiles (and e.g. not as one big 256x256 image, though reading tiles out of it is also not a rocket science and should be fairly trivial to code in MicroPython, tho... | 0 | false | 1 | 5,131 |
2017-10-05 21:11:53.197 | Populating related table in SqlAlchemy ORM | So I have two table in a one-to-many relationship. When I make a new row of Table1, I want to populate Table2 with the related rows. However, this population actually involves computing the Table2 rows, using data in other related tables.
What's a good way to do that using the ORM layer? That is, assuming that that th... | After asking around in #sqlalchemy IRC, it was pointed out that this could be done using ORM-level relationships in an before_flush event listener.
It was explained that when you add a mapping through a relationship, the foreign key is automatically filled on flush, and the appropriate insert statement generated by the... | 1.2 | true | 1 | 5,132 |
2017-10-06 05:44:44.957 | Beginners python. Best way to store different amount of items for each key? | I'm a beginner at programming (and also an older person), so I don't really know how to express what I want correctly. I've tried to describe my question as thoroughly as possible, so really appreciate your patience!
I would like to store the winning scores associated with each user.
Each user would have different nu... | You can use Dictionary as values in dicts can be mutable like a list where you can keep all the scores/winning scores for each user.
{'player1' : [22,33,44,55],
'player2' : [23,34,45],
.....
}
If this is not an exercise that you will repeat dicts make sense but if it is an exercise that might need to be done again in ... | 0.067922 | false | 2 | 5,133 |
2017-10-06 05:44:44.957 | Beginners python. Best way to store different amount of items for each key? | I'm a beginner at programming (and also an older person), so I don't really know how to express what I want correctly. I've tried to describe my question as thoroughly as possible, so really appreciate your patience!
I would like to store the winning scores associated with each user.
Each user would have different nu... | class is used when there is both state and behavior . dict is used when there's only state. since you have both use class. | 0 | false | 2 | 5,133 |
2017-10-06 07:17:10.657 | Error installing Spyder in anaconda | Tried anaconda today , it seems fine but when I tried to launch Spyder each time I get this error: Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\Scripts\spyder-script.py", line 6, in <module>
from spyder.app.start import main
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\app\start... | The problem is you have two Python versions installed in your system: one in C:\ProgramData\Anaconda3\ and the other in C:\Users\Jaker\AppData\Roaming\Python\Python36.
Please uninstall one of them and the problem will be solved. | 0 | false | 1 | 5,134 |
2017-10-06 12:19:56.843 | I used Update.callback_query after which i used Update.message in same function its not working | update.callback_query.from_user Inside the same function I used
update.message.text
where i tried to get message from user update.message.text is not working giving me 'NoneType' object has no attribute 'text'
how can i use two update in same function | To be exact you can find the message object (or/and the text) of a callback_query at update.callback_query.message.text.
Or for convenience you can always use update.effective_chat, update.effective_message and update.effective_user to access the chat, message and from_user objects wherever they are in (no matter it's ... | 0.386912 | false | 1 | 5,135 |
2017-10-07 13:23:31.923 | How to use random numbers that executes a one dimensional random walk in python? | Start with a one dimensional space of length m, where m = 2 * n + 1. Take a step either to the left or to the right at random, with equal probability. Continue taking random steps until you go off one edge of the space, for which I'm using while 0 <= position < m.
We have to write a program that executes the random wa... | 1 - Start with a list initialized with 5 items (maybe None?)
2 - place the walker at index 2
3 - randomly chose a direction (-1 or + 1)
4 - move the walker in the chosen direction
5 - maybe print the space and mark the location of the walker
6 - repeat at step 3 as many times as needed | 0.386912 | false | 1 | 5,136 |
2017-10-07 14:59:11.577 | django - split project to two servers (due to Cloudflare) without duplicating code | I currently have a Django project running on a server behind Cloudflare. However, a number of the apps contain functionality that requires synchronizing data with certain web services. This is a security risk, because these web services may reveal the IP address of my server. Therefore I need a solution to prevent this... | This sounds like a single project that is being split as part of the deployment strategy. So it makes sense to use just a single codebase for it, rather than splitting it into two projects. If that's the case, re-use is a non-issue since both servers are using the same code.
To support multiple deployments, then, you j... | 1.2 | true | 1 | 5,137 |
2017-10-08 10:52:30.880 | How to python pip install for Python 2.7, having using Python 3.6 before on Windows | I would like to ask about how to use pip install for Python 2.7, when I previously installing for and using Python 3.6 ? (*I now have to versions of Python on Windows)
pip install ... keeps installing for Python 3.6
I need to use the previous version, to rewrite the code in Python 2.7. (this is for building a Kivy ap... | If you have the 2 versions really installed, you should have a pip2 or pip2.x available in your PATH | 1.2 | true | 1 | 5,138 |
2017-10-08 21:13:14.383 | Execute Python script in terminal fullscreen | how do I write/execute a Python script full screen at the terminal.
I want to write a small Programm which shoud be shown like "vim", "sl", or "nano". | As fas as I can understand from your question, you can make the terminal to be fullscreen by pressing F11 (at least in Ubuntu) | 0 | false | 1 | 5,139 |
2017-10-09 09:05:26.840 | Count number of times my code has been called? | I am trying to figure out how to code how many times my main program has been called.
I want to count how many times my program has been called, lets call the program "test". In the program different sub-functions can be called. therefore i want to be able to count those aswell, let's call them "program-1, Program-2 ..... | You can use a variable that will increment when the function calls or stops. | 0 | false | 1 | 5,140 |
2017-10-10 20:49:59.730 | Selenium (Maybe headless) on raspberry pi zero w | i have had a rough time getting my scripts to work on my raspberry pi zero w and the last program i need installed requires selenium. This script was designed for windows 10 + python 2.7 because i make my scripts in this environment.
I was wondering if it is possible to use selenium on a raspberry pi zero w and prefer... | I don't see why you couldn't. You can install pip with apt install python-pip, you'll probably need to sudo that command unless you login as root.
Then you can just open a terminal and use the pip install command to get selenium. If that doesn't work you can try running python -m pip install instead. | 0 | false | 1 | 5,141 |
2017-10-11 13:21:04.010 | How to customize docstring color for Python in VSCode's default theme? | Could some one explain to me please how to customize docstring color for Python in VSCode's default theme? I want to do it thru User Settings because want to be able to save my config file.
I tried to use "editor.tokenColorCustomizations": {} but it affects all strings. | Leonard's answer above is perfect.
Just for the googlers in 2020, I would add that the command in Command Palette: Developer: Inspect TM Scopes seems to have changed to: Developer: Inspect Editor Tokens and Scopes.
This option shows both the standard token types, as well as TextMate scopes. | 0.386912 | false | 1 | 5,142 |
2017-10-11 19:41:23.807 | Pycharm stopped working in remote interpreter | I have been using remote interpreter all the times before, but suddenly it shows failed error message: can't run python interpreter: error connecting to remote host:
I am using SFTP, and I have tried "Test SFTP connection", got success message with the same host.
I am wondering how do I see verbose message in the remo... | Solve the problem. There are two places to edit the same remote interpreter. One is from Default Setting-> Project Interpreter -> Setting Icon -> More -> edit icon, another is from Tools -> Deployment -> Configuration. The settings in both places need to be correct for the same remote interpreter.
For some reason, the ... | 1.2 | true | 1 | 5,143 |
2017-10-12 04:29:56.190 | How to find the number of elements of a float array in python and how to convert it to a 2-dimensional float array? | I am trying to find the length of a 1-D float array and convert it into a 2-d array in python. Also when I am trying to print the elements of the float array the following error is coming:-
'float' object is not iterable | Length of array: len(array). Try to do 2 cycles to spread all values to 2-d array. | 0 | false | 1 | 5,144 |
2017-10-12 11:16:35.900 | Check the data has updated at server without requesting every frame of the game | I have a game where I have to get data from the server (through REST WebService with JSON) but the problem is I don't know when the data will be available on the server. So, I decided to use such a method that hit Server after specific time or on request on every frame of the game. But certainly this is not the right, ... | It is clearly difficult to provide an answer with little details. TL;DR is that it depends on what game you are developing. However, polling is very inefficient for at least three reasons:
The former, as you have already pointed out, it is inefficient because you generate additional workload when there is no need
The ... | 0 | false | 1 | 5,145 |
2017-10-12 16:48:35.643 | Python/SQLAlchemy: How to save huge redshift table to CSV? | Im going to run query that returns a huge table (about 700Mb) from Redshift and save it to CSV using SQLAlchemy and python 2.7 on my local machine (mac pro).
I've never done this with such a huge queries before and obviously there could be some memory and other issues.
My question is what i shall take into account and... | If you don't run much else on that machine then memory should not be an issue. Give it a try. Monitor memory use during the execution. Also use "load" to see what pressure on the system is. | 0 | false | 1 | 5,146 |
2017-10-12 23:12:35.613 | How to use conda/pip install to install packages behind a corporate proxy? | In R I can use
install.packages("pkgName")
to install a new package no problems. But when I tried python and do pip install package it fails with error
Retrying (Retry(total=4, connect=None, read=None, redirect=None,
status=None)) after connection broken by
'NewConnectionError(': Failed to establish a new connect... | Try using the below command on windows command prompt or PowerShell:
pip install --proxy DOMAIN\username:password@proxyserver:port packagename
Replace the DOMAIN, username, password, proxy server and port with values specific to your system. This works for a windows 10 installation authenticated by Active Directory th... | 1.2 | true | 1 | 5,147 |
2017-10-14 08:41:12.810 | when python interpreter loads source file, will it convert file content to unicode in memory? | Say, I have a source file encoded in utf8, when python interpreter loads that source file, will it convert file content to unicode in memory and then try to evaluate source code in unicode?
If I have a string with non ASCII char in it, like
astring = '中文'
and the file is encoded in gbk.
Running that file with python ... | Python source is only plain ASCII, meaning that the actual encoding does not matter except for litteral strings, be them unicode strings or byte strings. Identifiers can use non ascii characters (IMHO it would be a very bad practice), but their meaning is normally internal to the Python interpreter, so the way it reads... | 0 | false | 1 | 5,148 |
2017-10-14 08:53:25.767 | MySQL commit trigger done | I have MySQL database where I'm loading big files which insert more than 190 000 rows. I'm using python script which is doing some stuff and then load data from csv file into mysql execute query and commit.
My question is if I'm sending such a big file, is database ready after commit command or how to trigger when all ... | The COMMIT does not actually return until the data has been... committed... so, yes, once you have committed any transaction, the work from that transaction is entirely done, as far as your application is concerned. | 1.2 | true | 1 | 5,149 |
2017-10-15 20:35:39.390 | How to scrape javascript while using a webpage normally? | I know very little about js and I'm trying to create a program that will get information about a browser based javascript game while I play it. I can't use a webdriver as I will be playing the game at the time.
When I inspect the js on google chrome and look at the console, I can see all the information that I want to... | hacking a game I see. Provided you are aware that what you are doing may diminish the validity of other's playtime as well as potentially committing a crime, I shall provide a solution:
You would need to get a piece of "sniffing" software which allows modifications.
The modifications are likely to be the addition of "Q... | 0 | false | 1 | 5,150 |
2017-10-17 04:53:58.117 | Why is a tuple containing an unhashable type unhashable? | For example, the tuple (1,[0,1,2]). I understand why from a design perspective; if the tuple were still hashable, then it would be trivial to make any unhashable type hashable by wrapping it in a tuple, which breaks the correct behavior of hashability, since you can change the value of the object without changing the h... | tuple implements its own hash by computing and combining the hashes of the values it contains. When hashing one of those values fails, it lets the resulting exception propagate unimpeded.
Being unhashable just means calling hash() on you triggers a TypeError; one way to do that is to not define a __hash__ method, but ... | 1.2 | true | 2 | 5,151 |
2017-10-17 04:53:58.117 | Why is a tuple containing an unhashable type unhashable? | For example, the tuple (1,[0,1,2]). I understand why from a design perspective; if the tuple were still hashable, then it would be trivial to make any unhashable type hashable by wrapping it in a tuple, which breaks the correct behavior of hashability, since you can change the value of the object without changing the h... | I assume that tuple.__hash__() calls hash(item) for each item in the tuple and then XOR's the results together. If one of the items isn't hashable, then that will raise a TypeError that bubbles up to the original caller. | 0.386912 | false | 2 | 5,151 |
2017-10-17 06:23:14.977 | How do I make an app available online? [Python] | I wrote a really simple app in Python for a school project. It is for a skillsharing community that our club is trying to start up. Imagine Venmo, but without any money involved. It's essentially a record of favors done for those in the community.
The users' info is stored as a dictionary within a dictionary of all use... | If I got your idea right then you just want to create python web application.
First, you should check out python WebFrameworks and choose right one for you.
Then you should check how to work with it on your existing web server.
And last but not least (if I didn't forget anything) you should check some info on front-end... | 0.386912 | false | 1 | 5,152 |
2017-10-17 06:26:55.020 | how to give commands to the running instance of maya with mayapy.exe? | I want to create a simple python script which will directly transfer objects from blender to Maya. I created a python script which exports the object from blender to a temp folder. now I want to import that object into Maya without actually going to Maya>file>import. I searched for the solution for a while and found ou... | as suggested by Andrea, I opened the commandPort of maya and connected to it using socket in python script. now i can send commands to maya using that python script as long as the maya commandPort is open. | 1.2 | true | 1 | 5,153 |
2017-10-18 06:09:49.487 | Python - how to get executable program to get the windows file browser to pop up for user to choose an excel file or any other document? | The program would follow the below steps:
Click on executable program made through python
File explorer pops up for user to choose excel file to alter
Choose excel file for executable program to alter
Spits out txt file OR excel spreadsheet with newly altered data to same folder location as the original spreadsheet | Yes this is perfectly doable. I suggest you look at PyQT5 or TkInter for the user interface, pyexcel for the excel interface and pyinstaller for packaging up an executable as you asked. There are many great tutorials on all of these modules. | 1.2 | true | 1 | 5,154 |
2017-10-18 18:37:55.697 | Bokeh Plots Axis Value don't show completely | I have just started exploring bokeh and here is a small issue I am stuck with. This is in regards with live graphs.
The problem is with the axis values. Initially if I start with say 10, till 90 it shows correct values but while printing 100, it only show 10 and the last zero(0) is hidden. It's not visible.
That is wh... | This is a known bug with current versions (around 0.12.10) for now the best workaround is to increase plot.min_border (or p.min_border_left, etc) to be able to accommodate whatever the longest label you expect is. Or to rotate the labels to be parallel to the axis so that they always take up the same space, e.g. p.yaxi... | 1.2 | true | 1 | 5,155 |
2017-10-20 01:26:31.517 | Data Periodicity - How to normalize? | I have a data set which contains 12 years of weather data. For first 10 years, the data was recorded per day. For last two years, it is now being recorded per week. I want to use this data in Python Pandas for analysis but I am little lost on how to normalize this for use.
My thoughts
Convert first 10 years data also ... | First, you need to define what output you need, then, deduce how to treat the input to get the desired output.
Regarding daily data for the first 10 years, it could be a possible option to keep only one day per week. Sub-sampling does not always mean loosing information, and does not always change the final result. It ... | 0 | false | 1 | 5,156 |
2017-10-20 18:32:04.647 | How to find if english words exist in string | I am trying to parse some web domains (tens of thousands) to see if they contain any English words.
It is easy for me to parse the domains to grab the main part of the domain with tldextract and then I tried to use enchant to see if they exist in the English dictionary.
The problem is I do not know how to split the do... | Unless you need to do that in a hurry, you could just chip off letters from the beginning or the end of the string, and check if it's a known word; if it is, cut it off and repeat. With e.g. 50k words 20 letters each, at worst you'll do 1M lookups. With a lookup taking e.g. 5ms (hitting an HDD every time), it will take... | 0 | false | 1 | 5,157 |
2017-10-21 06:34:27.033 | What is the difference between os.system("timeout 1") and time.sleep(1)? Python | What is the difference between os.system("timeout 1") and time.sleep(1) in Python? I know the first one will call out the command line and let it do the timeout, but not sure how the second one make the system idle.
Also, which one can save more CPU power or make less memory occupied?
Thanks!! | Efficient way is using time.sleep.
Second method is just sleeping (idle) the process for it's own for 1 second. It doesn't use any other resources more that itself.
First method is making an another process, which takes more memory space, CPU, etc., and waiting to end (os.system's behavior). Luckily the another process... | 1.2 | true | 1 | 5,158 |
2017-10-21 14:48:32.237 | Delete trigger on a AWS Lambda function in python | I have a lambda function and for that lambda function my cloudwatch event is a trigger on it...
at the end of the lambda function i need to delete the trigger (cloud watch event ) on that lambda function programatically using python .
how can i do that ? is there any python library to do that? | Came across the same issue and found the solution. What you want is remove_permission() on the lambda client | 0.135221 | false | 1 | 5,159 |
2017-10-21 19:36:22.533 | Python len function on list with embedded sublists and strings | I have a list called movies with two sublists embedded it. Do the sublists have names too? I want to use len() BIF to measure all items in the list and sublists, how do I do that? | U can use the len() function by specifying the inner sublists
movies = [ [list1] , [list2] ] ;
print(len(movies[0])); # prints length of 1st sublist
print(len(movies[1])); #prints length of second sublist | 0.101688 | false | 1 | 5,160 |
2017-10-22 07:59:18.353 | how to connect a programmed raspberry pi to a Kaa platform? | I have some sensor nodes. they are connected to a Raspberry Pi 2 and send data on it. the data on Raspberry Pi is sending the data to Thingspeak.com and it shows the data from sensor nodes.
now I am developing a Kaa server and wanna see my data (from Raspberry Pi) on Kaa. is there any chance to connect the current pro... | Mashid. From what I know, to use a KAA server, you should utilize the SDK obtained when you create a new application on the KAA server. This SDK also functions as an API key that will connect the device with a KAA server (on a KAA server named with Application Token). The platforms provided for using this SDK are C, C ... | 0 | false | 1 | 5,161 |
2017-10-22 20:16:16.990 | How to get Dev C++ to find Python.h | I'm using Dev C++. Include Python.h doesnt work, and IDE states it cant find the file or directory. I can pull up the Python.h C file, so I know I have it. How do I connect two-and-two? I imagine I have to tell my IDE where the file path is, but how would I do that? | check that in dev-C++ tools > compiler options > directories > c includes and c++ includes have the path to where your Python.h is. | 1.2 | true | 1 | 5,162 |
2017-10-23 20:40:24.267 | Google Foobar: Free the Bunny Prisoners clarification | I'm working my way through Google Foobar and I'm very confused about "Free the Bunny Prisoners". I'm not looking for code, but I could use some insight from anyone that's completed it. First, the problem:
Free the Bunny Prisoners
You need to free the bunny prisoners before Commander Lambda's space
station explodes... | I think you missed the part where it says
but no group of (num_required - 1) bunnies can.
I can explain my solution further, but I will ruin the fun. (I'm the owner of that repo).
Let's try it with your answer.
[[0], [0, 1, 2], [0, 1, 2], [1], [2]]
Your consoles are 3. Bunny 2 can open it on its own, Bunny 3 can open ... | 1.2 | true | 1 | 5,163 |
2017-10-24 16:20:30.877 | Remove clearly and reinstall python on CentOS | Today I messed up the versions of Python on my CentOS machine. Even yum cannot work properly. I made the mistake that I removed the default /usr/bin/python which led to this situation. How could I get back a clear Python environment? I thought remove them totally and reinstall Python may work, but do not know how to do... | To install Python on CentOS: sudo yum install python2/3 (select the version as per requirement)
To uninstall Python on CentOS: sudo yum remove python2/3 (select the version as per your requirement)
To check version for python3(which you installed): python3 --version
To check version for python2 (which you installed): p... | -0.201295 | false | 1 | 5,164 |
2017-10-24 19:32:33.710 | Bluepy Installation Error | I am trying to install bluepy 1.0.5. However, I get receiving error below. Any idea how can i solve it? (I am using Mac OS X El Capitan)
40:449: execution error: The directory '/Users/isozyesil/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please ch... | What part of the diagnostic message did you find unclear?
Did you consider ensuring writable self-owned files by doing sudo chown -R isozyesil /Users/isozyesil/Library/Caches/pip ?
Did you consider sudo pip install bluepy ? | 0 | false | 1 | 5,165 |
2017-10-25 08:26:33.650 | uwsgi application stops with error when running it with multi thread | I am running a uwsgi application on my linux mint. it has does work with a database and shows it on my localhost. i run it on 127.0.0.1 IP and 8080 port. after that i want to test its performance by ab(apache benchmark).
when i run the app by command uwsgi --socket 0.0.0.0:8080 --protocol=http -w wsgi and get test of i... | it has solved.
the point is that you should create separate connection for each completely separate query to avoid missing data during each query execution | 0 | false | 1 | 5,166 |
2017-10-25 19:01:31.963 | Is there a name for Python literals? The way JavaScript literals are called JSON? | I have a program that can output results either as JSON or Python data structure literals. I am wondering how to succinctly name the latter option. | JavaScript literals are not called JSON. JSON derived its name and syntax from JavaScript, but they’re not the same thing. Use “Python literals”. | 0.673066 | false | 1 | 5,167 |
2017-10-25 19:37:33.277 | Telegram Bot API InlineQueryResultAudio | Okay i can send audio with some url in inline mode. But how can i send the local audio from the directory? Telegram Bot API return me this:
A request to the Telegram API was unsuccessful. The server returned
HTTP 400 Bad Request. Response body:
[b'{"ok":false,"error_code":400,"description":"Bad Request:
CONTENT_... | InlineQueryResultAudio only accepts links while InlineQueryResultCachedAudio only accepts file_id. What you can do is post the files to your own server or upload it elsewhere to use the former one, or use SendAudio to get the file_id of it and use the latter one. | 0 | false | 1 | 5,168 |
2017-10-25 20:00:43.330 | Overriding Django admin vs creating new templates/views | I am a total noob with Django, I come from the PHP world and I am used to doing things differently.
I'm building an app and I want to change the way the backend looks, I want to use Bootstrap 4 and add a lot of custom stuff e.g. permission based admin views, and I was wondering what is the best practice, or how do more... | Django admin is intended for administration purposes. For all intents and purposes it is a direct interface to your database. While I have seen some people building customer facing interfaces using admin, this is most definitely not the way to make a general Django web application.
You should define views for your mode... | 1.2 | true | 2 | 5,169 |
2017-10-25 20:00:43.330 | Overriding Django admin vs creating new templates/views | I am a total noob with Django, I come from the PHP world and I am used to doing things differently.
I'm building an app and I want to change the way the backend looks, I want to use Bootstrap 4 and add a lot of custom stuff e.g. permission based admin views, and I was wondering what is the best practice, or how do more... | Yes. The admin pages is actually for administering the webpage. For user login and registration you create the templates. However, if you want your backend to look different then you can tweak the template for the admin page, admin login page as well. And you can also have permission based admin views. It's okay to ove... | 0 | false | 2 | 5,169 |
2017-10-29 08:29:36.633 | Logistic Regression- Working with categorical variable in Python? | I have a dataset that includes 7 different covariates and an output variable, the 'success rate'.
I'm trying to find the important factors that predict the success rate. One of the covariates in my dataset is a categorical variable that takes on 700 values (0- 700), each representing the ID of the district they're fro... | You can apply grouping and then do logistic regression on each group. Or you treat it as multilabel classifier and do "Softmax regression". | 0.386912 | false | 1 | 5,170 |
2017-10-29 11:24:49.163 | Random element in fitness function genetic algorithm | So I am using a genetic algorithm to train a feedforward neural network, tasked with recognizing a function given to the genetic algorithm. I.e x = x**2 or something more complicated obviously.
I realized I am using random inputs in my fitness function, which causes the fitness to be somewhat random for a member of the... | Normally you use a seed for genetic algorithms, which should be fixed. It will always generate the same "random" childs sequentially, which makes your approach reproducible. So the genetic algorithm is kind of pseudo-random. That is state of art how to perform genetic algorithms. | -0.201295 | false | 1 | 5,171 |
2017-10-30 06:51:59.987 | how to let files in pycharm see different ones? | Suppose we have a directory: main that includes:
directory_1
file_1.py
directory_2
file_2.py
If the main code is inside file_1.py, how can I import file_2.py?
If it helps, I am using pycharm. | just simply add __init__.py to each directory (dir_1 and dir_2).
Note that you don't need to write anything to 2 of __init__.py, it's fine to just leave it blank. | 0 | false | 1 | 5,172 |
2017-10-30 09:01:52.047 | How to iterate over a XPath in HTML format using lxml and python? | I want to iterate //span[@class="postNum and contains(text(),1)] This xpath over the range of 1 to 10 and store it in a variable. I want it to be done in HTML format and not XML.
pseudo code:
for e in range(1,11):
xpathvar[e]='//span[@class="postNum and contains(text(),e)]'
how to implement this so that xpathvar[1... | I solved it myself. What I wanted to do was with using slice, I wanted to traverse to all xpath using iteration where the iterative will be in digits coming from for loop. | 0 | false | 1 | 5,173 |
2017-10-30 19:46:35.310 | Can't seem to fetch from GitHub repository in PyCharm | Fetch failed: Unable to find remote helper for 'https'
When I tried to fetch on PyCharm from my GitHub repository, the above is the message I ended up getting. I was wondering how I could fix this. | This may seems like an overkill way of handling the problem but I have fixed it myself by re-installing git on my machine. It seems to actually be the fix for this. Another thing you could do is try git-bash (Git for Windows app) in the future. | 1.2 | true | 1 | 5,174 |
2017-10-30 21:05:43.870 | Add product.product fields to product.template view - Odoo v8 | I'm trying to add new product.product fields to the default product.template view, problem is, that I've tried many examples, but none seems to be working.
The issue is that I do have added these fields to the product.product default view, (as an inherit view) BUT, that view is only available on sales module, the vast ... | You should add those fields to product.template model and then they will be automatically added to product.product by the inheritance. This way you will be able to show the fields in product.template views.
I do not know what is the exact problem that you are trying to solve but when you need to add a field to a produc... | 1.2 | true | 1 | 5,175 |
2017-10-31 07:37:09.760 | GSM 900D Module Limit for Text Messages Sending & Receiving | I have a GSM Modem SIM 900D. I am using it with my server and Python code to send and receive messages. I want to know how many Text SMS I could send and receive through this GSM modem per minute. | If you consider all protocols involved, including radio part, 300+ messages across a good dozen of protocols would have to be sent in order to deliver outgoing SMS to SMSC, and a great deal of waiting and synchronization will have to be involved. This (high overhead) will be your limiting factor and you would probably ... | 1.2 | true | 1 | 5,176 |
2017-10-31 14:42:28.753 | Save data as a *.dat file? | I am writing a program in Python which should import *.dat files, subtract a specific value from certain columns and subsequently save the file in *.dat format in a different directory.
My current tactic is to load the datafiles in a numpy array, perform the calculation and then save it. I am stuck with the saving par... | Correct me if I'm wrong, but opening, writing to, and subsequently closing a file should count as "saving" it. You can test this yourself by running your import script and comparing the last modified dates. | 0 | false | 1 | 5,177 |
2017-10-31 14:52:48.697 | Where to store payment gateway secret key when using python Django with apache server hosted on aws ec2 Ubuntu | Where to store payment gateway secret key when using python Django with apache server?
I don't what to store in settings.py as i will checking this file in my git.
Can i do it the same way amazon store AWS ec2 keys. If possible how to do it. | You can set secrets in environment variables and get them in python code as password = os.getenv('ENVNAME'). | 1.2 | true | 1 | 5,178 |
2017-10-31 20:54:29.743 | Basic-Auth session using python script | I am creating python script to configure router settings remotely but recently stumbled on problem how to logout or close session after job is done?
From searching I found that Basic-Authentication doesn´t have option to logout. How to solve it in python script? | with python requests you can open your session, do your job, then logout with:
r = requests.get('logouturl', params={...})
the logout action is just an http Get method. | 0 | false | 2 | 5,179 |
2017-10-31 20:54:29.743 | Basic-Auth session using python script | I am creating python script to configure router settings remotely but recently stumbled on problem how to logout or close session after job is done?
From searching I found that Basic-Authentication doesn´t have option to logout. How to solve it in python script? | Basic auth doesn't have a concept of a logout but your router's page should have some implementation. If not, perhaps it has a timeout and you just leave it.
Since you're using the requests module it may be difficult to do an actual logout if there is no endpoint or parameter for it. I think the best one can do at tha... | 1.2 | true | 2 | 5,179 |
2017-11-01 04:30:58.390 | jupyterlab - change styling - font, font size | I recently updated to the most recent version of JupyterLab (0.28.12). I'm on Windows.
I've tried adjusting the variables.css file located in \Lib\site-packages\jupyterlab\themes\@jupyterlab\theme-light-extension of my Miniconda/Anaconda folder. I mainly want to change the font family and size, which I've tried using ... | You should change the font size in the website. It should be at Settings->Fonts->Code->Size for code editor and Settings->Fonts->Content->Size for main contents
The css file should be <prefix>/share/jupyter/lab/themes/@jupyterlab/<your theme>/index.css.
To change the font, find all the place in the css file which looks... | 0 | false | 2 | 5,180 |
2017-11-01 04:30:58.390 | jupyterlab - change styling - font, font size | I recently updated to the most recent version of JupyterLab (0.28.12). I'm on Windows.
I've tried adjusting the variables.css file located in \Lib\site-packages\jupyterlab\themes\@jupyterlab\theme-light-extension of my Miniconda/Anaconda folder. I mainly want to change the font family and size, which I've tried using ... | It is now possible to change the font sizes of most elements of the interface via the Settings menu .e.g: Settings->JupyterLab Theme->Increase Code Font Size etc.
Note: These do not change if View->Presentation Mode is ticked.
To change the font style one still needs to go to Settings->Advanced Settings Editor (as ment... | 0.3154 | false | 2 | 5,180 |
2017-11-01 14:18:46.820 | VSCode starts up when I use ".py" extension with CMD commands | I don't know when and how it started but now I have such a glitch:
open CMD
enter python command: "django-admin.py help"
Visual Studio Code starts up and opens manage.py for editing.
The CMD command itself does not return anything.
on the other hand, if I enter: "django-admin help" (without .py)
the CMD shows help and... | It also happened to me, i tried creating a django project using django-admin.py startproject example, I asked around and i found out that the django-admin.py does not work on vscode for windows (am not really sure about mac), vscode sees it as a file and not as a command, cause vscode doesnt need the .py extension to e... | 0.201295 | false | 1 | 5,181 |
2017-11-02 15:50:48.697 | Adding path to pythonpath in dockerbuild file | Using dockerbuild file, how can I do there something like:
export PYTHONPATH=/:$PYTHONPATH
using RUN directive or other option | In your Dockerfile, either of these should work:
Use the ENV instruction (ENV PYTHONPATH="/:$PYTHONPATH")
Use a prefix during the RUN instruction (RUN export PYTHONPATH=/:$PYTHONPATH && <do something>)
The former will persist the changes across layers. The latter will take effect in that layer/RUN command | 1.2 | true | 1 | 5,182 |
2017-11-02 16:39:30.027 | Append an element to a list and del/pop/remove it after a a specific amount of time has passed since it was appended | I'm building an experiment in Psychopy in which, depending on the participants response, I append an element to a list. I'd need to remove/pop/del it after a specific amount of time has passed after it was appended (e.g. 10 seconds). I was considering creating a clock to each element added, but as I need to give a name... | I would take a slightly different approach: I would wrap the items you're inserting into the list with a thin object that has a timestamp field.
Then I'd just leave it there, and when you iterate the list to find an object to pop - check the timestamp first and if it's bigger than 10 seconds, discard it. Do it iterativ... | 0.995055 | false | 1 | 5,183 |
2017-11-02 18:58:32.550 | Managing multiple Python versions on OSX | What's the best way to manage multiple Python installations (long-term) if I've already installed Python 3 via brew? In the past Python versions were installed here, there, and everywhere, because I used different tools to install various updates. As you can imagine, this eventually became a problem.
I once was in a si... | I agree to using virtualenv, it allows you to manage different python versions separately for different projects and clients.
This basically allows you to have each project it's own dependencies which are isolated from others. | 0 | false | 2 | 5,184 |
2017-11-02 18:58:32.550 | Managing multiple Python versions on OSX | What's the best way to manage multiple Python installations (long-term) if I've already installed Python 3 via brew? In the past Python versions were installed here, there, and everywhere, because I used different tools to install various updates. As you can imagine, this eventually became a problem.
I once was in a si... | Use virtualenvs to reduce package clash between independent projects. After activating the venv use pip to install packages. This way each project has an independent view of the package space.
I use brew to install both Python 2.7 and 3.6. The venv utility from each of these will build a 2 or 3 venv respectively.
I ... | 1.2 | true | 2 | 5,184 |
2017-11-03 12:44:11.697 | How to protect my Python code before distribution? | I have written a python code which takes an input data file, performs some processing on the data and writes another data file as output.
I should distribute my code now but the users should not see the source code but be able to just giving the input and getting the output!
I have never done this before.
I would app... | One other option, of course, is to expose the functionality over the web, so that the user can interact through the browser without ever having access to the actual code. | 0.101688 | false | 1 | 5,185 |
2017-11-03 18:10:38.250 | Getting data from a uri django | I have a django view that takes in a json object and from that object I am able to get a uri. The uri contains an xml object. What I want to do is get the data from the xml object but I am not sure how to do this. I'm using django rest, which I am fairly inexperienced in using, but I do not know the uri until I search ... | You don't really do this in view part of Django.
What you should do is take the json, find the uri, get the content of uri through urllib, requests etc, get the relevant content from the response, add a new field to the json and then pass it to your view. | 0 | false | 1 | 5,186 |
2017-11-03 21:56:20.427 | google-cloud-storage distribution not found despite being installed in venv | As in the title, when running the appserver I get a DistributionNotFound exception for google-cloud-storage:
File "/home/[me]/Desktop/apollo/lib/pkg_resources/init.py", line 867, in resolve
raise DistributionNotFound(req, requirers)
DistributionNotFound: The 'google-cloud-storage' distribution was not found an... | The solution for me was that both google-cloud-storage and pkg_resources need to be in the same directory.
It sounds like your google-cloud-storage is in venv and your pkg_resources is in the lib folder | 0 | false | 1 | 5,187 |
2017-11-04 09:36:40.570 | how can i make anaconda spyder code completion work again after installing tensorflow | I am data scientist in beijing and working with anaconda in win7
but after I pip installed tensorflow v1.4,code completion of my IDE spyder in anaconda not work, before anything of code completion function is work perfectly.
Now even I uninstall tensorflow,code completion function of spyder still not work. Any help?
m... | I try pip rope_py3k、jedi and readline, and reset the set of tool, but all are not useful.
and my Spyder code editing area also can not be automatically completed after the installation of tensorflow, I have re-installed again and found the same problem.
However,when I re-installed all envs except tensorflow,it can work... | 0 | false | 2 | 5,188 |
2017-11-04 09:36:40.570 | how can i make anaconda spyder code completion work again after installing tensorflow | I am data scientist in beijing and working with anaconda in win7
but after I pip installed tensorflow v1.4,code completion of my IDE spyder in anaconda not work, before anything of code completion function is work perfectly.
Now even I uninstall tensorflow,code completion function of spyder still not work. Any help?
m... | Now that I have to use a temporary alternative, I installed anaconda version without an installed tensorflow in anaconda's envs. And I use it when I don't use tensorflow. I hope this question can be complement answered, please attent my answer. | 0 | false | 2 | 5,188 |
2017-11-05 00:06:55.490 | Python flask.ext.mysql is deprecated? | When I run from flask.ext.mysql import MySQL I get the warning Importing flask.ext.mysql is deprecated, use flask_mysql instead.
So I installed flask_mysql using pip install flask_mysql,installed it successfully but then when I run from flask_mysql import MySQL I get the error No module named flask_mysql. In the first... | flask.ext. is a deprecated pattern which was used prevalently in older extensions and tutorials. The warning is telling you to replace it with the direct import, which it guesses to be flask_mysql. However, Flask-MySQL is using an even more outdated pattern, flaskext.. There is nothing you can do about that besides con... | 1.2 | true | 1 | 5,189 |
2017-11-06 23:13:02.097 | Filter Pandas Dataframe using an arbitrary number of conditions | I am comfortable with basic filtering and querying using Pandas. For example, if I have a dataframe called df I can do df[df['field1'] < 2] or df[df['field2'] < 3]. I can also chain multiple criteria together, for example:
df[(df['field1'] < 3) & (df['field2'] < 2)].
What if I don't know in advance how many criteria I ... | I believe that reduce( (lambda x, y: x & (df[y[0]]<y[1])), list_of_filters ) will do it. | 0 | false | 1 | 5,190 |
2017-11-07 01:23:06.780 | questions about using pymongo to insert date and time into mongo | I want to insert date and time into mongo ,using pymongo.
However, I can insert datetime but not just date or time .
here is the example code :
now = datetime.datetime.now()
log_date = now.date()
log_time = now.time()
self.logs['test'].insert({'log_date_time': now, 'log_date':log_date, 'log_time':log_time})
it show err... | You are experiencing the defined behavior. MongoDB has a single datetime type (datetime). There are no separate, discrete types of just date or just time.
Workarounds: Plenty, but food for thought:
Storing just date is straightforward: assume Z time, use a time component of 00:00:00, and ignore the time offset upo... | 0 | false | 1 | 5,191 |
2017-11-07 14:39:27.390 | Sitemap creation with Scrapy | Is it possible to use Scrapy to generate a sitemap of a website including the URL of each page and its level/depth (the number of links I need to follow from the home page to get there)? The format of the sitemap doesn't have to be XML, it's just about the information. Furthermore I'd like to save the complete HTML sou... | Yes, it's possible to do what you're trying with Scrapy's LinkExtractor library. This will help you document the URLs for all of the pages on your site.
Once this is done, you can iterate through the URLs and the source (HTML) for each page using the urllib Python library.
Then you can use RegEx to find whatever patt... | -0.386912 | false | 1 | 5,192 |
2017-11-07 19:49:38.727 | How does Postges Server know to keep a database connection open | I wonder how does Postgres sever determine to close a DB connection, if I forgot at the Python source code side.
Does the Postgres server send a ping to the source code? From my understanding, this is not possible. | When your script quits your connection will close and the server will clean it up accordingly. Likewise, it's often the case in garbage collected languages like Python that when you stop using the connection and it falls out of scope it will be closed and cleaned up.
It is possible to write code that never releases the... | 0.386912 | false | 1 | 5,193 |
2017-11-07 23:21:19.743 | Parameter vs Argument Python | So I'm still pretty new to Python and I am still confused about using a parameter vs an argument. For example, how would I write a function that accepts a string as an argument? | A parameter is the placeholder; an argument is what holds the place.
Parameters are conceptual; arguments are actual.
Parameters are the function-call signatures defined at compile-time; Arguments are the values passed at run-time.
Mnemonic: "Pee" for Placeholder Parameters, "Aeigh" for Actual Arguments. | 0 | false | 1 | 5,194 |
2017-11-08 06:45:05.677 | How to implement a connection pool in web application like django? | The purpose is to implement a pool like database connection pool in my web application. My application is write by Django.
The problem is that every time a http request come, my code will be loaded and run through. So if I write some code to initiate a pool. These code will be run per http request. And the pool will b... | Your understanding of how things work is wrong, unfortunately. The way Django runs is very much dependent on the way you are deploying it, but in almost all circumstances it does not load code or initiate globals on every request. Certainly, uWSGI does not behave that way; it runs a set of long-lived workers that persi... | 0 | false | 1 | 5,195 |
2017-11-09 03:02:41.053 | AttributeError: 'module' object has no attribute 'SubscriberClient' | After running sudo pip install google.cloud.pubsub
I am running the following python code in ubtunu google compute engine:
import google.cloud.pubsub_v1
I get the following error when importing this:
ImportError: No module named pubsub_v1 attribute 'SubscriberClient'
Can anyone tell me how to fix this? | Update your google-cloud-pubsub to the latest version. It should resolve the issue | 0.386912 | false | 1 | 5,196 |
2017-11-10 22:15:14.747 | Race Conditions with asyncio | I'm new to asyncio and I was wondering how you prevent race conditions from occuring. I don't see implementation for locks - is there a different way this is handled? | asyncio only runs one coroutine at a time and only switches at points you define, so race conditions aren't really a thing. Since you're not worried about race conditions, you're not really worried about locks (although technically you could still get into a deadlock situation if you have 2 coroutines that wake each o... | 1.2 | true | 1 | 5,197 |
2017-11-12 18:32:11.580 | WSL python3 ModuleNotFoundError: No module named xxx | I am using python 3.6.2 on WSL (Windows Linux subsystem) and trying to set tensorflow environment (and installing some other libraries as well). However, i always get an error when I exit and login again:
ModuleNotFoundError: No module named 'tensorflow'
So I have to reinstall the libraries again and the problem will b... | Well, since no one is answering this question, I have to close the question. What I did to overcome the issue was just to uninstall the whole WSL and reinstall it. | 1.2 | true | 1 | 5,198 |
2017-11-13 17:42:13.033 | How can you write/delete/read a file in a different user account with the same ip address with python? | Recently, I learnt how to write/delete/read a file in Python (I am a beginner). However, something has got me thinking: is it possible to write/delete/read a file in a different user account from the same network (i.e same ip address)? If so, how? Don't worry, I'll just try it at home. ;) | This is running into more of an OS question. The answer is if you have permission to do so then yes you can but if you do not have permissions over the file then you cannot. | 0 | false | 2 | 5,199 |
2017-11-13 17:42:13.033 | How can you write/delete/read a file in a different user account with the same ip address with python? | Recently, I learnt how to write/delete/read a file in Python (I am a beginner). However, something has got me thinking: is it possible to write/delete/read a file in a different user account from the same network (i.e same ip address)? If so, how? Don't worry, I'll just try it at home. ;) | If you can remove the file without Python, then you can remove it with Python. Otherwise, the answer is "no". | 0 | false | 2 | 5,199 |
2017-11-14 03:49:07.433 | cv2 running optical flow on particular rectangles | I am using OpenCV's Optical Flow module. I understand the examples in the documentation but those take the entire image and then get the optical flow over the image.
I only want to pass it over some parts of an image. Is it possible to do that? If yes, how do I go about it?
Thanks! | Yes, it's possible. cv2.calcOpticalFlowPyrLK() will be the optical flow function you need. Before you make that function call, you will have to create an image mask. I did a similar project, but in C++, though I can outline the steps for you:
Create an empty matrix with same width and height of your images
Using the p... | 0 | false | 1 | 5,200 |
2017-11-14 15:24:36.950 | AWS CLI not working in Cygwin | I am working on a Windows computer and have been using Git Bash up until now without a problem. However, Git Bash seems to be missing some commands that Cygwin can provide, so I switched to Cygwin.
I need to use AWS CLI with Cygwin but any time I input any aws command, I get the following error:
C:\users\myusername\ap... | You are mixing cygwin posix path with with a not cygwin Python.
C:\users\myusername\appdata\local\programs\python\python36\python.exe
Is not the cygwin python so it can't open the file as
/cygdrive/c/Users/myusername/AppData/Local/Programs/Python/Python36/Scripts/aws is not a windows path that it can understand . Onl... | 0 | false | 2 | 5,201 |
2017-11-14 15:24:36.950 | AWS CLI not working in Cygwin | I am working on a Windows computer and have been using Git Bash up until now without a problem. However, Git Bash seems to be missing some commands that Cygwin can provide, so I switched to Cygwin.
I need to use AWS CLI with Cygwin but any time I input any aws command, I get the following error:
C:\users\myusername\ap... | Ok, so I spent ages trying to do this as well because I wanted to get setup on the fast.ai course. Nothing seemed to work. However, I uninstalled Anaconda3 and installed Anaconda2 instead. That did the trick! | 0 | false | 2 | 5,201 |
2017-11-14 16:09:24.473 | How can I set Anaconda3 python my default on windows | I have anaconda 3 with python 3 that works perfectly in anaconda prompt but I want to make anaconda python my default python. file names 'python.exe' is located at 'C:\ProgramData\Anaconda3\python.exe' but when I go to PATH Variables there's no file named python in Anaconda3 folder. Any suggestions on how to do it? | C:\ProgramData\Anaconda3;C:\ProgramData\Anaconda3\Scripts;C:\ProgramData\Anaconda3\Library\bin;
These three settings should be set automatically in the path folder by Anaconda? If not done automatically, put them at the very beginning of the list. | 1.2 | true | 1 | 5,202 |
2017-11-15 04:34:22.757 | Maximum Limit of distinct fake data using Python Faker package | I have used Python Faker for generating fake data. But I need to know what is the maximum number of distinct fake data (eg: fake names) can be generated using faker (eg: fake.name() ).
I have generated 100,000 fake names and I got less than 76,000 distinct names. I need to know the maximum limit so that I can know how ... | I had this same issue and looked more into it.
In the en_US provider there about 1000 last names and 750 first names for about 750000 unique combos. If you randomly select a first and last name, there is a chance you'll get duplicates. But in reality, that's how the real world works, there are many John Smiths and Robe... | 1.2 | true | 1 | 5,203 |
2017-11-15 07:28:23.303 | different result 22/7 on python 2.7.12 and 3.6 | how to make output 22//7 on python 2.7 become 3.14159 ?i try use float(22/7) but it just give me 3.0. I try use Decimal but it just give me 3, use round(x, 6) only give 3.0 just like float. | Here, int/int will return int only that is what happening here 22/7 gives 3 and you're type casting it to float(3) which is giving 3.0 but if you will perform float/int or int/float then it will result into float so you convert any of them to float as shown following.
replace float(22/7) with float(22)/7 | 1.2 | true | 1 | 5,204 |
2017-11-16 08:07:59.413 | Learners in CNTK C# API | I am using C# CNTK 2.2.0 API for training.
I have installed Nuget package CNTK.CPUOnly and CNTK.GPU.
I am looking for following learners in C#.
1. AdaDelta
2. Adam
3. AdaGrad
4. Neterov
Looks like Python supports these learners but C#
package is not showing them.
I can see only SGD and SGDMomentun learners in C# there.... | Download the NCCL 2 app to configure in c# www.nvidia. com or google NCCL download | 0 | false | 2 | 5,205 |
2017-11-16 08:07:59.413 | Learners in CNTK C# API | I am using C# CNTK 2.2.0 API for training.
I have installed Nuget package CNTK.CPUOnly and CNTK.GPU.
I am looking for following learners in C#.
1. AdaDelta
2. Adam
3. AdaGrad
4. Neterov
Looks like Python supports these learners but C#
package is not showing them.
I can see only SGD and SGDMomentun learners in C# there.... | Checked that CNTKLib is providing those learners in CPUOnly package.
Nestrov is missing in there but present in python.
There is a difference while creating the trainer object
with CNTKLib learner function vs Learner class.
If a learner class is used,
net parameters are provided as a IList.
This can be obtained using... | 0 | false | 2 | 5,205 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.