Q_CreationDate,Title,Question,Answer,Score,Is_accepted,N_answers,Q_Id 2021-01-05 16:52:24.587,How can I run my Python Script in Siteground Hosting Server,"I am building my website which contains a python(.py) file, html, css and JS file. I want to know that how can I run my python script in siteground from my hosting account so that it can scrape data from a site and output a JSON file to Javascript file which can display it on the webpage.",I would use cron jobs to run jobs in the foreground,0.0,False,1,7215 2021-01-07 07:21:30.950,"Iterate through a string forwards and backwards, extracting alternating characters","I'm studying python and there's a lab I can't seem to crack. We have a line e.g. shacnidw, that has to be transformed to sandwich. I somehow need to iterate with a for loop and pick the letters with odd indexes first, followed by backward even indexes. Like pick a letter with index 1,3,5,7,8,6,4,2. It looks pretty obvious to use a list or slices, but we aren't allowed to use these functions yet. I guess the question is just how do I do it?","Programming is all about decomposing complex problems into simpler ones. Try breaking it down into smaller steps. First, can you generate the numbers 1,3,5,7 in a for loop? Next, can you generate 8,6,4,2 in a second loop? Tackling those two steps ought to get you on the right track.",0.2655860252697744,False,1,7216 2021-01-07 14:07:03.210,What's exactly ntc form in tf-idf vector space?,"I have a collection of text documents. I've been asked to show each document in tf-idf vector space and in ntc form and then, train a svm model based on documents' vectors in python. What does ntc exactly mean here? I Found that it's the same as tf-idf weights with one step of normalization which is called ""cosine normalization"". But i can't find information about such thing. I found ""cosine similarity"" which is in my idea different from ""cosine normalization"". Are they the same? And how can i create this vector in python?","I suggest the sklearn.feature_extraction.text.TfidfVectorizer, scikit learn is a bib in python used for training machine learning model, it is easy and very useful,",0.0,False,1,7217 2021-01-07 14:34:21.043,Properly starting/stopping Selenium standalone server,"I am using the Selenium standalone server for a remote web driver. One thing I am trying to figure out is how to start/stop it effectively. On their documentation, it says ""the caller is expected to terminate each session properly, calling either Selenium#stop() or WebDriver#quit."" What I am trying to do is figure out how to programmatically close the server, but is that even necessary? In other words, would it be okay to have the server up and running at all times, but to just close the session after each use with something like driver.quit()? Therefore when I'm not using it the server would be up but there would be no sessions.","you were right. Use seleniums driver.quit() as it properly closes all browser windows and ends driver's session/process. Especially the latter is what you want, because you most certainly run the script headless. I have a selenium script running on as Raspberry Pi (hourly cron job) headless. That script calls driver.quit() at the end of each iteration. When i do a -ps A (to list al active processes under unix), no active selenium/python processes are shown anymore. Hope that satisfies your question!",0.0,False,1,7218 2021-01-07 21:37:17.423,Need help sorting a list with letters and numbers in each entry,"In my code I need to ask the user to input items of a shopping list and then sort that list into descending order by price. For example if the user where to enter : Butter 1.70, Coffee 4.99, Milk 0.45, Kitchen Towel 1.75, Washing powder 6.20 The output should be: Washing powder 6.20, Coffee 4.99, Kitchen Towel 1.75, Butter 1.70, Milk 0.45 However I am completely stuck on how to actually do this. Any help is welcome, thanks in advance.","Here's some high level steps I'd start with, lmk if you need help with any particular step. split up list with something like input.split(',').strip() For each element, split by space item.split(' ') Assume the number is the last 'word' of each element. Convert that word to a number. Do the sort.",0.0,False,1,7219 2021-01-08 08:09:42.083,How can I combine a HTML and Python File?,"I recently did a project where I have to get the following input from the user: Date in DD form, Month in MM form, Year in YY form, Century (19, 20 0r 21) and the date format(MM-DD-YYYY, DD-MM-YYYY, YYYY-MM-DD). And I have to print the date in the format chosen by the user... Further I have to ask the user the number of days to be added to the date that was printed previously and then add the no. of days and then print it and if the user should be asked if he wants to continue adding days, if they choose yes.. again they'll be asked the no. of days to be added, if they select no then program ends there.... Now I have made a HTML files for that... The problem is I don't know how to combine the Python and HTML files... Please help me in this regard.","The keywords you should be looking are a web framework to host your application such as Flask, Django, and a template language to combine python and HTML to use it via these frameworks, such as Jinja2 or Django's own template language. I suggest Flask with Jinja2 since it's a micro framework and easy to start with.",0.2012947653214861,False,1,7220 2021-01-08 16:26:06.310,Numpy doesn't provide an attribute,"I've tried to import a model on Kaggle: from statsmodels.tsa.arima.model import ARIMA but it returned this error: AttributeError: module 'numpy.linalg.lapack_lite' has no attribute '_ilp64' There's numpy version 1.18.5. Could you please tell how to fix this error?","I've just back up statmodels library to the version 0.11.0: pip uninstall statsmodels -y pip install statsmodels==0.11.0 It seems like default version 0.11.1 has a bug",0.3869120172231254,False,1,7221 2021-01-10 01:30:19.023,Limit same password in password change,"I’m building a gui on python with tkinter, i’ve made a login, register and change password screens, hosting the data on mysql, i want to make an option that if user already choose password “x” for example, he will be able to repeat the password only 1 more time, after that it will not give him an option to choose and repeat the same password on the change password screen, any clue how to do it?","Create a table with (user, passwords_used) as columns. Each time a user changes their password, check it against this table. If that (user, password) pair isn't in the table, add it to the table and change the password. Otherwise reject it as reused.",0.0,False,1,7222 2021-01-10 03:19:46.847,how to clear the vscode terminal when I run the code again?,Is there a way in Visual Studio Code to clear the previous code in the terminal every time I execute the code. It's very annoying to type clear every time I wanna run the code again (or to run another file).,"To clear Terminal in VS Code simply press Ctrl + Shift + P key. type command Terminal: Clear. go to View in taskbar upper left corner of vs code and open Command palette. I think Ctrl + K should do the trick too if you are in windows, or else you can make shortcuts for clearing the terminal using VS Code shortcuts(keybindings file).",0.3869120172231254,False,1,7223 2021-01-11 08:03:22.507,how to replace python 32-bits with 64-bits without losing my projects?,"I am using python 32-bits but I want to upgrade it to 64-bit to use some advanced modules. But I don't want to lose my 32-bit projects, suggest help, please.","Pure Python code is neither 32 nor 64 bits, because Python is a very high level programming language. When you run a Python program, the Python interpreter quickly compiles your source code to machine code and executes it. It doesn't matter whether you use a 32 bit or 64 bit Python interpreter to execute your pure Python program, because the result should be the same. However, if your program uses libraries that contain non-Python code, you might have to reinstall the 64 bit version of those libraries. So to conclude, don't be afraid to download and install the 64 bit version of Python because your Python programs will all run perfectly on it!",0.3869120172231254,False,1,7224 2021-01-11 16:13:22.740,Generate an executable from python project,"I need to generate an executable from a python project containing multiple folders and files. I tried to work with library cx_Freeze, but only worked for a single file project. Can you tell me how to do please?","Running pyinstaller on your ""main"" python file should work, as PyInstaller automatically imports any dependencies (such as other python files) that you use.",0.1352210990936997,False,2,7225 2021-01-11 16:13:22.740,Generate an executable from python project,"I need to generate an executable from a python project containing multiple folders and files. I tried to work with library cx_Freeze, but only worked for a single file project. Can you tell me how to do please?","use pyinstaller. just run pip install pyinstaller and then open the folder the file is located in with shell and run pyinstaller --onefile FILE.py where file is the name of the python file that should be run when the exe is run",1.2,True,2,7225 2021-01-13 12:26:48.657,How many rows/columns are there in a tkinter Frame?,"Using tkinter we can use either widget.grid(row,col) or widget.pack() to place a widget. Since row,col corresponds to the row/col-index in a given Frame/Window - how do we know how many columns the Frame/Window consists of? E.g if I want to place a widget in the midle or to the very right","Rows and columns are just concepts, not actual things. There is effectively an infinite number of rows and columns, all with a width or height of zero until they contain a widget or are configured to have a minimum width or height. From a practical standpoint, there are as many rows and columns as there are pixels in the window. In reality, the number of rows and columns is entirely up to you. A widget can have a single row and column or it can have several. It all depends on what you add to the window. A frame starts out with nothing in it, so there are no rows and columns, just empty space. When you add a widget to a row and column, it now has one row and one column plus maybe some empty space. Even if you place your first widget at row 50 and column 20, there is still just one row (50) and one column (20). There are simple techniques to put something in the middle, or along the right size. For example, because you can define how many columns, you can configure the master to use three columns and the place your widget in the middle column. You can use columnconfigure to cause the last column to take up all extra space with the weight option. This will move any widgets in the last column to the right edge.",0.6730655149877884,False,1,7226 2021-01-13 14:44:17.660,"ImportError: DLL load failed, Dearpygui, Python","Dearpygui used to work just fine, till I upgraded Pycharm and Python from 3.6 to 3.9. Than this error occurred. Went back to 3.6. Abandoned Pycharm. Removed Pycharm, Pip and Python. Installed Python 3.6, 3.7, 3.9. Started in new environment. Upgraded pip. Tried all Python versions.... for all versions pip successfully installed Dearpygui to the site-packages... but all failed to load DLL on Python-'import'-command. I've seen others with similar problems with other packages, but found no useful suggestion... It looks as if something is changed in the settings/environment of Window-10... (by Python?) dearpygui-0.6.123, pip 20.3.3, python 3.7 (64-bit) a.o., windows 10 Pro 2014 (PS. although 'the specified module' can not be found upon the Python-'import'-command, PyCharm has somehow full access to the Dearpygui-class-information...)",What is the name of your file? Would it happen to be dearpygui.py?,-0.3869120172231254,False,1,7227 2021-01-13 17:19:32.087,Selecting mutiple random sequences of N elements from M different-length lists in Python,"I have X lists of elements, each list containing a different number of elements (without repetitions inside a single list). I want to generate (if possible, 500) sequences of 3 elements, where each element belongs to a different list, and sequences do not repeat. So something like: X (in this case 4) lists of elements: [A1,A2], [B1,B2,B3,B4], [C1], [D1,D2,D3,D4,D5] possible results: [A1,B2,D2], [B3,C1,D2], [A1,B2,C1]... (here 500 sequences are impossible, so would be less) I think I know how to do it with a nasty loop: join all the lists, random.sample(len(l),3) from the joint list, if 2 indices belong to the same list repeat, if not, check if the sequence was not found before. But that would be very slow. I am looking for a more pythonic or more mathematically clever way. Perhaps a better way would be to use random.sample([A,B,C,D], 3, p=[len(A), len(B), len(C), len(D)]), then for each sequence from it randomly select an element from each group in the sequence, then check if a new sequence generated in this way hasn't been generated before. But again, a lot of looping. Any better ideas?","Check itertools module (combination and permutation in particular). You can get a random.choice() from the permutations of 3 elements from the X lists (thus selecting 3 lists), and for each of them get a random.choice() (random module).",0.0,False,1,7228 2021-01-13 20:11:36.893,How to install PyAudio via Virtual Environment in PyCharm,"So I am using a venv (virtual environment) for one of my python projects and need to install PyAudio for it. I am using PyCharm for the venv. When I try to install PyCharm usually it comes up with 'Command errored out with exit status: 1' How can I install PyAudio into my venv properly (I know PyAudio needs to be installed differently I just don't know how to do it in the venv)",So I fixed my problem. I found the PyAudio file in my normal python (Python 3.9 64-bit) and transferred it to my venv (Python 3.8 64-bit) and now it works fine!,0.0,False,1,7229 2021-01-14 16:31:43.383,Fast subsequent multiplication of many matrices in python,"I have to generate a matrix (propagator in physics) by ordered multiplication of many other matrices. Each matrix is about the size of (30,30), all real entries (floats), but not symmetric. The number of matrices to multiply varies between 1e3 to 1e5. Each matrix is only slightly different from previous, however they are not commutative (and at the end I need the product of all these non-commutative multiplication). Each matrix is for certain time slice, so I know how to generate each of them independently, wherever they are in the multiplication sequence. At the end, I have to produce many such matrix propagators, so any performance enhancement is welcomed. What is the algorithm for fastest implementation of such matrix multiplication in python? In particular - How to structure it? Are there fast axes and so on? preferable dimensions for rows / columns of the matrix? Assuming memory is not a problem, to allocate and build all matrices before multiplication, or to generate each per time step? To store each matrix in dedicated variable before multiplication, or to generate when needed and directly multiply? Cumulative effects of function call overheads effects when generating matrices? As I know how to build each, should it be parallelized? For example maybe to create batch sequences from start of the sequence and from the end, multiply them in parallel and at the end multiply the results in proper order? Is it preferable to use other module than numpy? Numba can be useful? or some other efficient way to compile in place to C, or use of optimized external libraries? (please give reference if so, I don't have experience in that) Thanks in advance.","I don't think that the matrix multiplication would take much time. So, I would do it in a single loop. The assembling is probably the costly part here. If you have bigger matrices, a map-reduce approach could be helpful. (split the set of matrices, apply matrix multiplication to each set and do the same for the resulting matrices) Numpy is perfectly fine for problems like this as it is pretty optimized. (and is partly in C) Just test how much time the matrix multiplication takes and how much the assembling. The result should indicate where you need to optimize.",0.3869120172231254,False,1,7230 2021-01-15 14:28:22.847,How can I restrict a bot to responding in certain channels with discord.py?,"I am making a bot that is using cogs and has a couple different commands. I want this bot to only reply in one of the two bot commands channels of the server I’m using it on. I have seen that i can use ctx.channel.id = whatever the Id is, but i would prefer the bot to not be able to respond in the channel at all, including to .help commands. I have seen people do this with on_message, but I’m not sure how I would do that with cogs. Any help would be much appreciated. My intended result is basically to have the bot only respond in two channels, the two bot channels that i specify, to any commands including the .help command. Thanks!","The easiest way to do this is not actually via code but via permissions on the server. On your server you should find a role with the same name as your bot, whose permissions (including send messages) you can change for seperate channels.",1.2,True,1,7231 2021-01-15 20:33:19.040,Pycryptodome: ImportError: DLL load failed while importing _AES: %1 is not a valid Win32 application,"I have this problem when I try to import Pycryptodome. Traceback (most recent call last): File ""C:\Users\me\Documents\Python\Python 3.8\file.pyw"", line 17, in from Crypto.Cipher import AES File ""C:\Users\me\AppData\Local\Programs\Python\Python38\lib\site-packages\pycrypto-2.6.1py3.8-win-amd64.egg\Crypto\Cipher\AES.py"", line 50, in from Crypto.Cipher import _AES And then: ImportError: DLL load failed while importing _AES: %1 is not a valid Win32 application. I'm using Windows 64 bit with Python 64 bit 3.8.7. I installed Pycryptodome (version 3.9.9) with pip install pycryptodome. But when I tried to import AES from Pycryptodome, it errors out with the error above. Can anyone please tell me how to fix it? FYI, this is my first post on Stack Overflow, so if the post is missing anything, please tell me. Thanks!","oh silly me, need to install pycryptodome 3.8.2. Dumb mistake lol.",1.2,True,1,7232 2021-01-19 06:00:20.620,Google Cloud can't save Tensorflow model from Jupyter Notebook,"I am creating and training a TensorFlow model in Google Cloud in their JupyterLab AI Notebooks but for some reason I cannot find a way to save my model after it's been created. Typically, I'd use created_model.save(str('/saved_model_file')) in Colab to save to the local directory. But JuptyerLab in Google Cloud responds with a ""Permission Denied"" error, I've tried giving all possible maximum permissions in AIM, I'm the only person on the count. But the error persists. But I do seem capable of saving blobs to Buckets by using blob.upload_from_filename(source_file_name) or blob.upload_from_string(source_file_name) which saving to buckets seems like a more appropriate strategy. But neither one of these will take the trained model created by TensorFlow since it's more of a function and not a file type they seem to be looking for. The tutorials seem to casually mention that you should save your model to a bucket but completely neglect to provide any simple code examples, apparently I'm the only guy on earth who wasn't born knowing how to do this. Would be a great if someone could provide some code examples on how to save a TensorFlow model to a bucket. I also need for this function to be done automatically by the python code. Thanks!","It seems you just need to create the path with the OS module first then the TF function will work. This seems kind of odd, other platforms I've used let the TF function create the path by its self. Apparently Google Cloud doesn't like that, perhaps there's some user permission buried in a hierarchy somewhere that is causing this problem. MODEL_NAME = 'model_directory' model_version = int(time.time()) model_path = os.path.join(MODEL_NAME, str(model_version)) os.makedirs(model_path) tf.saved_model.save(model, model_path)",1.2,True,1,7233 2021-01-19 10:47:38.007,Run python script in Android aplication,I have Android application made in java and I need to call Python script and put there some parameters to its function. When I make apk. of this androdid app. how can I make Android device execute python script in it ?,"You can make a server out of python as backend with flask or django, and then call the server whenever your app needs to run the python script.",0.0,False,1,7234 2021-01-19 16:33:47.430,django app how to get a string from a function before,I am building a django app in which the user has to write a sentence in a text box. This sentence gets then sent to the server and received by it. After that the user has to click on continue and gets on a another html page. Here the user has to record an audio of a word he sais. The word is then turned into a string and after that sent to the server. Now I would like the function in views.py to find out if the word the user said is in the sentence the user wrote before. But the sentence is only in the first function that receives the sentence after it is sent. I know I could first store the sentence but is there also another way?,"yes, at least there is two ways first using a model to store the value. or a file maybe. second using some html magic(? I'm not sure of magic). using an input type=""hidden"". your first function receives the text, redirects user to another page but with an argument the text!, then inside that template store that text in a hidden input and by clicking the button send both voice and hide value text to the new functon.",1.2,True,1,7235 2021-01-20 05:18:51.260,Telegram Bot delete sent photos?,"I am looking to delete a photo sent by my bot (reply_photo()), I can't find any specific reference to doing so in the documentation, and have tried delete_message(), but don't know how to delete a photo. Is it currently possible?","You need to have the chat_id and the message_id of that message sent by bot, then you can delete using context.bot.delete_message(chat_id, message_id). Note: Bot cannot delete a message if it was sent more than 48 hours ago.",0.0,False,2,7236 2021-01-20 05:18:51.260,Telegram Bot delete sent photos?,"I am looking to delete a photo sent by my bot (reply_photo()), I can't find any specific reference to doing so in the documentation, and have tried delete_message(), but don't know how to delete a photo. Is it currently possible?","It's currently possible in Telegram API, not the Bot API unfortunately. It's a shame :(",0.0,False,2,7236 2021-01-20 12:38:52.443,How can I run a Python script inside a webpage?,"I hope you can help me. I have a static website hosted on Heroku and I would like to implement a Python Script to be executed when a button is clicked. So, just as a reference you would have: A text field A button Another text field The idea is that you enter some text in the first text field, you click the button calling the Python Script, and then print the result coming from the Python Script in the second text field. How would you implement such technology? Which services should be used to achieve the result? I think that the script should be hosted somewhere and be called via an API but I do not really know how to do it. I hope you can help me. Thanks!","I should use Flask or Django. In Flask you simply use the: name = ""your_variable"" command in your HTML code and then you can simply use the code request.form [""your_variable""] in your python script.",0.1352210990936997,False,2,7237 2021-01-20 12:38:52.443,How can I run a Python script inside a webpage?,"I hope you can help me. I have a static website hosted on Heroku and I would like to implement a Python Script to be executed when a button is clicked. So, just as a reference you would have: A text field A button Another text field The idea is that you enter some text in the first text field, you click the button calling the Python Script, and then print the result coming from the Python Script in the second text field. How would you implement such technology? Which services should be used to achieve the result? I think that the script should be hosted somewhere and be called via an API but I do not really know how to do it. I hope you can help me. Thanks!","You have to use backend for your purpose. When a user clicks your button some data would be collected by your backend, handled and showed to user with the help of API. You can start with learning a little bit of Flask and learning Django later for some bigger projects.",0.1352210990936997,False,2,7237 2021-01-20 13:57:26.497,Multiprocessing in python vs number of cores,"If a run a python script where i declare 6 processes using multiprocessing, but i only have 4 CPU cores, what happens to the additional 2 processes which can find a dedicated CPU core. How are they executed? If the two additional processes run as separate threads on the existing Cores, will GIL not stop their execution? #Edit 1 - 21st Jan 2021 I have mixed up threads and processes in the question I asked. Since I have better clarity on the concept, I would rephrase question 2 as follows(for any future reference): If the two additional processes run in parallel with two other processes in existing Cores, will GIL not stop their execution? Ans: GIL does NOT affect the processes, GIL allows only one thread to run at a time, there is no restriction on processes, however. The system scheduler manages how the additional two processes will run on the existing cores.","First you are mixing up threads and processes: in Python only threads not processes have to share a lock on their interpreter. If your are using the multiprocessing library then, your are using Python processes which have their own interpreter. When you are using Python processes, their execution is managed by your operating system scheduler, in the same manner as every other processes in your computer. If you have more processes than CPU cores then the extra processes are waiting in background to be scheduled. This usually happen when an other process terminates, wait on an IO, or periodically with clock interrupts.",1.2,True,1,7238 2021-01-20 20:21:16.300,How to stop my exes from being treated like a virus?,"I noticed any exe application I make are treated like viruses upon download. This is terrible, how do I make them legitimate? I read something about self-signing, but I still don't get it. What is the process of self signing and how do I do it? If it helps I am using pygame, python, on pycharm, with pyinstaller, on Windows 10.","You cant, or it is hard, to fix that your program treats as virus at antiviruses because av's use euristhic analysis and machine learning so they could make your program false positive. You have to go to av's forums and ask why your app is false positive.",0.0,False,1,7239 2021-01-21 08:13:07.650,How to change character to ASCII in python without ord(),"I know the function 'ord' can convert character to number. but I just want to know how to convert without 'ord' C can convert it, but is it impossible in Python ?","You can use len() function to solve it input(""any value?"") print(len(""value""))input(""any value you want"") print(len(""enter your value""))",-0.2012947653214861,False,1,7240 2021-01-22 05:58:29.237,Numerical Integration in fortran with infinity as one of the limits,"I am asked to normalize a probability distribution P=A(x^2)(e^-x) within 0 to infinity by finding the value for A. I know the algorithms to calculate the Numerical value of Integration, but how do I deal with one of the limits being Infinity.","The only way I have been able to solve this problem with some accuracy (I got full accuracy, indeed) is by doing some math first, in order to obtain the taylor series that represents the integral of the first. I have been looking here for my sample code, but I don't find it. I'll edit my post if I get a working solution. The basic idea is to calculate all the derivatives of the function exp(-(x*x)) and use the coeficients to derive the integral form (by dividing those coeficients by one more than the exponent of x of the above function) to get the taylor series of the integral (I recommend you to use the unnormalized version described above to get the simple number coeficients, then adjust the result by multiplying by the proper constants) you'll get a taylor series with good convergence, giving you precise values for full precision (The integral requires a lot of subdivision, and you cannot divide an unbounded interval into a finite number of intervals, all finite) I'll edit this question if I get on the code I wrote (so stay online, and dont' change the channel :) )",0.0,False,1,7241 2021-01-22 14:51:07.210,"django.db.utils.ProgrammingError: (1146, ""Table 'online_examination_system.studentapp_courses' doesn't exist"")","I tried makemigrations, migrate, and even many methods stated in stack overflow but nothing is happening. Please tell me the reason why this happens and how can i solve it?","I think this can help you :- Delete all the migrations in your app except init.py file. AND then again type python manage.py make makemigrations and type python manage.py migrate",0.0,False,1,7242 2021-01-23 05:29:45.003,Windows Command prompt - nnictl command not recognized,"I have tried installing nni packages in windows command prompt,it installed successfully.but when i tried to command, ""nnictl create --config nni\example/trails\mnist-pytorch\config_windows.yml"" in windows command prompt.it says, 'nnictl' is not recognized as an internal or external command,operable program or batch file. how can i fix this error?",It is solved! I just installed anaconda3 and tried installing nni packages in it.And also it recognized 'nnictl' command in anaconda3 prompt automatically by setting path variables.Thanks:),0.0,False,1,7243 2021-01-23 11:22:19.500,VSCode Jupyter cannot update kernels automatically,"I'm working on Ubuntu by remoteSSH, and I updated python kernel in my vitual environment named nn form 3.7.9 to 3.8.5, however, I still find the old kernel standing in the jupyter kernel list. I want to know how to delete the old kernel name from the kernel list. I've replaced python 3.7.9 and python3.6.4 with python 3.8.5, but the old kernels didn't disappear, I want to delete them manually. Moreover, I can't select Python 3.8.5 from the kernel list.","I had the same problem and the following might help someone else encountering the issue: Reload VS Code Window by Ctrl+Shift+P and selecting Reload Window. Reload the Python and Jupyter extensions under the Extensions in the Side Bar. Quit and relaunch VS Code. It seems that VS Code is not that quick to update the interpreter list.",0.5916962662253621,False,1,7244 2021-01-25 00:01:29.770,How to send live status update from express/flask backends to vuejs frontend,"I am implementing a system that checks the plagiarism of documents. our stack is vuejs, nodejs/express and flask for python. My question is that i have a page which the user will upload his documents for checking and the vue ui will send a request to the backend apis with the user file to check the similarity, while this process is running a loading overlay is displayed in the same page. I want to update this page with live steps from the backend side like ""extracting"", ""searching"", ""comparing"", ""generating report"". noting that the request sent with the user file have only one response. so any ideas how can i achieve this step ?? Thanks ,,",You can return a request_id and after that you can use the id to check on the status/stage of the request.,0.0,False,1,7245 2021-01-25 04:16:20.610,need help using pyinstaller,"i am trying to program a simple script and i would like to know if anyone has the answer to this question when i have a module for example WMI from 'pip install wmi' in the form as 'import wmi' in my code, how do i get the pyinstaller module to compile the wmi module with the exe file i have tried importing from the source code in a folder example 'from wmi import wmi' but i got no luck when launching the exe file only in the raw python file, also just to note when i compile the script i do the command 'pyinstaller vb.py --onefile'",remove --onefile since wmi couns as a file (or multiple if its a package),1.2,True,1,7246 2021-01-26 10:24:13.223,How to add a directory to a path?,"I am trying to install jupyterlab via the command terminal and it gave me the following warning: WARNING: The script jupyter-server.exe is installed in 'C:\Users\Benedict\AppData\Roaming\Python\Python39\Scripts' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress thus warning, use --no-warn-script-location. Please how do I add the directory to PATH? Someone help me please. Thank you","As i can see, you haven't put that in path, for doing that follow the following step:- Open the advance system settings select environment variable Then click on path and press edit. Click on new and enter the you path and then your path to python script directory. Press okay and reopen the jupyter. That's it",0.0,False,1,7247 2021-01-26 20:37:26.943,How do you prevent a circular import exception,"I have been trying to link a main module with another module, both need each other to perform a specific task, so I imported them to each other, but I get an error about circular importation. I've been trying to avoid this but it keeps raising the error, please how do I correct this??","Simply create a 3rd module, from which you can then import the functions, classes and variables to the 2 other scripts. Normally issues like these are signs of poor code structuring. 2 separate scripts should never both depend on one another at the same time. Avoid such design blunders in the future.",0.0,False,1,7248 2021-01-27 01:57:19.983,Is it better for performance to use min() mutliple times or to store it in a variable?,"I have a small python code that uses min(list) multiple times on the same unchanged list, this got me wondering if I use the result of functions like min(), len(), etc... multiple times on an unchanged list is it better for me to store those results in variables, does it affect memory usage / performance at all? If I had to guess I'd say that if a function like min() gets called many times it'd be better for performance to store it in a variable, but I am not sure of this since I don't really know how python gets the value or if python automatically stores this value somewhere as long as the list isn't changed.","If you are only using it 1-5 times, it doesn't really matter. But if you are going to call it anymore, and really less too, it is best to just save it as a variable. It will take next to no memory, and very little time to do so and to pull it from memory.",0.0,False,1,7249 2021-01-27 07:28:51.500,See pip installations in a PyCharm Project?,"Is there a possibility to see all pip installed packages in Pycharm? Because I have the Problem: I write in PyCharm and it works fine, but now I want to move the project to a server... And now I don't know how can I quickly export this","Use the command pip freeze >requirements.txt locally to import the environment you need into the file, then use the command pip install -r requirements.txt on the server to install the required environment",0.1352210990936997,False,1,7250 2021-01-27 20:03:44.497,How do i copy a URL from searchbar?,"I wrote a program that automatically navigates me threw a website, but how do I copy my current URL. Context: I am attempting to code a watch2gether bot that automatically creates a watch2gether room","I don't know which programming language you use, but in Python3 its simply driver.current_url",1.2,True,1,7251 2021-01-27 21:46:14.163,How to provide different sets of data to different users in django?,"I'm a newbie to the django framework and trying to make a watchlist for stocks. I've already made the crux of the webapp, where-in, a user can search for a quote and add it to their watchlist, along with relevant data about that quote. What I want to do now is, to save the separate watchlists that different users are creating (after creating an account on my site) and upon logging in to my site, they can view their personalized watchlist and edit it. I'm using a model for storing the data for the watchlist quotes and looking for a way to provide the different personalized watchlists depending upon the logged in user. Can anyone give me a lead on how to employ the logic for this? Do I need to use two data bases - one for the data of the users and the other one for storing the respective user watchlists? If yes, how do I connect everything? EDIT: Ever used a stock investment app? The way every user/customer can log in to their account and make/edit and save their watchlists in the app - that is the functionality I want to implement. How/Where do I store so many watchlists?","use 'request.user' from your view, to know the user who sent the request and return the corresponding watchlist",0.3869120172231254,False,1,7252 2021-01-28 15:09:23.800,Keras LSTM Binary Classification Output,"I am doing binary classification for a time series with keras LSTM. How could I extract the final output from the model? By this I mean, how can I get a list containing zero and one values from the final model?","You should attach right after a LSTM layer a Dense layer with as much neurons as you consider (that depends upon the LSTM output itself), and on top of that one add a final Dense classification layer with a single neuron, that'd be the binary output.",0.0,False,1,7253 2021-01-28 22:25:08.557,How to correlate different MRI sequences images in NIFTI format?,"I am new on Medical Imaging. I am dealing with MRI images, namely T2 and DWI. I uploaded both images with nib.load, yet each sequence image has a different number of slices (volume, depth?). If I select one slice (z coordinate), how can get the corresponding slice on the other sequence image? ITK does it correctly, so maybe something in the NIFTI header could help? Thank you so much for reading! I also tried interpolation, but it did not work.","Reading the NIFTI, namely affine, and extracting the translation Transformation Matrix to create a mapping from the T2 to the DWI voxels. Hint: nibabel.",0.2012947653214861,False,1,7254 2021-01-29 10:32:56.013,Uninstall Jupyter-Lab with conda completely,"I'm trying to reinstall Jupyter-Lab with conda completely. I mean, when I run uninstall jupyterlab and install it again, the system already comes with configuration I had previously, such as extensions installed. Therefore, there is something that is still present after the uninstall. Hence, how do I completely remove jupyter-lab and install it again from scratch?","When jupyterlab is installed use jupyter --paths to see where the configuration, data and runtime is stored. After removing the corresponding files and directories you will be able to perform a clean install without any traces of the old extensions. Remember to use it in the right environment.",1.2,True,1,7255 2021-01-29 12:52:38.413,How to implement a python code to work as Azure Function?,"I have built a Socket TCP / IP server that listens on a specific port and then, with that data, makes a rest query to another server, and that response is returned through the port where it received it. All Socket server is made in Python 3.8 and works great. I need to know how to implement this code from my Socket server to an Azure Functions, so that it provides permanent service? I appreciate the goodwill of anyone who can offer an answer. Thanks Total.","Simple answer: you cannot do that. Azure Functions are Event-based (such as an HTTP call). If you need to provide TCP socket, maybe hosting your python code in a container, e.g. Azure Container Instances, might be a good way to go.",0.0,False,1,7256 2021-01-29 14:48:13.503,How do I check the type of a field contained in a JSONB?,"I'm hoping this is a fairly simple question with a simple answer. In PostgreSQL I have a table with a Answer column that is a jsonb. As of right now, the data that can be stored in the column can be empty or quite varied. Some examples include: {""Answer"":""My name is Fred""} {""Answer"":[{""text"": ""choice 1"", ""isActive"": true}, {""text"": ""choice 2"", ""isActive"": false}]} Yes, we store a field called Answer in our column called Answer. Not sure why, but that is how it is. I want to be able to test if the JSON attribute Answer contains a string or an array. But I don't know how, and I must be wording my searches incorrectly. I'm not finding anything concrete. I already know how to check if Answer exists. Just can't tell what it contains. Does anyone know how I would do this? Or if there isn't a way, what I need to do instead to query this data?","func.jsonb_typeof(.answer.op('->')('Answer')) == ""string"" seems to do the job.",0.0,False,1,7257 2021-01-30 17:10:02.537,how to RST packet drop using python?,"I want to implement a simple source code that DROPs all RST packets that come into the computer using Python. What should I do? Linux servers can be easily set up using the iptables command, but I want to make it Python for use on Mac, Linux, and Windows systems.","Dropping RST packets is a function of the networking firewall built into your operating system. There is only one way to do it on Linux: with iptables. You could use Python to instruct iptables. Windows has its own way to add firewall rules. MacOS also has its own way, and each of them is different from the other. There is no single common way to do this. Therefore, there is no single common way to do this with Python.",0.0,False,1,7258 2021-02-01 08:48:14.973,"is there a way to get the count of conflicts while using Django ...bulk_create(.., ignore_conflicts=True)?",I am using bulk_create to upload some data from excel to django db. Since the data is huge I had to use bulk_create instead of .create and .save. But the problem is that I need to show the user how many duplicate data has been found and has not been uploaded due to integrity error. Is there a way to get the number of errors or duplicate data while using bulk upload?,"After, Reading data from csv file. First create a list before inserting data to system. Then convert that list to set after then again sort the data which is in set. Here , you gets every data exactly one time in sorted manner.",-0.9950547536867304,False,1,7259 2021-02-01 14:22:58.123,How to save URL to a Django ImageField,"I have Django model with Image field, but sometimes I don't need to actually upload file and store path to it, but I need to store only path. Especially url. I mean, I have web client, that receives both foreign urls like sun1-17.userapi.com and url of my own server, so sometimes I don't need to download but need to store url. Is it possible, to store url in ImageField, or I need to make CharField and save files via python? If its impossible, how do I save file in python3, having one, sent me via multipart?","The URL field in the ImageField is ReadOnly, so you cannot write it. You should probably use in addition a URLField (better than a CharField) to save the URLs. You can allow null values on both and use only the appropriate one according to your scenario.",0.0,False,1,7260 2021-02-01 22:49:29.137,How can I set a .jpg as window background in python ursina?,How can I an image as the background in my ursina project. I know I can change the color of the background by using window.color = color.light_gray for example. But how do I use an image?,"Try Sky(texture=""texture_name"")",0.0,False,1,7261 2021-02-02 08:16:14.057,Showing the setup screen only on first launch in kivy,"I am trying to make an app with kivy and kivymd but I can't figure out how I can make the setup screen show up only the first time. This is how the application is going to work: User launches the application after installation and is being shown the sign up/log in screen, And once the user is done with the setup, the setup screens will never appear again unless the user reinstalls the application. How can I make this happen? Please help and thanks SO much in advance!","I fixed this problem by creating and reading a ""text"" file.My ""text"" file has '0' as a boolean variable .Once the user is done with signing up / logging in , I change that ""text"" file to '1' ,and in the __init__ func, I check if that file equals to '0' or '1'. I'm not sure if this is the correct way or not,but this worked for me.",1.2,True,1,7262 2021-02-02 10:41:21.907,Reinforcement learning DQN environment structure,"I am wondering how best to feed back the changes my DQN agent makes on its environment, back to itself. I have a battery model whereby an agent can observe a time-series forecast of 17 steps, and 5 features. It then makes a decision on whether to charge or discharge. I want to includes its current state of charge (empty, half full, full etc) in its observation space (i.e. somewhere within the (17,5) dataframes I am feeding it). I have several options, I can either set a whole column to the state of charge value, a whole row, or I can flatten the whole dataframe and set one value to the state of charge value. Is any of these unwise? It seem a little rudimentary to me to set a whole columns to a single value, but should it actually impact performance? I am wary of flattening the whole thing as I plan to use either conv or lstm layers (although the current model is just dense layers).","You would not want to add in unnecessary features which are repetitive in the state representation as it might hamper your RL agent convergence later when you would want to scale your model to larger input sizes(if that is in your plan). Also, the decision of how much of information you would want to give in the state representation is mostly experimental. The best way to start would be to just give in a single value as the battery state. But if the model does not converge, then maybe you could try out the other options you have mentioned in your question.",1.2,True,1,7263 2021-02-03 14:09:39.923,Create Bacnet client variable automate,"Sorry to my bad english. So i use a automate with MERVIS software and i use a Bacnet server to have my variable in my IHM (weintek panel pc with Easybuilder Pro). So all i make is good and work but i'm not happy to EasyBuilder pro and i want make my own HMI. I decide to make my application with QT in C++. But i'm physicien at the begining so learn little bit by little bit( i have base of python,c++, structur text). I know nothing about how build a bacnet client and do you have idea where can i find some simple exemple to communicate with my PLC because i find nothing and i need to learn and make this to my project. So i have my PLC, link in ethernet to my PC where i make my hmi. In the future i want put this application in PANEL PC tactil work in window and link to my PLC with MERVIS software.","If I'm clear on the question, you could checkout the 'BACnet Stack' project source code or even the 'VTS' source code too - for a C/C++ (language) reference. Otherwise YABE is a good project in C# (language), but there's also a BACnet NuGet package available for C# too - along with the mechanics that underpin the YABE tool.",0.0,False,1,7264 2021-02-03 17:00:46.763,how can i make someone on another network access my website with django,"hello guys I'm trying to make another one to access my Django website I host it on my localhost by type python manage.py runserver 0.0.0.0:8000 and i set the ALLOWED_HOSTS = ['*'] when I trying to connect with my IP it's says refused to connect. can someone help me",you are only hosting your server in your local network therefore no-one outside of this network can access your server. To make them access it you would have to make it accessible over the internet for example via hosting it on aws or another cloud hoster.,-0.3869120172231254,False,1,7265 2021-02-03 17:56:01.027,How to immediately delete just input symbol in tkinter.Entry(),"Let's imagine, I have a simple tkinter program: only tkinter.Entry(), where I can write down some text. The main goal I have set to this tkinter.Entry() is to make next: when I try to input there some symbol, it is immediately deleted from tkinter.Entry(). So the question is how to make tkinter.Entry() delete every symbol, when it have been just input there? I hope the problem is fully described. Thanks in advance for your help. I apologize, but it seems to me that this question has lost its former relevance for me. Sorry for letting you take all of your precious time. I took all the answers and tips into account. I will delete the question soon. Thank you for your attention to me","From what I deduced, you're trying to delete the content from the entry widget. tkinter.Entry.delete('0',END) This should do it.",0.3869120172231254,False,1,7266 2021-02-03 18:05:20.380,how can i create a tkinter app updater which is included with the app,"I have a Tkinter app which I have converted to .app and .exe, but after giving this app to others if I have to update the app how should I do it(like in play store update)? And also if I package this app and distribute with an installer then how to send update to the app?","I don't think that it's possible to update the app like that. Android apps usually are made with Java, and iOS apps are made with Xcode, Swift, and Objective-C. I don't usually make apps with Python, unless they are for myself, because once they are made into apps, they cannot be updated (as far as I know). If I wanted to update my Python app, I would remove the first app, then use Pyinstaller to make the updated app. Hope this helps, and have a good day. :)",0.6730655149877884,False,1,7267 2021-02-04 23:02:22.620,How to hide window when running a Task Scheduler task,"I'm using Task Scheduler to execute python run.py. It works, but the Python interpreter pops up. I want to run run.py in the background without any interpreter popping up. How can I do this? In Linux I'd just do python run.py & to get it to run in the background silently, but I'm not sure how to achieve the same in Windows with Task Scheduler.","You can just change .py extension to .pyw and the python file will run in background. And if you want to terminate or check if it actually running in background, simply open Task manager and go to Processes you will see python32 running there. EDIT As you mentioned, this doesn't seem like working from command line because changing the file's .extension simply tells your system to open the file with pythonw application instead of python. So when you are running this via command line as python .\run.pyw even with the .pyw this will run with python.exe instead of pythonw.exe. Solution: As you mentioned in the comments, run the file as pythonw .\run.pyw or .\run.py or just double click the run.pyw file.",0.0,False,1,7268 2021-02-05 02:07:54.343,How to hide / encrypt source code written in Python?,"I had developed a standalone application on Windows for Deep Learning / Computer vision in Python 3.X using various standard python libraries such as pandas, numpy, TensorFlow, Keras, Yolo, PyQt ...etc. I want to deliver this application to my client but without source code. Can you please help me how to do this?","""I want to deliver this application to my client but without source code."" Can you clarify this process? If you just want to deliver this service to your client you can just use HTTP/POST to let users upload their data to you, then you run these data on your network on the server, and finally, just return the prediction result to them.",0.0,False,1,7269 2021-02-06 02:26:05.223,How to execute .py file with double-click,"I just uninstalled and reinstalled python on my Windows machine. Before I uninstalled my previous version I was able to just double-click on a python script and it would open the command prompt, run the script, and close automatically. After re-installing with the newest version (3.9), I am no longer able to execute the script like that with a double-click. Clearly I had done something special last time to set that up for myself, but I don't remember what it was. Any idea how I can get that double-click deal going again?","There will be an option of ""Open With"" after right-click on the file go and choose CMD. I hope it helps if not then sorry. Because I use Parrot OS",0.0,False,1,7270 2021-02-06 18:05:28.877,Turtle Graphics APK,"I have built a snake game using Turtle graphics module of Python, and now I wish to convert it into an apk. I have tried kivy. It builds the apk, but the app crashes as soon as I open it in android. When using adb logact -s python, it says that the tkinter module is not available. On further researching, I got to know that turtle graphics is based upon tkinter module and tkinter is not supported by python-for-android. The solutions suggest to rewrite my code in Kivy, but I don't know how to do so. Any suggestions on how can I run my turtle graphics game on android?","The solutions suggest to rewrite my code in Kivy, but I don't know how to do so. Any suggestions on how can I run my turtle graphics game on android? It looks like you've already found the solution: rewrite your graphics in Kivy, or another python module that works on android. Recent pygame releases might. If you don't know how to do so, you need to learn. If you try to do so but have problems with any specific question, that would be a better target for a stackoverflow question.",0.0,False,1,7271 2021-02-07 11:16:23.347,Vehicle Routing Problem - How to finish/determine when certain locations are visited?,"I have VRP problem. I have vehicles starting positions and I have distance matrix. I want solution to be terminated/finished when certain locations are visited. So I don't want it to actually visit each index of location_matrix but if visiting different index beside ""MUST VISITS"" make for better solution then I have no problem. Because you know sometimes going from directly 1 to 3 is slower than 1-2-3. (visiting 2 which is not necessary but make it for shortcut) I defined a dummy depot which cost 0 , I used this for end because if you use starts you have to define ends. And I put ends 000 which are basically ending position. You might ask why you didnt put your ""JOB"" locations. But this means they have to end there. So it doesn't seem optimal because example one vehicle could be really near to both of ""JOB"" locations but if it terminates / ends because it has END defined vehicle would stop. I have no idea how to make this work. Basically what I want that if certain locations are visited once just terminate - that's the solution. So if jobs are (1,3,5) and Vehicle 1 visited 1,3 and Vehicle 2 just visited 2 it should be finished. If I use solver in ortools It will be like TSP problem which will try to visit each location in distance_matrix. I don't exactly want this. It could visit if results better solution(does it make sense?) but it should be focusing on ""JOB"" locations and how to go them faster","Potential approach: Compute a new distance matrix with only the ""MUST VISIT"" locations, and run a VRP with this matrix. Compute a distance matrix with only the ""MUST VISIT"" locations. Each cell contains the shortest path between two ""MUST VISIT"" locations. Store all the pairwise shortest paths found. Run a regular VRP on this distance matrix. Reconstruct the full path using the shortest paths found earlier.",1.2,True,1,7272 2021-02-07 22:32:21.810,How to do under-sampling with K-fold validation in machine learning,"I'm dealing with a highly imbalanced dataset for my project rn, for the simplicity, I will give a simple example here: a dataset has a number of 20 '0's and 80 '1's so the total is 100. Suppose I have already used X_train, X_test,y_train,y_test = train_test_split(X, y,stratify=y,random_state=42) to make a stratified split (X_train.shape is 80 and X_test.shape is 20), so my question is how to achieve under-sampling with K-fold validation in the train dataset at the same time. My initial thought is use from imblearn.under_sampling import RandomUnderSampler to get 16 '0's and 16 '1's (total is 32) to make equal distributed dataset, and do the K-fold cross-validation on that 32 dataset and discard the rest of 48 in the X_train. Use the model to predict the X_test. So I was wondering if this is correct procedure to deal with.",You can use RandomUnderSampler method to achieve it. Put random states and ratio value in the arguments and try to see if this works.,0.0,False,1,7273 2021-02-09 11:19:04.273,Interactive Brokers TWS: How to handle daily restart in python?,"I've built an IB TWS application in python. All seems to work fine, but I'm struggling with one last element. TWS requires a daily logout or restart. I've opted for the daily restart at a set time so I could easily anticipate a restart of my application at certain times (at least, so I thought.) My program has one class, called InteractiveBrokersAPI which subclasses the ECClient and EWrapper. Upon the start of my program, I create this instance and it successfully connects to and works with TWS. Now, say that TWS restarts daily at 23:00. I have implemented logic in my program that creates a new instance of my InteractiveBrokersAPI, and calls run() on it af 23:15. This too seems to work. I know this because upon creation, InteractiveBrokersAPI calls reqAccountUpdates() and I can see these updates coming in after my restart. When I try to actually commit a trade the next day, I get an error that it's not connected. Does anyone else have experience in how to handle this? I am wondering how others have fixed this issue. Any guidance would be highly appreciated.","Well, this doesnt exactly answer your question, but have you looked at ib_insync",0.0,False,1,7274 2021-02-10 20:52:25.617,"ModuleNotFoundError: No module named 'x' because can't find the module folder, PyInstaller","My code (test.py) looks like this (simplified): from app.utils import conversion (code) When I try to make an executable using PyInstaller, the .exe works when I import generic modules. However, I get the following error message when I use ''from app.utils import conversion'' at the beginning of my code: ModuleNotFoundError: No module named 'app' and the .exe won't run. My project is structured this way (simplified): project/app/test.py project/app/utils/conversion.py The instruction I put in the console is: pyinstaller --onefile test.py Any idea why and how to overcome this? Thanks!","Here is how I fixed my problem: in the .spec file, added the missing app module in hiddenimports: hiddenimports=[""app""] Then to compile the executable, I run the .spec file instead or the .py file. pyinstaller --onefile test.spec",0.0,False,1,7275 2021-02-11 14:08:05.040,Node JS detect connectivity to all Node JS programs,"Let me describe it as briefly and clearly as possible: I have 10 different copies of a node JS based program running on 10 different desktops. I want to create a Node JS based (or any other technology) web app deployed on a server which will check if these 10 programs are online or not. Any suggestions as to how I can implement this? Note: The node JS based desktop apps are running on electron.","While you can use socket.io for this there may also be a simpler way and that is to just use a post request / cron to check every X minutes if the server is reachable from 'Checking' server (that would just be the server that is doing the check) So why not use socket.io? Well, without knowing how you node servers are setup, its hard to say if socket.io would be a good fit, this is simply because socket.io uses WSS to connect, so unless you are running it from the browser it will need additional configurations / modules setup on the server to actually use WSS (if you do go this route, you will need socket.io-client module on each system, this is important because this will allow you to connect to the socket.io server, also make sure the version of socket.io matches the socket.io-client build) All in all, if I was building this out, I would probably just do a simple ping of each server and log it to a DB or what not but your requirements will really dictate the direction you go",0.0,False,2,7276 2021-02-11 14:08:05.040,Node JS detect connectivity to all Node JS programs,"Let me describe it as briefly and clearly as possible: I have 10 different copies of a node JS based program running on 10 different desktops. I want to create a Node JS based (or any other technology) web app deployed on a server which will check if these 10 programs are online or not. Any suggestions as to how I can implement this? Note: The node JS based desktop apps are running on electron.","You can use 2 most probable ways. if you want to know immediately whether out of 10 programs, if any of them goes offline then you should use Socket.io Your server nodejs program will act as server and your 10 desktop program will work as client. Your 10 client socket connection will connect with server socket connection and server socket can check whether socket client is still connected or not based on Ping/Pong concept of socket. in brief, Ping/pong technique in which server sends Ping event on socket connection and client will receive server's ping event and send Pong event back to server. if client is not sending Pong event back in predefined time interval on getting Ping event then that client is offline or disconnected. You can periodically (say every 1/5/10 minutes etc ) call simple HTTP request and check if response status is 200 or not. If any of the 10 desktop program is offline then you will know it by response status whether it is 200 or not.",0.0,False,2,7276 2021-02-12 23:08:11.587,How to to manually recover the a PIP corrupted installation?,"I do not have administrative privileges' on my Windows 10 workstation. The IT department installed Python 2.7 as my request but I proceed a PIP upgrade without the ""--user"" setting, and now the already installed PIP got corrupted and I do not know how to recover it. The corrupted PIP always return syntax error on lib\site-packages\pip_internal\cli\main.py"", line 60 sys.stderr.write(f""ERROR: {exc}"") I can not run again the --upgrade or get-pip I can write in the Python folder so I can change the main.py file. Is there a way to manually recover the installation (without sudo)? I need to reinstall the Python?","It would be better to reinstall Python, yes. It would be better to install a version of Python that was actually still supported, such as 3.6 or newer.",0.0,False,1,7277 2021-02-13 11:32:08.670,Get icon of a process (like in gnome-system-monitor) to be used with Gtk and python,"I have been working on a project which involves me to get the icon from the icon theme used on Linux so that I can use it with the Gtk Pixbuf like how Gnome-system-monitor displays the icon for all the process, the same thing I want to achieve. Any ideas about how to do this? I am using python with Gtk on PopOS 20.10.","Gio.AppInfo in the Gtk library stack is a good point to start. If you are looking for the approach that is used by the gnome-system-monitor then the prettytable.c file will the one you need to check. There is one more approach, scanning the /usr/share/application/ directory and creating a file monitor for this directory. All icons of the application are that are in the menu can be found here.",0.2012947653214861,False,1,7278 2021-02-14 00:46:21.650,Django how to change a vallue of a field that received error,"Thanks for your time. Basically, what I'm trying to do is to set a object from a database list (.csv) and if i get an ValueError I would like to set that field value and keep adding data ValueError: Field 'age' expected a number but got 'M' I'm quite sure that's a doc for this, but I've been reading for some time and hasn't found.","How about filtering the data once you receive it? For example lets say age field expects an Integer, and before you save it you could check if the data is an Integer. But I also think the most efficient way is using try except.",1.2,True,2,7279 2021-02-14 00:46:21.650,Django how to change a vallue of a field that received error,"Thanks for your time. Basically, what I'm trying to do is to set a object from a database list (.csv) and if i get an ValueError I would like to set that field value and keep adding data ValueError: Field 'age' expected a number but got 'M' I'm quite sure that's a doc for this, but I've been reading for some time and hasn't found.","Using a simple 'try', 'except' block should work where you have a default value to use in 'except' before saving.",0.0,False,2,7279 2021-02-14 05:24:39.640,How to import postgresql database (.sql) file from AmazonS3 to AWS RDS?,"How to import postgresql database (.sql) file from AmazonS3 to AWS RDS? I am very new to AWS, and Postgresql. I have created a database using PgAdmin4 and added my data to the database. I have created a backup file of my database i.e. .SQL file. I have created a database instance on AWS RDS. I have uploaded my database file and several documents s3 bucket. I tried to integrate AWS S3 and RDS database using AWS Glue, but nothing is working for me. I am not able to figure out how to integrate S3 and RDS for importing and exporting datafrom S3 to RDS and vice versa. Can you please tell me how can I set up RDS and S3?",What you can do is install a pure python library to interact with rds and run the commands via that library just like you would do with any normal python program. It is possible for you to add libraries like this to run in your glue job. In your case pg8000 would work like a charm,0.0,False,1,7280 2021-02-14 14:03:12.133,How can I efficiently call a function in a loop with python?,"I am solving a stochastic differential equation and I have a function that contains an algorithm to solve it. So I have to call that function at each time step (it is similar to Runge Kutta's method but with a random variable), then I have to solve the equation many times (since the solution is random) to be able to make averages with all the solutions . That is why I want to know how to call this function in each iteration in the most efficient way possible.","The best way to implement a function on an iterable is to use the map function. Since map is written in C and is highly optimized, its internal implied loop can be more efficient than a regular Python for loop.",0.1016881243684853,False,2,7281 2021-02-14 14:03:12.133,How can I efficiently call a function in a loop with python?,"I am solving a stochastic differential equation and I have a function that contains an algorithm to solve it. So I have to call that function at each time step (it is similar to Runge Kutta's method but with a random variable), then I have to solve the equation many times (since the solution is random) to be able to make averages with all the solutions . That is why I want to know how to call this function in each iteration in the most efficient way possible.","Some ways to optimize function calls: if the function arguments and results are always the same, move the function call out of the loop if some function arguments are repeated and the results for a given set of arguments are the same, use memoize or lru_cache However, since you say that your application is a variation on Runge-Kutta, then neither of these is likely to work; you are going to have varying values of t and the modeled state vector, so you must call the function within the loop, and the values are constantly changing. If your algorithm is slow, then it won't matter how efficient you make the function calls. Look at optimizing the function to make it run faster (or convert to Cython) - the actual call itself is not the bottleneck. EDIT: I see that you are running this multiple times, to determine a range of values given the stochastic nature of this simulation. In that case, you should use multiprocessing to run multiple simulations on separate CPU cores - this will speed things up some.",1.2,True,2,7281 2021-02-16 10:24:00.567,How to send DirectInput keys to an inactive window in Python,"I would like to send DirectInput keys to an inactive window without interfering with my actual mouse. I tried using PostMessage, SendInput and SendMessage but pywin32 uses virtual keycodes while ctypes does work with DirectInput. I have no idea how I can make it send in an inactive window.","Try using this, it manages to work for me send the keystrokes to the inactive window, Use (but add error checking) hwndMain = win32gui.FindWindow(""notepad"", ""​prueba.txt: log keys"") hwndEdit = win32gui.FindWindowEx",-0.3869120172231254,False,1,7282 2021-02-16 10:32:15.153,ResNet family classification layer activation function,"I am using the ResNet18 pre-trained model which will be used for a simple binary image classification task. However, all the tutorials including PyTorch itself use nn.Linear(num_of_features, classes) for the final fully connected layer. What I fail to understand is where is the activation function for that module? Also what if I want to use sigmoid/softmax how do I go about that? Thanks for your help in advance, I am kinda new to Pytorch","No you do not use activation in the last layer if your loss function is CrossEntropyLoss because pytorch CrossEntropyLoss loss combines nn.LogSoftmax() and nn.NLLLoss() in one single class. They do they do that ? You actually need logits (output of sigmoid) for loss calculation so it is a correct design to not have it as part of forward pass. More over for predictions you don't need logits because argmax(linear(x)) == argmax(softmax(linear(x)) i.e softmax does not change the ordering but only change the magnitudes (squashing function which converts arbitrary value into [0,1] range, but preserves the partial ordering] If you want to use activation functions to add some sort of non-linearity you normally do that by using a multi-layer NN and having the activation functions in the last but other layers. Finally, if you are using other loss function like NLLLoss, PoissonNLLLoss, BCELoss then you have to calculates sigmoid yourself. Again on the same note if you are using BCEWithLogitsLoss you don't need to calculate sigmoid again because this loss combines a Sigmoid layer and the BCELoss in one single class. check the pytorch docs to see how to use the loss.",1.2,True,1,7283 2021-02-17 21:38:32.087,Selenium/Python - Finding Dynamically Created Fields,"Newbie here... 2 days into learning this. In a learning management system, there is an element (a plus mark icon) to click which adds a form field upon each click.  The goal is to click the icon, which generates a new field, and then put text into the new field.  This field does NOT exist when the page loads... it's added dynamically based on the clicking of the icon. When I try to use ""driver.find_element_by_*"" (have tried ID, Name and xpath), I get an error that it can't be found. I'm assuming it's because it wasn't there when the page loaded. Any way to resolve this? By the way, I've been successful in scripting the login process and navigating through the site to get to this point. So, I have actually learned how to find other elements that are static. Let me know if I need to provide more info or a better description. Thanks, Bill","Apparently I needed to have patience and let something catch up... I added: import time and then: time.sleep(3) after the click on the icon to add the field. It's working!",0.0,False,1,7284 2021-02-18 12:02:23.297,How to push the notification on web browser using django,I create a Todo web application in Django and i deploy it on Heroku. I want to know how can i push the notification in my browser for upcoming task.Thanks in advance.,"You should use websockets and async functionality of Django to be able to push realtime notifications as they occur. Basic http protocol does not give you such functionality.",0.6730655149877884,False,1,7285 2021-02-19 06:19:10.787,Django User.date_joined.date using UTC time?,"In my template, I want to show the join date of a user, so I am using {{ user.date_joined }} which shows the date and time (in local time zone - same as what is shown in the admin panel). To just show the date, I use {{ user.date_joined.date }}, but it seems to be converting the date and time to UTC before showing the date (I am in EST/EDT - I never remember which is which). For example: {{ user.date_joined }} ==> Feb. 18, 2021, 7 p.m. {{ user.date_joined.date }} ==> Feb. 19, 2021 Is there a way for me to change this so that it shows the same date as the full date and time?","Found a solution/workaround for anyone else with a similar question. Instead of using {{ user.date_joined.date }} like a traditional datetime object, I used {{ user.date_joined|date }}",1.2,True,1,7286 2021-02-19 16:21:47.433,Solving ModuleNotFoundError: Importing the module WoE and manipulating sys.path.append to allow my notebook to identify the new module,"I just tried to install package WoE using pip which works fine. Then in Jupyter Notebook when I try to run the command: from WoE import WoE I receive an error that there is no module named ""WoE"" I keep trying to figure out how to use sys.path.append to make this module work but I cannot figure it out. Any help or advice would be appreciated!","Try running command prompt as admin and then doing the command py -m pip install WoE. If that still doesn't work try restarting your computer, it could just be an issue with Jupyter not seeing the module yet. You can also do py -m pip show WoE and if that gives you a file location then that means it did install correctly.",1.2,True,1,7287 2021-02-19 20:44:54.213,"my colab notebook crash, how can i resolve it?","i got this message when i wanted run a beysian personalized ranking by GPU in colab, How can i resolve this problem ? message is : GPU training requires factor size to be a multiple of 32 - 1. Increasing factors from 100 to 127.","It could be that google colab is running out of ram why? because we are loading all data at once.or generating all data at once. example : google colab having 12 GB of ram. and it running out of ram. So what i would suggest is: we can process that data in chunks. if the total size of the data is 12 GB. than we can divide it into chunk(file) of 1 Gb. 12 GB data = 12 chunks(files) of 1 Gb so now we have to load only 1 GB file into ram. which won't crash our notebook.",0.0,False,2,7288 2021-02-19 20:44:54.213,"my colab notebook crash, how can i resolve it?","i got this message when i wanted run a beysian personalized ranking by GPU in colab, How can i resolve this problem ? message is : GPU training requires factor size to be a multiple of 32 - 1. Increasing factors from 100 to 127.",On Colab a multitude of things could lead to crash. It's likely that you ran out of RAM or out of GPU memory.,0.0,False,2,7288 2021-02-20 02:07:25.003,Python OOP Design Pattern for Calculation Flows,"I am relatively new to oop and had a quick question about the best way to approach coding a certain type of calculation. I'm curious if there's an established design pattern to approach this sort of problem. Consider a chemical process flow where you convert materials (a,b) with attributes such as temperature, pressure, flow rate, etc. into a final product c. To get there, I need unit operations D,E,F... each with its own set of attributes (cost, size, etc.). I would only need information flow in one direction as closed loops will probably increase the complexity (if not, I would really appreciate insight into how closed loops would work). a,b --> D --> E --> F --> c Ultimately I would like to be able to do a system cost analysis, where I would sum up the cost attributes of D,E,F. My current thought process to approach this is to define a ""materials"" object, then have D inherit materials, E inherit D... c inherit F then lastly a ""system"" object inherit c to analyze the system variables. Since I would like to be able to swap out D,E,F for say G,H,I, there also needs to be code for conditional inheritance where D must be able to accept inputs a,b (based on defined attributes) and E be able to inherit D for the same reason. One of the things I'm unsure of is how object c would be able to understand how to sum up attributes of all the inherited objects (probably based on some consistent naming convention of objects/attributes?). Sorry for the somewhat lengthy question - if you are aware of AspenPlus, I'm looking to replicate a smaller scale version of this (ie no solvers) in Python. Thank you for reading through this!","I would argue that in your case functional programming is actually more suited than OOP since what it boils down to is a set of operations process on ""blank"" materials that results in a new material, well actually the same with different properties. If I was restrained to OOP I would create different classes : MaterialType which is basically a string or enum (of a, b & c) ExternalProperties for temperature/pressure, etc. Material which contains the Material_Type and various properties/functions aimed at transforming the material type so for instance it could contain a transform function with an unbounded list of ExternalProperties Laboratory to do all the operations Here object c would be the MaterialType which the Material can calculate without inheriting of everything else. It's hard to propose an accurate concretisation since your example is very abstract but I think inheritance brings more problems than solutions here.",0.0,False,1,7289 2021-02-20 10:01:38.690,How to find multiple equally distributed means of a numpy array?,"Suppose I have a list of 100 numbers. I can find the mean by summing and dividing by the number of elements. But how can I find two values, one that gravitates towards the left of the list (assuming the list is ordered) and one towards the right, so that the list is equally divided into three blocks? Sorting the array and taking the 33th and the 66th elements doesn't work because I could have all 1's before the 33th position and bigger values after, so the 33th position would be too early in the array. Those two 'means' depend on the values of the array and not solely on the indices. I'm sure what I'm trying to do has a proper naming but I can't really remember it now.","You could try numpy.quantile for example np.quantile(your_list, [0.33, 0.66]) I think should do the trick",0.0,False,1,7290 2021-02-20 15:45:37.403,How do I check if 2 numbers are equal to a specific ratio in Python?,"For example: I want to know wether 5 and 500 have a 1:100 ratio, I also want to know how I can see if they roughly have the same ratio or not, how do I do this??","If you need to know whether a/b and c/d are roughly the same ratio, then (in Python 3 only) you can do math.abs(a/b - c/d) < margin. The smaller the positive number margin is, the more close the ratios have to be for the expression to return True. margin = 1/100 would be within a percentage point.",1.2,True,1,7291 2021-02-21 01:11:04.583,Real random python numbers,"i need to create random numbers in python, i have been using the random library, but is this library really random or is it just pseudo random? and if it is pseudo random how can I get real random numbers in python?","All computer generated random numbers are pseudo-random. If you want a more ""randomized"" version, you can use the secrets module instead of the random module.",0.9950547536867304,False,1,7292 2021-02-21 02:28:52.117,Connect face recognition model to database efficiently,"I'm having a hard time connecting my facial recognition system (realtime) to the database. I am using python language here. Try to imagine, when the system is doing REAL-TIME face detection and recognition, it will certainly form frame by frame during the process (looping logic), and I want if that face is recognized then the system will write 'known face' in the database. But this is the problem, because what if the upload to the database is done repeatedly because the same frame is continuously formed? the question is, how do you make the system only upload 1 data to the database and if the other frames have the same image, the system doesn't need to upload data to the database?","you dont show any code, but to do what you're asking you want to have a flag that detects when a face is found and sets the variable. Then clear the variable once the flag leaves the frame. to account for false positives you can wait 4-5 frames before clear the flags and see if the face is still in the frame (i.e someone turns their head and the tracking looses the face)",0.0,False,1,7293 2021-02-21 19:35:25.623,send email verfication link using django-email-verification with celery,"I am using django-email-verification for sending verification link to email of the user but it tales time to send email , i want to send mail with celery for the same to speed it up , please guide me how can i add celery configs?",Celery isn't going to make this run any faster. What Celery will do for you is make the task asynchronous.,0.0,False,1,7294 2021-02-22 13:32:49.697,How to access active warning filters list?,"In python, after I set some filter with warnings.filterwarning (or some package I import does), how can I access the list of active filters? I tried sys.warnoptions but it always gives me an empty list.",I found it looking at the source code. It's warnings.filters.,0.3869120172231254,False,1,7295 2021-02-25 04:35:59.877,how to inject code with a batch into a batch that has existing code,"do I convert it a txt file? how do I inject the new line in between the other lines? I'm trying to inject a wallet address to a simple mining batch file without needing to physically open it prior. pretty much the last step to automating my mining rigs for full self sufficiency. if anyone has any way of doing this, please describe in full detail or show an example, as I am self taught and in way over my head for a project that's exceeding expectations before release lol","I would read in the entire file with f.readlines() so you get a list of strings (where each string represents a line in the file), write some logic that determines where the new string should go in between, and then re-write that to a file after.",0.0,False,1,7296 2021-02-25 14:02:41.320,Load new model in background,I made an API for my AI model but I would like to not have any down time when I update the model. I search a way to load in background and once it's loaded I switch the old model with the new. I tried passing values between sub process but doesn't work well. Do you have any idea how can I do that ?,"You can place the serialized model in a raw storage, like an S3 bucket if you're on AWS. In S3's case, you can use bucket versioning which might prove helpful. Then setup some sort of trigger. You can definitely get creative here, and I've thought about this a lot. In practice, the best options I've tried are: Set up an endpoint that when called will go open the new model at whatever location you store it at. Set up a webhook on the storage/S3 bucket that will send a quick automated call to the given endpoint and auto-load that new item Same thing as #1, but instead you just manually load it. In both cases you'll really want some security on that endpoint or anyone that finds your site can just absolutely abuse your stack. Set a timer at startup that calls a given function nightly, internally running within the application itself. The function is invoked and then goes and reloads. Could be other ideas I'm not smart enough (yet!) to use, just trying to start some dialogue.",0.0,False,1,7297 2021-02-25 14:34:22.237,Created an EXE file from .py and it's detected as virus,"I was able to convert a .py file to and exe file, however when I try to send it via Gmail, it detects as a virus. Also, when trying to transfer the file on a USB flash drive, the computer says it's a virus. Any ideas on how to fix this?","Apart from getting your exe signed (not really a viable option unless you're working on a big and important project) or writing the program in a natively compiled programming language like C, no, there is no way to avoid the detection since the Py2Exe converter you're using embeds the Python interpreter and all needed dependencies into the binary, which is a technique often used by viruses. EDIT FOR: I didn't actually get the fact that Gmail is the thing blocking the exe, not your AV. Well, as said by other comments, Gmail blocks certain files by default. Try adding the exe to a zip or rar archive and send that instead of the plain .exe.",1.2,True,1,7298 2021-02-25 16:00:57.500,Is there a pandas method to find the 4th 5-quantile of a dataset?,"I was recently trying to solve a data science test. Part of the test was to get the number of observations in a dataset for which the variable X is less than the 4th 5-quantile of this variable X. I don't realy understand what they meant by the 4th 5-quantile! I tried using pandas df.quantile function but I wasn't able to figure out how to use it in my case",4th 5-quantile translates value = data.quantile(4/5),0.0,False,1,7299 2021-02-25 16:17:48.080,pymysql SELECT * only detecting changes made externally after instantiating a new connection,"I have two applications that access the same DB. One application inserts data into a table. The other sits in a loop and waits for the data to be available. If I add a new connection and close the connection before I run the SELECT query I find the data in the table without issues. I am trying to reduce the number of connections. I tried to leave the connection open then just loop through and send the query. When I do this, I do not get any of the updated data that was inserted into the table since the original connection was made. I get I can just re-connect and close, but this is a lot of overhead if I am connecting and closing every second or 2. Any ideas how to get data that was added to a DB from an external source with a SELECT query without having to connect and close every time in a loop?","Do you commit your insert? normally the best way is you close your connection, and it is not generating very overhead if you open a connection for the select query.",0.0,False,1,7300 2021-02-26 12:47:15.790,Subtracting angles of complex valued matrix,"Let's say I have two complex images Z_1 and Z_2. I want to make a relative-phase map of the second image with respect to the first. This means: Z_2_relative = Z_2 * np.exp(-1j * np.angle(Z_1)) This creates a new complex valued matrix where the complex-phase should now be given by np.angle(Z_2_relative) == np.angle(Z_2) - np.angle(Z_1) But according to python these two are not equal. I bet it has something to do with the np.angle function.. but I cant pinpoint it, or know how to fix it... PS: Sorry, cant make a reproducible piece of code atm. Can do it later today","Bah.. stupid question. Sorry for anyone that read it. If you do module 2pi, then everything is the same",0.0,False,1,7301 2021-02-26 16:27:38.003,Python Thread() - Function Arg Tuple Not Working?,"I'm attempting to thread a function call in my Python catastr^H^H^H^H^H^Hreation, and I've read up on how to use the threading.Thread() call. My function takes a simple string argument, so theoretically it should be as easy as: thread = threading.Thread(target = my_func, args = (string_var, )) bearing in mind that the args() needs to be a tuple. Got it. However, it appears as though I'm still doing something wrong because I continually get the barffage from Python: TypeError: my_func() takes 1 positional argument but 2 were given I'm a bit stumped here. Any guidance? Thanks!","Seems the issue is that because it's a method (thanks gribvirus74 for the idea) and I'm attempting to thread it, it won't inherit the self. And that appears to be the issue. I moved the function outside of the class and called it with the Thread(). Works fine now.",1.2,True,1,7302 2021-02-27 22:20:08.067,"How to get information from an image of a document, like name, CPF, RG, on python?","I'm sorry for the title of my question if it doesn't let clear my problem. I'm trying to get information from an image of a document using tesseract, but it doesn't work well on pictures (on print screens of text it works very well). I want to ask if somebody know a technique that can help me. I think that letting the image black and white, where the information I want is in black would help a lot, but I don't know how to do that. I will be glad if somebody knows how to help me. (:","Using opencv might help to preprocess the image before passing it to tesseract. I usually follow these steps Convert the image to grayscale If the texts in the image are small, resize the image using cv2.resize() Blur the image (GaussianBlur or MedianBlur) Apply threshhold to make the text prominent (cv2.threshold) Use tesseract config to instruct tesseract to look for specific characters. For example If the image contains only alphanumeric upper case english text then passing config='-c tessedit_char_whitelist=0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"" would help.",1.2,True,1,7303 2021-02-28 22:12:06.673,VSCode and Anaconda Environments: How to have dev extensions/environment and my code under development use different Anaconda environments,"In VS Code, many extensions, such as Tab Nine and Lint, rely on specific Python packages to function. On the other hand, the code I develop may need a different set of packages. Because there is the potential for package conflict and because we want the environment that we develop code to mimic the production environment, it is convenient to have the dev environment/extensions use one Anaconda Environment and the code I develop to use a different Anaconda Environment. But I am not sure how to configure this. Can someone help?",Down in the bottom left corner of VS code you can manually select the python environment depending on which codebase you are working with. The selection can be saved in the settings.json file so you don't have to manually reselect each time.,0.0,False,1,7304 2021-03-01 16:23:42.277,QT View/Model Login dialog,"So I am trying to build a login dialog for my application using qt/python. I got confused by QT's view/model architecture. QT provides models and view for tables, lists etc., but how do I go about implementing a login dialog using this architecture? I use a ui file that I created with QtDesigner. Should I create a user model that interfaces with the DB and retrieves user data, handling the login process, and return this result to the view? (view and controller combined, as per QT's terminology) I would like to use the same architecture throughout the application, but I got confused with this one. Do I even need a model for this?",Models are for binding data to view. You can create list model with user/password fields and use QWidgetMapper to bind it to two QLineEdits but there's no much use in it since there's no much data and no complicated interactions.,1.2,True,1,7305 2021-03-01 21:24:57.727,How would one go about making a directory (mkdir) in python with kivy on android(buildozer)?,"So im trying to simply just trying to make a directory with kivy and i simply cant get it to work. I a useing the os.mkdir() function. I have tried to just simply os.mkdir(""a""), but i couldnt find any directory named a (after doing a full phone search, with the phone plugged in to my pc). I have alos tried os.getcwd() as in os.mkdir(os.getcwd()+""a""), but to no avail. To put it simply i am lost, can't find anything about it online either... So if you know how i would greatly appreciate to be enlightend on the subject, thx in advance. And i am importing os, also tried to run os.mkdir before importing kivy.","I have tried to just simply io.mkdir(""a"") There is no io.mkdir - do you mean os.mkdir? The directory will be created inside the current directory of the script, which is a folder inside the app's private directory as defined by Android. That means you should see your new directory in e.g. os.listdir(""."").",1.2,True,1,7306 2021-03-02 09:49:14.303,If I run an http server in my user account (linux cluster) how to enable other users to access it?,I want to deploy a flask app with http.server (ngnix not installed by admin). I want any user who logs into the cluster to access it. Is it possible?,"HTTP server interfaces are visible to all users that are connected to a machine that has direct network access to the machine your server is running on. If you need them to access the interface just provide the ip address and port where the server is running and the will be able to access it as users of the Flask app you are running. Just make sure you allow the users to access the needed resources.",0.3869120172231254,False,1,7307 2021-03-02 16:20:31.310,Django admin many-to-many - how to show additional fields?,"For establishing many-to-many relationships, django admin has a nice widget called 'filter_horizontal'. The problem is - it only displays primary key of the related table. How do I add other fields from the related table? For example, if I have a many-to-many relationship in my Order model with User model, in 'Order' django admin I can only see User's primary key(id). How do I add their name into the widget?",Turns out it is changed in str method for the User model,0.0,False,1,7308 2021-03-02 17:28:04.520,Installing packages in python installed using home-brew,"Hey everyone I installed Python3.9 on my Mac using homebrew package manager but now I do not know how to install packages to it for use Can anyone please tell me, thanks !","You should first do some research on the Python virtual environment, but the final answer to your question is to use pip install for installing Python packages. Be aware that there are other options out there, but pip is the most prevalent.",0.0,False,1,7309 2021-03-02 20:56:43.463,how do i align text in kivymd button?,"i need to halign text in kivymd button to the left and i found solutions for default kivy like text_size: self.size and halign='left', is button still a label in kivymd like in kivy? If no then how do you align text inside it?","Try the following: text_align:'center'",0.0,False,1,7310 2021-03-04 12:09:28.717,"Anaconda on Windows subsystem for Linux (WSL) uses the ""wrong"" anaconda when creating a Jupyther Notebook","I am using Windows subsystem for Linux WSL with the Ubuntu App (Ubuntu 20.04 LTS). I have installed Anaconda (Anaconda3-2020.11-Linux-x86_64) on my Windows 10 Education 1909. I have Jupyter notebook, and can run this in the Firefox on my computer and it seams to be working properly. However when I try to install packages such as: Ubuntu console: pip install scrapy Then the Jupyter notebook can not find it. Jupyter notebook: import scrapy I am currently working in the base environment, but I believe that Jupyter is actually running python from a different source (I also have Anaconda on my Windows). I confirmed this by running: import sys and sys.version both in the WSL and in the Jupyter notebook. Jupyter notebook returns: '3.6.6 |Anaconda, Inc.| (default, Oct 9 2018, 12:34:16) \n[GCC 7.3.0]' WSL returns: '3.8.5 (default, Sep 4 2020, 07:30:14) \n[GCC 7.3.0]' confirming that the ""wrong python is used"". I am hesitant to delete my Windows Anaconda since I have my precious environments all set up there and are using them constantly. The spessific package that forces me to linux can be found at ""http://www.nupack.org/downloads"" but requires registration for downloads. I do not have Anaconda or python in my Windows environment variables. I would be happy If I either would know where to install my packages (as long as they are in Linux), or if someone knows how to force Jupyter to use the Anaconda from WSL.","Thanks to Panagiotis Kanavos I found out that I had both Anaconda3 and Miniconda3 installed and that the WSL command line used the miniconda3 version while Jupiter Notebook used Anaconda3. There is probably a way of specifying which version to use but for me I simply deleted Miniconda and it now works.",0.0,False,1,7311 2021-03-04 21:42:34.447,How to make sure my jupyter notebook is runnable on any other computer or on any jupyter Lab?,"An analytic task has been given to me to solve it by python and return back the result to the technical staff. I was asked to prepare the result in a jupyter notebook and such that the resulting code would be fully runnable and documented. Honestly, I just started using jupyter notebook and generally found it pretty useful and convenient in generating reports integrated with codes and figures. But I had to go into some level of difficulty when I wanted to use specific packages like graphviz and dtreeviz, which was beyond doing a simple pip install xxx. So, how should I make sure that my code is runnable when I do not know what packages are available at the destination Jupyter notebook of the next guy who wants to run it or when they want to run it using a Jupiter Lab? especially regarding these particular packages!","One solution for you problem would be to use docker to develop and deploy your project. You can define all your dependencies, create your project and build a docker image with them. With this image, you can be sure that anyone who is using it, will have the same infrastructure like yours. It shouldn't take you a lot of time to learn docker and it will help you in the future.",0.3869120172231254,False,1,7312 2021-03-06 11:01:54.253,Multiple applications inside a Django project,I am creating an ERP web application using Django. How can i connect multiple apps inside of a project with one database. I am using the PostgreSQL database and also how can i centralized the database for all modules of ERP. How can i perform operations in other module and see if user is authenticated or not,Your apps use only the database(s) set up in your settings.py file.,0.0,False,1,7313 2021-03-06 12:33:06.013,Tweets scraping - how to measure tweeting intensity?,"I am looking for a method to get information of a ""trend"" regarding some hashtag/key word on Twitter. Let`s say I want to measure how often the hashtag/key word ""Python"" is tweeted in time. For instance, today, ""Python"" is tweeted on average every 1 minute but yesterday it was tweeted on average every 2 minutes. I have tried various options but I am always bouncing off the twitter API limitations, i.e. if I try to download all tweets for a hashtag during the last (for example) day, only a certain franction of the tweets is downloaded (via tweepy.cursor). Do you have any ideas / script examples of achieving similar results? Libraries or guides to recommend? I did not find any help searching on the internet. Thank you.","Try a library called: GetOldTweets or GetOldTweets3 Twitter Search, and by extension its API, are not meant to be an exhaustive source of tweets. The Twitter Streaming API places a limit of just one week on how far back tweets can be extracted from that match the input parameters. So in order to extract all historical tweets relevant to a set of search parameters for analysis, the Twitter Official API needs to be bypassed and custom libraries that mimic the Twitter Search Engine need to be used.",0.0,False,1,7314 2021-03-08 00:48:37.863,How to use dhooks to find the most recent message sent in a channel,I want to know how to get the most recent message sent in a channel of a discord server with discord webhooks in python? I have not tried anything yet.,"Webhooks are only meant for sending messages, not reading messages in a channel. The only way to get the last message from the channel is if you have a bot user in the server that can read message history in that channel.",0.0,False,1,7315 2021-03-08 14:41:21.523,output raw query string with python requests library,"I am looking for a way to print out the raw http query string when I use the request library in python3. It's for troubleshooting purposes. Anyone has an idea how to do this. I tried to use prepared requests, but it is not what I'm looking for.Any suggestion? thanks","import requests response = requests.get('https://api.github.com') You can use: response.text or response.content or response.raw",1.2,True,1,7316 2021-03-08 16:53:59.537,how to add the newly created conda interpreter to a specific project,"I wanted to import the albumentations package to run a deep learning task, but it has conflicts and failed when I tried to install it in the current environment, so I used conda create --name to create a new one, and in the new environment the albumentations package is installed successfully, but I can not find it in the python interpreter setting, and the project keeps showing ""No module named 'albumentations' "", so , how to fix this problem?","I just tried create a new Base environment in the Setting-->Python Interpreter--> add --> Virtualenv Environment , and in the new Base environment, the newly created interpreter will appear below the Existing environment option.",0.0,False,1,7317 2021-03-10 08:45:21.367,AWS Managed Airflow - how to restart scheduler?,"I have a problem parsing DAG with error: Broken DAG: [/usr/local/airflow/dags/test.py] No module named 'airflow.providers' I added apache-airflow-providers-databricks to requirements.txt, and see from the log that: Successfully installed apache-airflow-2.0.1 apache-airflow-providers-databricks-1.0.1 apache-airflow-providers-ftp-1.0.1 apache-airflow-providers-http-1.1.1 apache-airflow-providers-imap-1.0.1 apache-airflow-providers-sqlite-1.0.2 apispec-3.3.2 attrs-20.3.0 cattrs-1.3.0 clickclick-20.10.2 commonmark-0.9.1 connexion-2.7.0 flask-appbuilder-3.1.1 flask-caching-1.10.0 gunicorn-19.10.0 importlib-resources-1.5.0 inflection-0.5.1 isodate-0.6.0 marshmallow-3.10.0 marshmallow-oneofschema-2.1.0 openapi-schema-validator-0.1.4 openapi-spec-validator-0.3.0 pendulum-2.1.2 python-daemon-2.3.0 rich-9.2.0 sqlalchemy-jsonfield-1.0.0 swagger-ui-bundle-0.0.8 tenacity-6.2.0 termcolor-1.1.0 werkzeug-1.0.1 But the scheduler seems to be stuck: The scheduler does not appear to be running. Last heartbeat was received 19 hours ago. How can I restart it?","well after remove all deps in the requirements , the worker in mwaa run normally , now can try test the bad deps",0.0,False,1,7318 2021-03-10 09:46:27.187,How to implement OCL (Object Constraint Language) in Python,"I am working on Google Colaboratory, and I have to implement OCL (Object Constraint Language), I searched a lot, but I didn't find how to implement it. Can someone give me an idea please?","It is surely possible for you to implement OCL, duplicating the efforts of one of the existing Open Source implementations such as Eclipse OCL or USE. There is an official OMG specification that will define what you need to do, however it has many deficiencies that will require research to solve and design around. I would be surprised if you can implement a 'full' implementation of OCL from scratch with plausible accuracy in less than a person year. I suspect that you have mis-stated what you want to do or have misunderstood what someone has instructed you to do.",0.0,False,1,7319 2021-03-11 07:02:59.187,How to send messages in discord without using bot application,"I want to know how I can send messages in discord, without creating a bot. Like I want the program to send messages through my own account. Most of the results I got when I searched this up is to create a bot. But I would like to know if there's a way to do it without creating the bot. Thanks :)","To access discord with a bot trough your own account, you can't use a discord bot. What you could do, is to automate ""your input"" in discord. Imagine a google sheet for example and now recording your input to copy the first line, delete it afterwards, then paste it in discord and send the message. now you could repeat this for every line in the file. (You can find such program using google) BUT this solution restricts you to your input. Any events discord provides like on_member_join for example aren't useable for this approach. It's more a user bot than a discord bot",0.0,False,1,7320 2021-03-13 12:13:48.727,Downloading QtDesigner for PyQt6 and converting .ui file to .py file with pyuic6,"How do I download QtDesigner for PyQt6? If there's no QtDesigner for PyQt6, I can also use QtDesigner of PyQt5, but how do I convert this .ui file to .py file which uses PyQt6 library instead of PyQt5?",You can install QtCreator or use command line pyuic6 -o main.py main.ui,1.2,True,1,7321 2021-03-13 23:07:18.970,Is there a Python function to mark the beginning and end of sentences with a specific character after tokenizing?,"with tokenize I know you can split text into individual words, but I am confused on how to add characters to indicate the beginning and end of sentences after tokenizing. In my case I want to put ^ to indicate the beginning of the sentence and $ to indicate the end of the sentence. I am asking because I am trying to implement bigram probability models and this is for a school assignment, which is why this is a reinvent the wheel problem.","tokenize is a part of python distribution, and intended to parse python source code. Is this actually a good tool for your problem? Have you tried nltk?",0.0,False,1,7322 2021-03-14 18:07:40.313,Is it possible to write python code inside Flutter using Android Studio?,"I'm working on Flutter project in Android Studio platform and I faced a problem with how to write and run python API code inside my Flutter project without letting it as a backend code in another platform? since when I run my Flutter project that connected with python API code in another platform as a backend using post method, it's worked with the emulator but it does not work with my physical android device. So is there any recommend solution for either the first problem or the second. Thanks.","No it's not possible to write python code Inside Flutter code But you can write your api in different framework like Django ,mongodb and use it in your Flutter app",0.0,False,1,7323 2021-03-14 19:32:44.830,How do I include a data-extraction module into my python project?,"I am currently starting a kind of larger project in python and I am unsure about how to best structure it. Or to put it in different terms, how to build it in the most ""pythonic"" way. Let me try to explain the main functionality: It is supposed to be a tool or toolset by which to extract data from different sources, at the moment mainly SQL-databases, in the future maybe also data from files stored on some network locations. It will probably consist of three main parts: A data model which will hold all the data extracted from files / SQL. This will be some combination of classes / instances thereof. No big deal here One or more scripts, which will control everything (Should the data be displayed? Outputted in another file? Which data exactly needs to be fetched? etc) Also pretty straightforward And some module/class (or multiple modules) which will handle the data extraction of data. This is where I struggle mainly So for the actual questions: Should I place the classes of the data model and the ""extractor"" into one folder/package and access them from outside the package via my ""control script""? Or should I place everything together? How should I build the ""extractor""? I already tried three different approaches for a SqlReader module/class: I tried making it just a simple module, not a class, but I didn't really find a clean way on how and where to initialize it. (Sql-connection needs to be set up) I tried making it a class and creating one instance, but then I need to pass around this instance into the different classes of the data model, because each needs to be able to extract data. And I tried making it a static class (defining everything as a@classmethod) but again, I didn't like setting it up and it also kind of felt wrong. Should the main script ""know"" about the extractor-module? Or should it just interact with the data model itself? If not, again the question, where, when and how to initialize the SqlReader And last but not least, how do I make sure, I close the SQL-connection whenever my script ends? Meaning, even if it ends through an error. I am using cx_oracle by the way I am happy about any hints / suggestions / answers etc. :)","For this project you will need the basic Data Science Toolkit: Pandas, Matplotlib, and maybe numpy. Also you will need SQLite3(built-in) or another SQL module to work with the databases. Pandas: Used to extract, manipulate, analyze data. Matplotlib: Visualize data, make human readable graphs for further data analyzation. Numpy: Build fast, stable arrays of data that work much faster than python's lists. Now, this is just a guideline, you will need to dig deeper in their documentation, then use what you need in your project. Hope that this is what you were looking for! Cheers",0.0,False,1,7324 2021-03-15 13:40:54.937,How to safely send a user data in API call,Created a Flash Restful API with various end points for my website. Some endpoints need the users username and password to get user specific data. I’m currently sending these as parameters in the API call but I’m assuming this isn’t secure so how does one do this safely?,you can make a seperate api route that acts as a login and returns a sessionID/token on a successful login that can be used for authenticating to those endpoints you mentioned.,0.0,False,1,7325 2021-03-15 14:34:44.450,How to call function in GCP Instance from Cloud Function,"I have created an instance on GCP to run some machine learning model for an app I am working on for a little project. I want to be able to call one of the methods in one of the files from my app and I thought a Cloud Function would be suitable. To make this question simpler, let's just imagine I have a file in my instance called hello.py and a method in this file called foo(sentence). And foo(sentence) simply returns the sentence parameter. So how do I call this method foo in python.py and capture the output? Thanks","At Google Cloud (And Google also), ""all is API"". Thus, if you need to access from a product to another one, you need to do this through API calls. If your Cloud Functions needs to invoke a script hosted on a Compute Engine VM instance, you need to expose an API on this Compute Engine instance. A simple flask server is enough, and expose it only on the private IP is also enough. But you can't directly access from your Cloud Functions code to the Compute Engine instance code. You can also deploy a Cloud Functions (or a Cloud Run if you need more system packages/libraries) with the model loaded in it, and like this perform all the computation on the same product.",0.6730655149877884,False,1,7326 2021-03-15 20:19:51.523,In pygame how can i create a data struct that keeps track of resizing events and the coordinates of objects?,"I'm looking to keep my mouse events in sync with my objects after resizing the screen. I'm told I need to create a data structure to keep track of: Resizing events New coordinates to match the resize How can I accomplish this using simple algebraic equations and integrate it into a resize event for accurate updating?","Do it the other way around create a virtual game map, scale to the size of the window when drawing the scene and scale to the size of the virtual map when receiving an event.",1.2,True,1,7327 2021-03-15 20:36:20.657,Switch to panel - Python Selenium,"After a click, a mini banner (or a container drawer) opens, which I should click on it, but I can't interact with it. I was trying the ""driver.switchTo"" command but since there is no Iframe, I don't know how to do it. the body is this: Go ","I've had issues with this in the past, and largely I couldn't figure out what to do either. If you can just leave your computer alone during the process you can always try to use pyautogui to kind of cheat your way through it.",1.2,True,1,7328 2021-03-16 01:33:53.907,How to make a Turtle Longer,"I am working on a Python Turtle Snake Program, and I want to make my Turtle longer. By that, I mean that I increase the 1 Cube to 2 Cubes, then 3, etcetera, for my Snake Game. Can you please inform how I could do that with turtle? Thanks.","I once made a game like that. You can just create more turtles and use them as the body. Make the first turtle as the head of the snake. Then whenever it eats food,run a function that will create another turtle as a body component and put it in the previous position of head component. Repeat this everytime the snake eats a food. I am not so good in explaining,so sorry for any inconvenience : )",0.0,False,1,7329 2021-03-16 10:24:29.247,"How to make multiple screens in pygame? (As in, a ""menu"" screen, a ""main"" screen, a ""start"" screen, etc.)","I am very new to python and pygame and I'm currently making a very basic experiment with it. So far, I know how to draw an image on the screen, move it around, add a background, stuff like that. But what I have always been wondering is, how do I switch between screens in a game and how do I keep the code tidy when doing so? Every time I try to add a new thing to my already unstable code, it takes only a few lines to break it and it becomes a confusing mess. If for example, I want a start screen that shows the title and a ""press any key to continue"" kinda thing, how do I do it?","A quick fix: Make the entire screen white and then draw the second screen onto the first one. Then when you need the other screen, just refill the screen with black and then continue. This can be achieved by putting the screens in their own separate functions. Let me know if this helps out",0.0,False,1,7330 2021-03-16 20:08:03.970,multiple independent websockets connections,"I have been playing around with django channels + angular. I have created an app that simply sends notifications to front end with a counter 1,2,3,4. It works fine, except if I open the page in multiple tabs. I am also not able to disconnect from the websocket, I can use unsubscribe but it does not really close the connection but that's more kind of a angular question. Anyways how can I make my socket multithread, So if I make multiple requests from the same computer but from different tabs it will work and 2 different instances of the consumer will be created therefore, If I load 2 pages in the same computer the counter should be different independently increasing counter. Do I need redis for that ?","my url router was missing .as_asgi() this worked: URLRouter([path('wscrawpredict', CrawPredictConsume.as_asgi(),name=""wscraw"")])",1.2,True,1,7331 2021-03-17 10:08:27.943,How do I install python2.7 packages under anaconda with python3.8 already in place?,"So the default of anaconda is python 3.8, but you can invoke python2 by running python2 a_py_script.py. The issue comes from the fact that you'll need to import things (say biopython), and you can't import them as any conda install -c conda-forge biopython or pip install biopython will be understood to automatically slot it into python3.8 packages exclusively. I ask this because I have some python2.7 scripts that demand packages outside the default install scope and ideally I'd like to do this without having to create a new python=2.7 env and track down everything I need. I've tried pip2.7 install biopython and python2.7 -m pip install biopython to no avail. Could it be that I technically don't have python 2.7 even though I'm able to invoke it from command line via python2 because python3 just naturally has some special limited backwards compatibility to run my python2 scripts? (I did notice that conda list includes only 3.8 and no mention of 2.7) I've tried cloning my env but I don't know how to do it in such a way that swapts just the version of python. conda create --name py27test --clone base python=2.7 says too many arguments. I'd like to know if this is even advisible as my base environment I would presume is entirely built off of v3.8 so swapping out the python versions will just be bad time hence why this seems impossible?","You can't mix Python versions in a conda environment. You can call Python executables from outside your environment, but that's unadvisable for anything requiring dependencies. If you must use Python 2.7 and need dependencies installed, that needs to be done in a contained environment, one that does not mix Python 3 packages into it. If you care about using your Python 2.7 scripts long-term, you should consider migrating them now; using unsupported software is only going to get harder over time.",0.0,False,1,7332 2021-03-17 11:59:20.170,Cannot find .ipynb in directory that says it was last modified recently but has no recently modified files,"Hi so I have been working on a notebook the last few days and showed it to my advisor yesterday and we walked through it together. I tried to start working on the project this morning and cannot find the file that I was working on. What is strange is that the directory that I was working in says it was last modified yesterday but when I look through the directory the file I am looking for cannot be found. I know that you are probably thinking ""this ding deleted the file on accident"" and although I really dont know how that could have happened, that is one suspicion of mine, but when looking at https://stackoverflow.com/questions/38819322/how-to-recover-deleted-ipython-notebooks they mention that it should go to trash for my version of jupyter notebook upon deletion. I am asking if there is any way to possibly get the file back? or anywhere I can look for the file? I have looked in my trash can but it is not there. MacOS Big Sur 11.2.3 Jupyter NoteBook 6.1.5 Conda Version: 4.9.2 Conda-build version: 3.20.5 Python: 3.8.5.final.0","I do not know why this was the case but here is: I could not find the file of interest. Did all methods from before in above link, once I looked in the icloud Desktop in my finder it suddenly appeared in the normal desktop directory. Idk why, but if this happens to you, check the icloud directory corresponding to the directory you are in and it may appear in the corresponding normal directory after. Lesson learned: do some version control.",0.0,False,1,7333 2021-03-17 12:08:15.460,Python exe - how can I restrict viewing source and byte code?,"I'm making a simple project where I will have a downloadable scraper on an HTML website. The scraper is made in Python and is converted to a .exe file for downloading purposes. Inside the python code, however, I included a Google app password to an email account, because the scraper sends an email and I need the server to login with an available Google account. Whilst .exe files are hard to get source code for, I've seen that there are ways to do so, and I'm wondering, how could I make it so that anyone who has downloaded the scraper.exe file cannot see the email login details that I will be using to send them an email when the scraper needs to? If possible, maybe even block them from accessing any of the .exe source code or bytecode altogether? I'm using the Python libraries bs4 and requests. Additionally, this is off-topic, however, as it is my first time developing a downloadable file, even whilst converting the Python file to a .exe file, my antivirus picked it up as a suspicious file. This is like a 50 line web scraper and obviously doesn't have any malicious code within it. How can I make the code be less suspicious to antivirus programs?","Sadly even today,there is no perfect solution to this problem. The ideal usecase is to provide this secret_password from web application,but in your case seems unlikelly since you are building a rather small desktop app. The best and easiest way is to create a function providing this secret_password in a separate file,and compile this file with Cython,thing that will obcufate your script(and your secret_password) at a very good extend.Will this protect you from lets say Anonymous or a state security agency?No.Here comes the reasonable thinking about how secret and important really your password is and from who you mainly can be harmed. Finally before compiling you can 'salt' your script or further obscufate it with bcrypt or other libaries. As for your second question antiviruses and specifically windows don't like programms running without installers and unsigned. You can use inno setup to create a real life program installer. If you want to deal with UAC or other issues related to unsigned programms you can sign your programm(will cost money).",1.2,True,2,7334 2021-03-17 12:08:15.460,Python exe - how can I restrict viewing source and byte code?,"I'm making a simple project where I will have a downloadable scraper on an HTML website. The scraper is made in Python and is converted to a .exe file for downloading purposes. Inside the python code, however, I included a Google app password to an email account, because the scraper sends an email and I need the server to login with an available Google account. Whilst .exe files are hard to get source code for, I've seen that there are ways to do so, and I'm wondering, how could I make it so that anyone who has downloaded the scraper.exe file cannot see the email login details that I will be using to send them an email when the scraper needs to? If possible, maybe even block them from accessing any of the .exe source code or bytecode altogether? I'm using the Python libraries bs4 and requests. Additionally, this is off-topic, however, as it is my first time developing a downloadable file, even whilst converting the Python file to a .exe file, my antivirus picked it up as a suspicious file. This is like a 50 line web scraper and obviously doesn't have any malicious code within it. How can I make the code be less suspicious to antivirus programs?","Firstly, why is it even sending them an email? Since they'll be running the .exe, it can pop up a window and offer to save the file. If an email must be sent, it can be from the user's gmail rather than yours. Secondly, using your gmail account in this way may be against the terms of service. You could get your account suspended, and it may technically be a felony in the US. Consult a lawyer if this is a concern. To your question, there's basically no way to obfuscate the password that will be more than a mild annoyance to anyone with the least interest. At the end of the day, (a) the script runs under the control of the user, potentially in a VM or a container, potentially with network communications captured; and (b) at some point it has to decrypt and send the password. Decoding and following either the script, or the network communications that it makes will be relatively straightforward for anyone who wants to put in quite modest effort.",0.0,False,2,7334 2021-03-19 10:45:05.610,Modify values in numpy array based on index and value,"How do I modify a np array based on the current value and the index? When I just want to modify certain values, I use e.g. arr[arr>target_value]=0.5 but how do I only modify the values of arr > target_value where also the index is greater than a certain value?","For that very specific example you would just use indexing I believe eg arr[100:][arr[100:] > target_value]=0.5 in general it could be conceptually easier to do these two things separately. First figure out which indices you want, then check whether they satisfy whatever condition you want.",0.0,False,1,7335 2021-03-20 05:09:16.817,MySQL Version 8 Python 3.7 Cannot write None value as NULL,"Previous version of code wrote fine with Python 2.7 to AWS MySQL Version 8 with the following: """"""INSERT INTO test_data(test_instance_testid, meas_time, data_type_name, value, corner_case, xmit, string_value) VALUES('15063', '2021-03-19 20:36:00', 'DL_chamber_temp', '23.4', 'None', 'None', 'None')"""""" But now, porting to Python 3.7 to the same server I get this: pymysql.err.InternalError: (1366, ""Incorrect integer value: 'None' for column 'xmit' at row 1"") This makes sense since it is a str value 'None' and not Python type None (although it used to work). It is legal to fill these columns as NULL values--that is their default in the test_data table. If I change the code and set the values to Python None, I get a different error which I don't understand at all: """"""INSERT INTO test_data(test_instance_testid, meas_time, data_type_name, value, corner_case, xmit, string_value) VALUES('15063', '2021-03-19 20:36:00', 'DL_chamber_temp', '23.4', None, None, None)"""""" pymysql.err.InternalError: (1054, ""Unknown column 'None' in 'field list'"") I really appreciate any help or suggestions. Thanks, Mike Thanks for the help! Yes, NULL does work, but I'm stuck on how to handle value types on the fly within my method. Depending on the call I need to write a quoted value in one case and non-quoted NULL on others. For some reason my old code (illogically!) worked. I've tried everything I can think of without any luck. Any thoughts on how to do this?",make default value as NULL at PhpMyAdmin,0.0,False,1,7336 2021-03-20 20:14:17.300,Where to store my custom Python modules on GCP so they can be accessed by different GCP services?,"Does anyone have any good suggestions for where I can store my custom Python modules on Google Cloud Platform? I have a bunch of modules that I would like to access from the different GCP services I am using (App Engine, Compute Engine, Cloud Functions etc), without having to copy the Python files and upload to the service's Python environment each time. I was thinking GCS could be an option but then I am not sure how I would then get the module into, say Cloud Functions or App Engine? Any ideas?","The code will eventually need to be written to your service's local storage. Python does not access code remotely during execution unless you write your code to do so (download the module and then execute). Package your code as modules and publish to PyPI and then add them as dependencies. When you deploy a service, your modules will be downloaded.",0.3869120172231254,False,1,7337 2021-03-21 01:20:30.540,module not found even after pip install,"Can you help with a definitive answer for MAC and PC. I have come across similar questions to this quite a lot on stackoverflow where a user will be using an editor such as IDLE or ATOM and they will get the module not found error, then they will go to terminal or command line prompt and try to pip install the module, and it will either install the module or say requirement already satisfied. On returning to the editor and running the script it will still give the module not found error. I have seen the same question, but often asked about for specific modules. This error started happening a lot for me when I was required to install anaconda for a course and was required to use other editors, but had previously been using a download of Python and working with IDLE. I often go between a MAC and a PC, where I have got the same issue, where I have an instance of anaconda installed and another instance of python installed. It is very confusing how to untangle the different paths where some have modules and other don't. Could someone give some advice on how to rectify this? I wonder if there is a solution where I could do a pip install that would globally update all versions of python with a module?",This could happen if you have multiple versions of Python installed on your computer. For example you have a package installed on Python 3.5 but you run your script on Python 3.8. On cmd or Powershell you could try something like py -3.8 -m pip list or py -3.5 -m pip list to check which libraries you have installed on each version of Python. Then if the library is missing from the version that you used on your script you can install it specifically for this version using something like py -3.5 -m pip install library_name.,0.9950547536867304,False,1,7338 2021-03-21 13:35:06.307,is it possible to call a web service from cooja?,is it possible to call a web service from cooja? May be I can read from border-router then call web service (via python script for example). I can ping border-router but I dont know how to read from node or write to node in cooja.I am new to contiki-ng and cooja. thanks in advance,You can try the websense example at the folder ~/contiki/examples/ipv6/sky-websense,1.2,True,1,7339 2021-03-21 17:24:01.213,How to protect my ren'py project from being copied?,"For all those who are not familiar with ren'py: It's basically python with some modifications. Since the project is coded in python, which can easily be edited by anyone it is not a good idea to include a license validation in the python files. An executable starts the game, so I thought about wrapping it with a license validation in an .exe (but I honestly don't know how I can take an executable, put some code around and have one executable including the actual one). Maybe there is another way, which is safer than the one I named, suggestions?","You don't. Ren'Py only features basic encryption to prevent players from accidentally deleting/modifying files. As security, game encryption isn't a fight worth picking. You have to decrypt the files to run them and that will always be a weak point to exploit. Anything you put on top is just delaying whoever wants in. You can write your game in binary and it will do exactly squat to someone who really wants to take it apart. Ren'Py is designed to be mod friendly. Nothing you do will stop someone from dropping a rpyc file into the game directory and hooking into the game. Even if you modify the engine to only read specific files, you won't stop someone who can just insert the functionality back in. All you're really doing is making it more difficult to preserve the game after you're dead. Nintendo can't stop people from extracting assets from their games. You don't stand a chance. You should hope to be so lucky as to have people interested enough in your game to want to mess around with the assets and code. If you're talking about a license players need or some sort of login mechanism, you need to implement an online server to validate the credentials they input. There is no secure front-end way to validate credentials.",0.9950547536867304,False,1,7340 2021-03-22 18:26:54.357,Could not install packages due to an EnvironmentError: [Errno 2] numpy-1.20.1.dist-infor \\METADATA,"I wanna install three packages in anaconda, but I face the following error. Error: Could not install packages due to an OSError: [Errno 2] No such file or directory: 'c:\\programdata\\anaconda3\\lib\\site-packages\\numpy-1.20.1.dist-info\\METADATA'. I have changed HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem@LongPathsEnabled to 1, but it does not still work. There are some similar problems with pip and some solutions are provided but I could not apply them. Is there any difference between the pip\\METADA error and numpy\\METADATA error? I have basic knowledge and I would be thankful if someone can explain how to fix it with details. For example, some people suggested installing in another directory, but I do not know how to do this.","You could remove the folder of ""numpy-1.20.1.dist-info"" in error information firstly, and try install again.",0.0,False,1,7341 2021-03-22 20:06:14.803,Django overriding ModelAdmin classes with a function requiring Model name,"In my admin.py, I have a lot of ModelAdmin classes and I want them to all override a function, has_module_permission. I want to base the module permission off of the user's permissions for the model corresponding to the ModelAdmin, and to do that I need to know the model name in order to run request.user.has_perm('app.add_') or something similar. I think an easy way of doing this is to create a class that has this function which is somehow able to get the model name, and then have each of the ModelAdmin classes inherit from that. The problem is that I don't know how to access the model's name from ModelAdmin. What's the best way of doing this?",If you just need the the model's name from ModelAdmin you can simply do the following: self.model.__name__,1.2,True,1,7342 2021-03-23 22:55:33.790,PIP installed items don't want to work in Windows 10,"I'm lost with Python. After troubleshooting with a friend through Discord for literally months I am about to give up. This is my last attempt at trying to get Python fixed on my Windows 10 laptop. I'm using a Lenovo Legion 5, bought the laptop in November 2020. I've not been able to get anything related to Python to run in the CMD window. I can run Python no problem, but nothing I have installed through pip has ever worked. I can use virtualenvs, but only through PyCharm for example. Python has never really worked through the command line. Yes I tried reopening the CMD window, rebooted the system many times, ran the CMD as administrator, installed the path variables for both Python and esptool.py but nothing seems to help. I honestly don't know where to start because none of the 250+ websites I've visited to so far that suggested a fix for any kind of issue I've been experiencing with Python has been working. I can run Python fine by the way, just none of the things installed through pip will work. Let's start with a use-case: I'm trying to run esptool.py so installed it with pip install esptool. This install worked fine, and I can confirm it is installed with pip show -f esptool. However, when running esptool.py version it told me: 'esptool.py' is not recognized as an internal or external command, operable program or batch file. So I added the local folder from the previous step to the %PATH% variables, after running esptool.py version it gave me a popup asking me with what kind of program I should open this, I didn't select to open with this kind of program from now on. This makes it so that I do not get an error, what now happens is that another window quickly opens and then exits without an error code. So I have no clue what's happening. What should happen is that it should tell me which version is installed in the CMD window. There have been a few other things going on with my Windows 10 install, for one, the username that I used during the installation wasn't used to create the user directory. Windows 10 somehow instead chose a name that was related to the first 5 characters of my email address, which is totally strange as I haven't used that string in the installation of Windows 10 at all. This was a fresh install on a new laptop. Now, after an update of Win10 my user icon doesn't display anymore and I had to change ownership of the 'Windows Apps' folder in order to be able to access it. Changing the ownership also changed the name I now see on the login screen when I boot up the laptop. It changed from the 5 first chars of my email address to my full name in the login screen, only because I took ownership of this folder so I could access it. There have been a lot of things going on that I think should not be changing all the time, things to do with administrator rights, ownership, etc. Now, since opening esptool.py doesn't open it, but also doesn't show me an error, I'm clueless and the only thing I can think of is doing a fresh system install, but I have a bunch of projects going on for which I need this laptop in working order and I don't have the mental health (due to corona) left to do a fresh system install. I'm worn down. Not in a dramatic way, I just don't have the spare energy to go through the whole process. So I'm hoping someone can point me in the right way to troubleshoot why my Python doesn't want to work natively. What happens when running esptool.py version is that I can see it opens a Python window, but without showing any content it closes within a few milliseconds. What is going on, how do I continue? I hope someone knows how to troubleshoot my system, to find the core of the problem.","It apparently was rather simple. First of all, thanks for the replies! And second of all, thanks for pointing me to superuser.com I wasn't aware of the site and will continue there. The fix was to use python -m pip install esptool as suggested by Valentin Kuhn. To answer AKD, I have a lot of experience with programming on my MacBook, but I'm not experienced with actually maintaining the system side, I'm a creative user. It's just that ever since I got a Windows laptop it's been nothing but trouble and after months of chatting about each individual issue with people on Discord nobody has been able to find a solution. I'm not expecting a GUI, just a simple ""esptool.py v3.0"" was the answer I was expecting from the command line. Now what I don't understand is that I've never found any hint to anyone suggesting python -m. I will get on superuser to find out more about why the standard instructions that work for most people, don't work for me. Sorry for using the wrong site for my question, I came on here through another related question and it was past my bedtime and I wasn't thinking clear.",0.0,False,1,7343 2021-03-24 12:30:19.070,gRPC - Using code other than Java to create a Service Implementation,"I'm a student. For my Distributed Systems project, I'm expected to create a gRPC project. I'm creating the project in Eclipse. Two service implementation are to be coded in Java and the other is to be done in another coding language. I've tried searching for help online but the results I'm getting are related to gRPC and how gRPC works, not about the coding or using other coding. Ideally, I would like to use Python as the other language and to create it in Eclipse if possible. Does anyone have any information, documentation or examples I could look at, so I could can reference it? I am able to see online searches for both Java and Python, but I'm not sure how to use both in one project. Thank you.","So I got a lot of feedback for lecturers and classmates. The server doesn't care what programming language is used. So Java, Python, Node.js etc, could all be sent to the server. A generalised simplistic idea of how I was able to understand is: Python converts its code to binary and sends it to the server. Same with Java and Node.js. I don't know why, but I was digging myself deeper trying to figure out what code (i.e. the binary) that needed to be the communication between the server and code. I was trying to encapsulate Python into Java and vice versa. Why did I think this? Your guess is as good as mine.",0.0,False,1,7344 2021-03-24 18:35:49.373,tcmalloc: large alloc python in Google Colab,"I was trying to apply a deep learning algorithm(CNN) in python but after separating training-testing data and transforming time series to image step my Colab Notebook crashed and restarted itself again. It gives an error like ""Your session crashed after using all RAM"" and when I checked app.log I saw something about tcmalloc: large alloc. I didn't find anything to fix this crashed. Do you have any idea how to prevent this warning and fixed this situation?",Your session ran out of all available RAM. You can purchase Colab Pro to get extra RAM or you can use a Higher RAM machine and use the Neural Network there,1.2,True,1,7345 2021-03-25 07:52:30.940,"SQLAlchemy how to use a ""fully module-qualified path""?","I'm contributing to a project that is using sqlalchemy. This project has a model.py file where they define all their classes, for example Foobar(BASE). Now, I've created another module mymodel.py where I need to extend some of those classes. So for example, in mymodule.py I have Foobar(model.Foobar) which I use to extend the parent class with new properties and functions. The problem is that when using either of those classes, I get this error from sqlalchemy: sqlalchemy.exc.InvalidRequestError: Multiple classes found for path ""Foobar"" in the registry of this declarative base. Please use a fully module-qualified path.. My question then is, how can I fix this error without renaming my classes? Since they are defined in a different module, how do I use a ""fully module-qualified path""?",As stated by SQLAlchemy there a two classes found named Foobar. One is model.Foobar and the second one is mymodel.Foobar. You need to use the fully module-qualified path which is mymodel.Foobar to reference the new class.,0.0,False,1,7346 2021-03-25 14:18:00.603,how can i work with my GPU in python Visual Studio Code,"Hello I know that the key to analyzing data and working with artificial intelligence is to use the gpu and not the cpu. The problem is that I don't know how to use it with Python in the visual studio code, I use Ubuntu, I already have nvidia installed","You have to use with the libraries that are designed to work with the GPUs. You can use Numba to compile Python code directly to binary with CUDA/ROC support, but I don't really know how limiting it is. Another way is to call APIs that are designed for parallel computing such as OpenCL, there is PyOpenCL binding for this. A bit limiting, but sometimes valid way - OpenGL/DirectX compute shaders, they are extremely easy, but not so fast if you need to transfer data back and forth in small batches.",0.3869120172231254,False,1,7347 2021-03-25 14:24:21.283,"How to convert YOLO format annotations to x1, y1, x2, y2 coordinates in Python?","I would like to know how to convert annotations in YOLO format (e.g., center_X, center_y, width, height = 0.069824, 0.123535, 0.104492, 0.120117) to x1, y1, x2, y2 coordinates?","Given that the upper-left corner of the image is [0,0]: For the upper-left corner you have to do [x,y] = [center_X, center_Y] - 1/2 * [width, height] . For the bottom-right corner [x,y] = [center_X, center_Y] + 1/2 * [width, height] .",0.2012947653214861,False,1,7348 2021-03-25 16:10:24.780,How will I access the data in my database after uploading my site to the web?,"It's probably a dumb question but i cant find the answer anywhere. So, I have made a simple site with Flask and it have a database in SQL(SQLite3). I'have never uploaded a site before and I don't know how to get the data after deployed. Plz help.","If your code already works locally, make sure it has a relative path like './data/sqllitedb.db'. Put it in a folder that isn't available to access from your website. When you deploy to your website, it should use the same relative path. Sqlite is great because it is just a local file and as long as you use relative paths to your main site, you should be able to access it",0.0,False,1,7349 2021-03-25 17:07:10.687,How to force python to unlock files on macOS,"I am using Python to automate some installations in my everyday workflow. The installation requires mounting a .dmg file to the system in order to start and complete the installation. Everything works fine until I try to eject/unmount the attached volume, it gives an error that the volume is used by Python and cannot be ejected/unmounted. The installation process is already completed by the time the unmount is executed, so in theory, files should no longer be in use. Force unmount helps with the unmount process, but for some reason, it interferes with subsequent subprocess.Popen command that starts the installed application and the app crashes at startup. The crash doesn't occur if the volume is not unmounted, which is a sign the issue is caused by the unmount process. I would like to try to unmount the volume without forcing the process, but I don't know how to unlock the files being used by Python for the installation. Is there a way to force python to unlock those files? Thanks in advance.",The issue was related to the fact the current working directory was set to a folder inside the mounted volume. Switching the CWD to HOME before unmounting process and subprocess execution fixes the issue.,0.0,False,1,7350 2021-03-25 17:09:41.340,Rename folder in git without changing the contributors,"I have a problem: we are using a package that is not maintained for a while now. So we forked it in order to maintain it ourselves. The package already exists lets say it is named package_a. Most of the code and the __init__ are in the package_a/ folder. Now we want to make our own package that will include our maintained code and we want to name is package_b. So far so good but the problems is that package_b wants to have the code and the __init__ in package_b/ folder and github changes the contributions for all files when a folder is renamed. And I would like that credit for contributions stays where it is due, the 10k+ lines of code didn't just appear in my local repo out of thin air. Any suggestions how we can have package named package_b but keep the code in the original folder package_a/? I am thinking along the lines of trying with some clever way of importing package_a into package_b or something along the line but I hope for a definite answer.","Instead of copying the code or trying to import A into B, extract the common code into a 3rd package which both A and B import. Or perhaps a subclass. This doesn't solve your contribution problem, but it does avoid making a big maintenance hassle by copying and pasting 10,000 lines of code. Git doesn't record copies and renames, but it can recognize when they happen. To give Git the best chance of recognizing a copy, do only the copy in its own commit. Make no changes to the content. Then in a second commit make any necessary changes to the copied code. In normal Git you can nudge git log and git blame to honor copies and renames with -C. Git doesn't do this by default because it's more expensive. Github will do what Github will do. Regardless of who Github says who wrote what line their contributions will still be in the project history. That's how it goes. You make your contribution and then others put their own work on top of it. This is normal. Their contributions remain in the history. ""History sheer"" is also normal, that's when a change touches many lines but is otherwise insignificant. For example, if you were to restyle the code that would cause a history sheer. git blame will say that was the last commit to touch the code. git blame -w mitigates this somewhat, and Github has an ""ignore whitespace"" option. History sheer is normal and so is learning to skip over it. The tools work for us. Don't bend yourself for the benefit of the tools. If you want to make a special shout out to your contributors, make a contributor's section to your README.md.",1.2,True,1,7351 2021-03-26 20:37:59.120,How to give all permissions in voice channel discord.py,"Sorry for my stupid question, but i dont understand how to add all permissions in my voice channel for one user. I have this await channel.set_permissions(member, some_permission), but i dont know what permission i need to use","You should just make a role with those permissions and then give that role to the user. for example, await member.add_roles(var) var being the role and member being the member you want to add the role too.",1.2,True,1,7352 2021-03-27 05:21:00.197,How the heck do I import my python chatbot into my html code?,I trained a chatbot in a file on my computer. I have everything else for my website up and running but I cannot get the python file into the site. Do you have any advice for how I can make an html messenger that uses user inputs and converses with the AI chatbot that way? Thank you!,"One easy way to do this is by building a server, where you can have your chatbot code. You can use Flask. The instant the HTML asks a question, you send an API call with the required message, which when received by the API runs that message through the chatbot and returns the response in the output. This can continuously go on in the chat.",1.2,True,1,7353 2021-03-27 16:13:25.387,How to read private Google Sheets using Google Sheets API without service account or downloading credentials,"Background I have a google sheet, who's data I need to process on my local system. The nature of processing is very tedious and long so I wrote a script for it. Problem I need to access the google sheet through the python script to process it further. Online it is mentioned that to read the private google sheet directly, I need to create a GCP project and within that project, I need to create a service account. After that I should download the credentials and share the google sheet with that service account email. Two problems here are : Downloading the credentials -- insecure and my organization prohibits it. Sharing of google sheet with service account email. organization also prohibits sharing sheet with outside organization emails. What I found as a solution I came across a solution of impersonating a service account but I could not find anything as to how can I do that. (Would appreciate any insights on that). All the other solutions suggested to download credentials which is a big NO. For the sharing of sheets thing, I guess we can use drive API, but same problems are with that. I tried using gcloud auth login and gcloud auth application-default login but was getting errors Request had insufficient authentication scopes."". Details: ""Insufficient Permission: Request had insufficient authentication scopes. using ['https://www.googleapis.com/auth/spreadsheets', https://www.googleapis.com/auth/drive'] as scopes What I need? (Summary) How to access google sheets API (or download the Sheet from google drive) without downloading any sort of credentials.json.","problem Your only option to access private user data is to be authorized as a user who can access the file. Either logging in using Oauth2 or using a service account Downloading the credentials -- insecure and my organization prohibits it. In order to use a google api you must first register your application on google developer console and download the client credentials then a user must authorize the application using Oauth2, which would mean both downloading the credentials.json file from google developer console and you getting user token credentials from the authorized user. Sharing of google sheet with service account email. organization also prohibits sharing sheet with outside organization emails. In order to use a service account you would again need to first register your application on google developer console and download the client credentials for the service account. Then you would need to share the sheet with the service account. service account impersonation. Service account impersonation is used by GSuite domain. You create a normal service account again downloading the credentials, and then the GSuite admin is able to delegate authority to the service account which will allow it to impersonate a user on the domain. This would require you to have GSuite domain and the owner of the file being also on the GSuite domain, and you creating a project on google developer console and downloading the credentials.json for the service account, which you already stated you couldn't do. conclusion I guess what i am saying is there is no way with the limitations imposed by your organization for you to access a private google sheet or any private user data on googles system, via any api.",0.3869120172231254,False,1,7354 2021-03-28 17:46:30.493,"Spacy, using nlp.pipe on large dataset in python, multiprocessing leads to processes going in sleep state. How to proper use all CPU cores?","I'm working on a NLP classification problem over a large database of emails (~1 million). I need to use spacy to parse texts and I'm using the nlp.pipe() method as nlp.pipe(emails,n_process=CPU_CORES, batch_size=20) to loop over the dataset. The code works but I'm facing a (maybe not so)weird behavior: the processes are being created but they are all in SLEEP state but one, casually some of them go in RUN state for a few seconds and then back to sleep. So I find myself with one single process using one core at 100% but of course the script not using all the CPU cores. It's like the processes don't get ""fed"" input data from pipe. Does anybody know how to properly use spacy nlp pipe or anyway how to avoid this situation? no way to use nlp.pipe with the GPU? Thank you very much! Sandro EDIT: I still have no solution but i've noticed that if I set the batch_size=divmod(len(emails),CPU_CORES), the processes all starts running at 100% CPU and after a few seconds they all switch to sleeping state but one. It really looks like some element in spacy pipe gets locked while waiting for something to end.... any idea?? EDIT2: Setting batch_size=divmod(len(emails),CPU_CORES) while processing a large dataset leads inevitably to a spacy memory error: MemoryError: Unable to allocate array with shape (1232821, 288) and data type float32 *thing that is maybe not so weird as my machine has 10GB of RAM and (1232821×288×32)bits / 8 = 1.4GB multiplied by 6 (CPU_CORES) leads to a 8.5GB of RAM needed. Therefore I guess that, having other stuff in memory already, it turns out to be plausible. *","Ok, I think I found an improvement but honestly the behavior it's not really clear to me. Now the sleeping processes are way less, with most of them stable running and a few sleeping or switching between the two states. What I've done was to clean and speedup all the code inside the for loop and set the nlp.pipe args like this: for e in nlp.pipe(emails,n_process=CPU_CORES-1, batch_size=200): If anybody have any explanation about this or any suggestion on how to improve even more, it's of course more than welcome :)",0.0,False,2,7355 2021-03-28 17:46:30.493,"Spacy, using nlp.pipe on large dataset in python, multiprocessing leads to processes going in sleep state. How to proper use all CPU cores?","I'm working on a NLP classification problem over a large database of emails (~1 million). I need to use spacy to parse texts and I'm using the nlp.pipe() method as nlp.pipe(emails,n_process=CPU_CORES, batch_size=20) to loop over the dataset. The code works but I'm facing a (maybe not so)weird behavior: the processes are being created but they are all in SLEEP state but one, casually some of them go in RUN state for a few seconds and then back to sleep. So I find myself with one single process using one core at 100% but of course the script not using all the CPU cores. It's like the processes don't get ""fed"" input data from pipe. Does anybody know how to properly use spacy nlp pipe or anyway how to avoid this situation? no way to use nlp.pipe with the GPU? Thank you very much! Sandro EDIT: I still have no solution but i've noticed that if I set the batch_size=divmod(len(emails),CPU_CORES), the processes all starts running at 100% CPU and after a few seconds they all switch to sleeping state but one. It really looks like some element in spacy pipe gets locked while waiting for something to end.... any idea?? EDIT2: Setting batch_size=divmod(len(emails),CPU_CORES) while processing a large dataset leads inevitably to a spacy memory error: MemoryError: Unable to allocate array with shape (1232821, 288) and data type float32 *thing that is maybe not so weird as my machine has 10GB of RAM and (1232821×288×32)bits / 8 = 1.4GB multiplied by 6 (CPU_CORES) leads to a 8.5GB of RAM needed. Therefore I guess that, having other stuff in memory already, it turns out to be plausible. *","I've found that using n_process=n works well for some models, like en_core_web_lg, but fails with others, such as en_core_web_trf. For whatever reason, en_core_web_trf seems to use all cores with just a batch_size specified, whereas en_core_web_lg uses just one unless n_process=n is given. Likewise, en_core_web_trf fails with a closure error if n_process=n is specified.",0.2012947653214861,False,2,7355 2021-03-28 20:50:22.837,How to calculate average of closest neighbours in an array in numpy,"Given an arbitrary array with real numbers as entries, I want to return an array with the same shape, whose entries are the average over the closest neighbours of the original array. What I mean by this in the case of a given array of dimension 2, is that if the array has shape (n,m) with entries a_{i,j}, then on the entry (i,j) the value of the new array should be: average(i,j)=1/4 (a_{i+1,j} + a_{i-1,j} + a_{i,j+1} + a_{i,j-1}), where the first index is taken mod n and the second mod m. I would like to create a function whose argument is an arbitrary array, and returns an array of the same shape and entries the averages over the entries on the closest neighbours of the given array (for a d-dimensional array there are 2d closest neighbours, obtained by summing +1 and -1 on each index) I know how to do this for a fixed dimension d (just generalising the above equation), using d nested for loops, but I don't know how to do it when the dimensions are not fixed.","Scipy has a scipy.ndimage.convolve function, which can do exactly this. it takes the array, and a matrix of values to multiply the neighbors with. It should work for any number of dimensions. However if you are trying to write this function manually, I'd suggest trying an iterative or recursive approach, where each iteration or layer of recursion handles a dimension. In a 3D case, you would first handle the first dimension, and have the one sixth of the value of the neighbors in that dimension. The next iteration would do the same for dimension 2, etc. The factor to multiply each neighbor with is 1/(2n), since each entry has 2 neighbors in each dimension. This should scale up to any arbitrary number of dimensions.",0.0,False,1,7356 2021-03-30 00:52:00.923,How do I get into script mode for Python?,I am confused as to how to get into script mode in Python's standard IDLE. I surprisingly cannot find how to get into it on Google.,"I believe you mean the simple editor that ships with Python, ""IDLE""? If you have an IDLE console window open already, go to file->New File, or press ctrl+N to get a window where you can write and save a python file like a text editor. When you've written a script in that editor you can save it as you'd expect from File->Save and run it from Run->Run Module, or press F5 as a quick shortcut. It should then output any text to the IDLE console window. Also see the comments directly beneath your question for some resources :) Happy scripting!",0.0,False,1,7357 2021-03-31 02:32:56.400,Addressing a pip´s dependency issue: requests==2.25.1 versus requests==1.1.0,"import yfinance as yf terminal: ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behavior is the source of the following dependency conflicts. yahoo 0.1 requires requests==1.1.0, but you have requests 2.25.1 which is incompatible. how can I address this issue Regards! :)","The problem is that yfinance requires a newer version of requests than yahoo. For me it said the same thing as you got when I tried. Importing yfinance worked for me. I didn't specify anything for requests and just installed the above. Generally, you can specify installation version using =x.x at the end, i.e. pip install requests==1.1.0.",0.0,False,2,7358 2021-03-31 02:32:56.400,Addressing a pip´s dependency issue: requests==2.25.1 versus requests==1.1.0,"import yfinance as yf terminal: ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behavior is the source of the following dependency conflicts. yahoo 0.1 requires requests==1.1.0, but you have requests 2.25.1 which is incompatible. how can I address this issue Regards! :)","It sounds like you have both yahoo and yfinance installed in the same environment/setup. I suggest creating a virtual environment with virtualenv so you can have the appropriate requests for each libraries. Alternatively you can submit a PR for yahoo to use a more recent version of requests",0.0,False,2,7358 2021-03-31 11:30:07.180,python - is there a function to return the maximum integer but not float from a list,"I am trying to code a function that will accept a list and then return the length of the list times the largest integer (not float) in the list, if the list does not contain an integer, it needs to return an empty string. I had been trying to use the max function but I cannot work out how to only call for the largest integer not float, or is there a way to sort the list first to only look at integers?",you might be able to use an if statement to check if the number is an interger,0.0,False,1,7359 2021-03-31 15:04:23.503,Wrapping a test case in Robot Framework in keyword based on the tag of a test,"Robot Framework supports two ways to interact with the tests and modify the test structure: the visitor internal API the listener API I would like to prepend, to specific tests, a given keyword, or even more precisely to wrap the test in a given keyword, if that test has a specific tag. Which of the two approaches should I choose, and how I should use the API of the Body of Robot Framework to wrap it in a Wait Until Keyword Succeeds?","I think the Listener API might be the way to go but why not use the Test and Suite Setup Keywords to be able to pull off what you are trying to do. However, in general, i.e. not just in Python or Robot Framework, it is a bad idea to have one test depend on the execution of another test. Ideally, each test should be able to run on its own, whether first or last or anywhere in the sequence so perhaps there might be a need to refactor your tests and/or Keywords to be able to achieve what you are attempting.",0.2012947653214861,False,1,7360 2021-04-01 05:49:36.783,How to read files from Google drive through python when it says Google hasn’t verified this app?,"I have created project and even i have client_secret.js file, when i try to run the program first time it asks to login, when I tried to login through gmail (which I have used to create project) it says ""Google hasn’t verified this app"" Message, so for that i'm looking how to get out from this step.",This is occuring because the application you created is not verified by google so you are not able to login in that you need to verify it by google suite and then you are able to login I also get that problem when i tried to create an browser for myself,-0.2012947653214861,False,1,7361 2021-04-01 23:56:43.710,how can i stop showing the decimal .0 after the whole number? python,"So, i entered code below to round a column to the nearest integer, though it still shows up with decimals. Eg. I want to round 62.040 to just 62 though once the code is entered it shows 62.0 in the output data['Final'] = np.ceil(data['Total'].round())","This should work pretty ok data['Final'] = round(data['Total']) This converts the decimal number to it nearest integer and the returned number doesn't have a decimal point Note: I'm assuming that data is just dictionary that contains float numbers, since no more information was provided",0.2655860252697744,False,1,7362 2021-04-02 06:31:52.013,How to run dramatiq tasks run in detach mode?,"I'm new with dramatiq and I do not find a way how to start dramatiq in detach mode like Celery? I try to start with flags --d --detach, but nothing works. Please inform me how to start dramatic in detach mode when I start dramatiq app:broker","I found it's already work on detach mode, but if you wish to read the logs you need to have your terminal in open view",0.0,False,1,7363 2021-04-02 09:17:12.367,"How to map an array of shape (4,386,258) to an array of shape (3, 386,258) in python?","I'm working in python and I have an image that is represented by the shape (4,386,258), I would like to represent it with the shape (3,386,258). Is there a way to do that? I don't know how to combine the information in order to get the right map","Assuming your image is 386 pixels by 258 pixels and you have 4 channels, it means you want to convert the colour representation to one using only 3 channels, probably RGB. You haven't specified what libraries you used to read-in the image or where it is from, but most would have methods to handle this for you, so you don't have to write the conversion manually. They should also have methods of finding what the current colour representation is.",0.0,False,1,7364 2021-04-02 21:34:50.583,CNN classified only one variable if it is true or false,"So i was trying to make a voice classifier, the challenge was to predict if the person talking is me or is other person, i already build a simple code that converts .wav file into an array, so all my datasets of audio files of me talking will be converted into arrays, the thing is that I am a beginner and i dont know how to only use one variable for predicting(my voice), is like saying true or false, how can i make a neural network(CNN) that works like that? Or should i use another type of machine learning? And not deep learning? I would like to use deep learning for this project.","Because it seems that you are relatively new to the topic, I would propose that you start with an easier machine learning model for this simple classification task. Maybe for the first model a Logistic Regression could be enough. So, you say you collected some samples of your own voice (your positve class), but did you also collect some negative samples from other people? After this, I would suggest to chunk the converted samples into equal siced sequences and label them (your voice or another?). Now with this as basis, you can test some easier models like the Logistic Regression or the KNN. You then might move forward to some simple Feed-Forward-Neural-Networks and then go on to some advanced models like CNN's or RNN's.",0.0,False,1,7365 2021-04-03 00:54:59.623,Is there a way to make it such that the user must answer within a time limit on discord.py?,"If I send out a request to a user for them to reply to a yes or no question, how can I make it such that after a certain amount of time, the question expires and is no longer accepting replies? Background I'm currently working on a discord.py bot, and I'm getting to the part where I start scanning the messages for user input. How it works is that somebody can challenge someone to a game of tic tac toe, and then the challenged person has 10 seconds to reply with yes or no. How can I make it such that after 10 seconds, the challenge expires? Examples One example I thought of is the bot Dank Memer. If you challenge someone to a tic tac toe game on there, then the challenged person has to respond to you within a time limit, or else the challenge expires. It also works with commands like pls trivia, where after 10 seconds it stops accepting answers to the question. I'm pretty sure that people have already asked this question, but I have looked over and over on Google and I can't find a solution. It's probably because of my wording, I think. It's also hard for me to do a minimal-reproducible example, as that would require you guys to have to create a discord account and token for the bot, which is not at all efficient.","You can use a await client.wait_for(check=check). Check is a function you must define that needs to return either true or false. Within check, you can add various conditions and actions if you need to. I made a command that does a math equation with it, if you'd like to see an example.",0.2655860252697744,False,1,7366 2021-04-03 01:29:27.437,Displaying a list of all the items/widgets inside a ListView Kivy/KivyMD,"Is there a way to display a list of the widgets or the items inside a list view? the items were also added by buttons, then next thing that i want to do is to display a list of the added items in another screen? how would i do this?",You can provide an id to your ListView and later on access it in your code where you want it. After accessing ListView you can just call lstvw.children (assuming you accessed it as lstvw). It will provide you list of all the children.,0.0,False,1,7367 2021-04-03 15:41:13.893,If I remove a conda environment will it automatically remove all packages?,"I would think it's obvious that it should uninstall all packages when removing an environment, since how would they be accessed otherwise, but I haven't seen documentation saying so, so I'm checking here if all packages need to be removed first.","The conda environment will be deleted. Sometimes some packages stay behind, although they are not bound to any environment. You can delete these under -> envs -> .",0.2012947653214861,False,1,7368 2021-04-04 16:55:50.177,Different user with more fields in the same model in Django,"I am planning to use a same user model for two different users with some additional fields in one model. Is it possible to do this in Django? If it is possible, how can I do it?","You have two options : Firstly You create a new Model (call it ExtendedUser) and you put the extra fields in that model. You then set your ExtendedUser model to inherit from your MainUser model. This will create two tables with a one to one link between them. The advantage of this is that your ExtendedUser model will inherit any methods defined in your original MainUser model, and you only need add methods to the ExtendedUser model if you absolutely have to. You can also write functions which can deal with both the MainUser and ExtendedUser models easily, since they are all instances of the MainUser model. One of the benefits of using inhertiance is if you write a query on the ExtendedUser model fetching all fields, it well fetch the MainUser fields too. A Second (worse) option : Have a single extended model with a flag on it which says whether to use the extra fields. This can be made to work, but will make your queries more complex, and if you need the extra fields to be indexed, the indexes are likely to be a bit less efficient. Note : having a second table with a relationship between the two is no bad thing in SQL - that is how data is normally managed. Having special optional fields for some types of users isn't great as mentioned.",0.0,False,1,7369 2021-04-05 20:44:39.017,How to install boost python on anaconda with windows 10,"I've tried conda install -c anaconda boost and I get the error fatal error C1083: Cannot open include file: 'boost/python.hpp': No such file or directory. I've added the boost download to the system and user paths, I've followed the direction on how to install boost python on Windows. What am I missing? What else can I do? I get the same error regardless of what I try.","My answer comes quite late, but I hope it will be of use for other people. In fact the arborescence has changed in an update for instance in my case with Anaconda in the 1.67 version , python.hpp is in \anaconda3\envs\myenv\Library\include\boost in newer version (tested with 1.73) , python.hpp is in \anaconda3\envs\myenv\Library\include\boost\python which prevents it from encountering it You can either modify the path referencing these files or install the version that works",0.0,False,1,7370 2021-04-06 19:39:17.053,How to access and change Pygame.midi?,"I'm using Pygame.midi and you can select from 127 instruments. I want to know how I can change/add midi instruments to this list. Is there a list of pygame.midi instruments anywhere and if not what libraries is pygame using to actually do midi? I've seen something called PortMidi and I'm wondering if this is what Pygame is using. I just want to know how I can access pygame.midi and add instruments.","Pygame is not providing the instruments. It's just sending MIDI commands to your system's built-in synthesizer, usually part of your sound card. MIDI allows for 127 instruments at a time. There is a standard called ""General MIDI"" that tries to define a baseline of 127 instruments, and that's probably what your system is using. You use ""sysex"" (system exclusive) messages to tell the synthesizer to change the instrument-to-channel assignments. pygame supports that with the write_sys_ex command, but you have to know the internals of your synthesizer to know which commands to send.",1.2,True,1,7371 2021-04-06 20:30:05.303,Is there an easy way to do half open TCP connection via Python Asyncio?,"I'm just picking up some async Python and trying to write a simple TCP port scanner using the Asyncio module. I can open a full-fledged TCP connection with 3-way handshakes via asyncio.open_connection. However, I want to create an SYN-ACK half-open connection—similar to what nmap uses—using asyncio. I was rummaging through the streams API but couldn't find anything. Is there a high-level method to do this? If not, how do I do this?","asyncio doesn't give you such control on TCP/IP stack layers and even hides some complex tasks such as callbacks, low-level protocols, transports. You can do it using a raw socket. Modules that can be useful python-nmap scapy",0.3869120172231254,False,1,7372 2021-04-06 21:02:41.453,How to install different versions of modules for python,"I'm wondering how to install two different versions of a module for python. I host some scripts on a server and some particular ones require older version of the module because some things just doesn't work in the newer version and vice versa, some things doesn't work on the older version. I know i can use pkg_resources and require a certain version, but if i try to install and use another version it just replaces the other one.",Easiest solution would be to use virtual environments for one or both of your scripts. This is however not recommended in the long run if you want to scale and manage. You should switch up the script using the older version or move to something like a docker based solution.,1.2,True,1,7373 2021-04-07 15:12:27.520,Creating a frequency distribution table in Python,"I'm new to Python and Pandas, and i'm struggling to create a frequency distribution table form my df. My dataframe is something like this: Balances Weight 10 7 11 15 12 30 13 20 10 15 13 20 edit: The balance numbers are its respective ID I need the frequency of each balance used (in this example, balance 10 would be 2 and so on) the min, max and mean of the measurements results. I was to use df.groupby(['balances']) but how can i use the results form using df.groupby to creat a new table? Is that the way?",df.groupby(['balances']).count() should solve what you're looking for,0.2012947653214861,False,1,7374 2021-04-07 16:04:47.493,Use connection pool with MongoEngine,"I have documents in different MongoDB databases referencing each other (mongoengine's LazyRefereneceField), so each time I need to get the field's value, I need to connect and disconnect from the field's relevant database, which I find very inefficient. I've read about connection pooling, but I can't find a solution on how to implement it using MongoEngine. How can I create a connection pool and reuse connections from it every time I need to the value for a LazyReferenceField?","MongoEngine is managing the connection globally (i.e once connected, it auto-magically re-use that connection), usually you call connect just once, when the application/script starts and then you are good to go, and don't need to interfere with the connection. LazyReferenceField is not different from any other field (ReferenceField, StringField, etc) in that context. The only difference is that it's not doing the de-referencing immediatly but only when you explicitly request it with the .fetch method",1.2,True,1,7375 2021-04-08 09:14:31.277,Barcode with kivy,"I salute all brethren here. Please I was tasked by my superior in a pharmacy outlet to generate barcode taking into consideration drug's country of origin ID or code, supplier code, product code and product classification as in pain killer etc. All these must be serialize into a readable barcode. So it means this must link to a database. Please brethren, how do I go about this in python kivy?","Too opened question I think ? You encapsulate: Install kivy Write your program Deploy it I suppose you want to focus on how to program it and you will manage to learn how to install and deploy it. I suppose that you want to use the phone's camera to analyse the barcode. I have an application that need to take photos and analyze the text on it to write it in a form. I didn't manage to make it work personnaly. Try to know if the kivy cam is ""stable enough"" to allowed saving/loading/real_time_analyze on Android. If you manage to make your camera work, you will need to focus on the analyse of the barcode. I think that you can reuse working library and use it on your application (or on a AWS lambda as a micro-service).",0.0,False,1,7376 2021-04-09 12:20:23.360,how to find the correlation between categorical and numerical columns,"I'm trying to find the correlation between categorical and numerical columns in my dataset using Python, can anyone help? Here is the data that I have. Thank you in advance. Light_Sensor_Reading Light_Sensor_Status 231 Dim 231 Dim 231 Dim 231 Dim 231 Dim 231 Dim 231 Dim 231 Dim 231 Dim 232 Dim 950 Very_bright 988 Very_bright 987 Very_bright 986 Very_bright 986 Very_bright 986 Very_bright 986 Very_bright 986 Very_bright 986 Very_bright 986 Very_bright 986 Very_bright 986 Very_bright 986 Very_bright 985 Very_bright 985 Very_bright","it doesn't mean anything to calculate the correlation between two variables if they are not quantitative. I think what you want to do is to study the link between them. The purpose is to explain the first variable with the other one through a model. You can use the logistic regression. But you will only know if there is a link between these two variables with a T-Test or a wilcoxon test depending on the normality of the data",0.1016881243684853,False,1,7377 2021-04-09 22:35:53.997,How do I find the date string from the numeric value?,"When I run time.mktime(datetime.strptime(""2012-03-09"", ""%Y-%m-%d"").timetuple()) I get the value 1331251200.0. Now I want to know how can I invert this? So if I pass in 1331251200.0, how do I get as output 2012-03-09? I know strftime is the inverse of strptime, but I don't see how to invert the whole thing because of the timetable function.","So the way to do this is by time.strftime(""%Y-%m-%d"", time.localtime(time.mktime(datetime.strptime(""2012-03-09"", ""%Y-%m-%d"").timetuple()))). I didn't know strftime would turn the timetable to a string before I asked.",0.0,False,1,7378 2021-04-11 05:16:38.417,Is instabot.py safe to use?,I am unfamiliar with the instaboy.py python package. I am wondering if there are any security issues with this package like possibly getting information leaked. I am wondering how does the API work if there are a lot of people using this package. Wouldn't you need your own personal Instagram API token? I am confused by the whole concept and if anyone could explain even just a little bit it will be much appreciated.,"Bots are now easily detected by Instagram. Your account could be banned for 3 days, 7 days, 30 days or definitively if Instagram detects too many attempts Usually bots simulate a browser via Sellenium and then create a ""browse like a human"" bot to create likes, follow, unfollow, etc.",0.0,False,1,7379 2021-04-12 07:59:11.797,How can I replace a full image placeholder by an empty one?,"I would like to programatically delete image placeholders which are full (PlaceholderPicture objects in the python-pptx API) and replace them with empty ones (PicturePlaceholder), the goal being to ""refresh"" pictures instead of always having to fill out an empty presentation. I think I know how to delete a shape, but creating a new PicturePlaceholder proves harder than expected. When I try to create one I am asked to provide a sp and a parent and I cannot find in the documentation what these parameters refer to. Does my approach make sense, and if so is it possible to create new placeholders programmatically? Could anyone explain what are the parameters I should pass to the constructor? Thanks in advance.","python-pptx has no API support for this, which means you would need to directly manipulate the underlying XML of the slide to accomplish it (and be outside the python-pptx ""safety net""). sp is the shape element (generally an element, hence the name) and parent would be a reference to the slide. As a general approach, I would create an empty placeholder and compare its XML to that of a ""filled"" placeholder which is the same in every respect. Then the job is to make one into the other. Note that a picture placeholder has a relationship to the ""image part"" (e.g. PNG file) stored elsewhere in the PPTX package (.pptx file). This will need to be dealt with and not left dangling. Another possibility is just to swap the image and leave everything else in place, which on paper at least would be less disruptive. Because none of these options has API support, pursuing them involves taking on responsibility for a lot of details that python-pptx takes care of for you and learning a fair amount about the internals. If that sounds like something you'd rather avoid then you'll want to find another way to accomplish the broader outcome you have in mind.",1.2,True,1,7380 2021-04-12 08:34:37.157,pandas plt.legend issue. error says that 'legend only accepts two non-keyword arguments',"I use the below statement, extracting cell content as legend name (I have 3 set of values to plot on y-axis, thus need 3 legend parameters) plt.legend(df.iat[0, 0], df.iat[0, 1], df.iat[0, 2]) the compiled error says that 'legend only accepts two non-keyword arguments' I print out the df.iat[0, 0], df.iat[0, 0], df.iat[0, 0], all these 3 are the cell content I expect. Anyone know how I can fix it?","You have to put the values in a list: plt.legend([df.iat[0, 0], df.iat[0, 1], df.iat[0, 2]])",0.0,False,1,7381 2021-04-12 10:52:41.020,How can I make an one-user input have consequences in the behaviour of all page?,"Is a very simple page, that have some buttons redirecting to external links. That external links have to change arbitrarely when certain people decides it. I was wondering about making a login screen in other page and depending which user logs in, set the link writting it in a txt file that would be recovered by the main page. Don't need security so i just would make the user go to the other page and login and that would change the link in a txt file hosted in the same directory that the index.html is. The problem is that i cannot make that idea (writing a .txt in the project folder) with JavaScript (or i think so), and i don't think that using a database worth it (neither want to because i read that would have to use node.js or something like that and i really don't know those tecnologies, only some python and sql server -that is in fact not supported by my hosting service-), cause are just 3 people associated to 1 link each. I can easily make that task with python but don't know how to call it from JS and neither if Ajax request would be useful for this case. I hope someone can help me! edit - the changes have to apply for the page itself not in the user session, so everyone who enters see the page with the changes edit 2 - absolutely all the info (users and links) are always the same, doesnt change so i can put it in variables, are just 4 or 5 so i can easily use an array, the only thing that i would have to register is which one to pick (since it depends on who decides it).","IT seems you want to use some sort of client side storage across different html pages - for that, you can use cookies, localSotrage or sessionStorage.",1.2,True,1,7382 2021-04-12 13:35:47.970,How to use pip for python 3.9 instead of inbuilt python 3.8 in Ubuntu?,"Today I faced a problem regarding pip3 in Ubuntu. Ubuntu comes with python 3.8 but I wanted to use latest versions of python, like 3.9 or maybe 3.10. So I installed it using 'ppa:deadsnakes' repository and also installed pip. But the problem is I want to use pip in python 3.9 instead of version 3.8. So I changed the default python version to 3.9 and everything crashed. So reverted to python 3.8. Whenever I install some package it gets installed using python 3.8. Help me, how can I use python 3.9 pip and install packages in python 3.9 without changing the default version. Any help is appreciated. --> Thing I want is that when I want to install python package using pip3 install it must install in python3.9 and not in python3.8","Hello everyone I fixed my issue. The problem is we cannot override default python version in Ubuntu as so many things depend on it. So I just made an alias as : alias pip3='python3.9 -m pip' and alias for python : alias python3='/usr/bin/python3.9' If anyone face this issue please do what I specify and you will be good to go. Now all my packages are being installed in python3.9.",0.296905446847765,False,3,7383 2021-04-12 13:35:47.970,How to use pip for python 3.9 instead of inbuilt python 3.8 in Ubuntu?,"Today I faced a problem regarding pip3 in Ubuntu. Ubuntu comes with python 3.8 but I wanted to use latest versions of python, like 3.9 or maybe 3.10. So I installed it using 'ppa:deadsnakes' repository and also installed pip. But the problem is I want to use pip in python 3.9 instead of version 3.8. So I changed the default python version to 3.9 and everything crashed. So reverted to python 3.8. Whenever I install some package it gets installed using python 3.8. Help me, how can I use python 3.9 pip and install packages in python 3.9 without changing the default version. Any help is appreciated. --> Thing I want is that when I want to install python package using pip3 install it must install in python3.9 and not in python3.8",you can use pip for python3.9 by pip3.9 install ,0.0,False,3,7383 2021-04-12 13:35:47.970,How to use pip for python 3.9 instead of inbuilt python 3.8 in Ubuntu?,"Today I faced a problem regarding pip3 in Ubuntu. Ubuntu comes with python 3.8 but I wanted to use latest versions of python, like 3.9 or maybe 3.10. So I installed it using 'ppa:deadsnakes' repository and also installed pip. But the problem is I want to use pip in python 3.9 instead of version 3.8. So I changed the default python version to 3.9 and everything crashed. So reverted to python 3.8. Whenever I install some package it gets installed using python 3.8. Help me, how can I use python 3.9 pip and install packages in python 3.9 without changing the default version. Any help is appreciated. --> Thing I want is that when I want to install python package using pip3 install it must install in python3.9 and not in python3.8","You don't need to install pip separately You should be able to refer to it as such python3.9 -m pip install",0.5457054096481145,False,3,7383 2021-04-13 19:27:05.077,"kivy app in adroid with buildozer, terminal loops on ""#waiting for application to start""","I made a sample app that just says hello world with kivy and I am trying to put it on an android tablet I bought. I used a virtual machine (Virtual box) and use bulldozer to loaded to the tablet. However when I run it the terminal just prints in a loop #waiting for the application to start any idea on what could be the problem, or how can I start the application","Make sure you have enabled developer mode on the phone, the phone must be plugged in to the VM (In VirtualBox: Devices -> USB -> {phone}) and that the screen is unlocked. On the phone you should see a ""USB debugging connected"" notification when it's plugged in. If the phone is properly connected, you'll see it in Android Studio in a number of places, including the LogCat and right at the top of the screen in a little dropdown to the left of the run button. Lastly, you can run the app manually and then connect the debugger if you want. Just run the app on the phone, then click the little icon in the top right with the green bug with an arrow over it.",0.0,False,2,7384 2021-04-13 19:27:05.077,"kivy app in adroid with buildozer, terminal loops on ""#waiting for application to start""","I made a sample app that just says hello world with kivy and I am trying to put it on an android tablet I bought. I used a virtual machine (Virtual box) and use bulldozer to loaded to the tablet. However when I run it the terminal just prints in a loop #waiting for the application to start any idea on what could be the problem, or how can I start the application",I had trouble with this too. But if it runs that far then it should've successfully compiled the .apk. It should be in the same folder that you ran the buildozer command. You can even run an HTTP server with buildozer serve and access it via localhost:THE_PORT_NUMBER_HERE. Then you can just transfer or download the .apk to your device. And then install and run it after accepting the correct permissions.,0.0,False,2,7384 2021-04-15 07:22:32.047,how to make django project click on a particular tab of a url,"I am developing a code using python and Django for web scraping. I have provided the required url and already fetched the data. But there is a tab on the url saying ""show more results"". How can I make my Django project to click on that tab of ""show more results"" on the url and the fetch the new results now. I have used Beautiful Soup library for web scraping/","BeautifulSoup is an HTML parser and nothing more, if you want to automate clicking and so on you have to use other tools such as selenium. Another idea might be getting the URL of ""Show more results"" and scrape the stuff that it loads. I assume it is loading the thing dynamically so look at your Network Tab (Ctrl+Shift+i then Network) and see which URL it is loading you may be able to scrape it.",0.0,False,1,7385 2021-04-15 15:57:43.700,"In python with selenium, how do you rotate IP addresses?","I am trying to scrape information off of a website (on Chrome) where I need to click on each subpage to get the information I need. After about 7, I get blocked by the website. I think if I was able to switch IPs either each time or once I get blocked, that would work. I am using Selenium to open the site and navigate to the subpages. I have tried using a try-catch block so far and a while loop but I am getting errors I do not know how to address. Does anyone have an alternative approach or previous success doing this?",You can use rotating proxies to change your IP per request or with a time interval but If you don't want to use any proxy you can restart your router to get a new IP address from your ISP but If you have a static IP from your ISP even through you restar your router your IP will stay the same.,0.0,False,1,7386 2021-04-16 01:53:37.950,how to find min/max axis length across the centroid of a closed curve,"I'm doing a segmentation task. Now I successfully segmented the area of interest and find the contour of the area. How can I calculate the min/max axis length of the contour? The axis does not have to be orthogonal. What I already got are: coordinates of points on the contour. centroid of the contour. What I already tried: I have found a fitting-ellipse of the contour. However, fitting-ellipse can only find the orthogonal axis which might not be the minimum or maximum length across the centroid.","Since you already have the contour, you might want to do this: for alpha = 0 to 45 degrees, rotate the contour by alpha, draw a line over the centroid of your contour that is parallel to X-axis, find out the intersection points of this line and the contour, that is one ""axis"" at current angle alpha. continue rotating the contour and find more of such ""axis"", find the longest one as your max axis, shortest one as your min axis.",0.0,False,1,7387 2021-04-16 07:29:43.963,How to upload an image to MongoDB using an S3 bucket and Boto3 in Python,"I'm working on a Python application where the desired functionality is that the webcam is used to take in a live video feed and based on whether a condition is true, an image is clicked and uploaded to a database. The database I am using is MongoDB. As far as I can understand, uploading images straight-up to a database is not the correct method. So, what I wanted to do is the following: an image is clicked from the webcam the image is uploaded to an S3 bucket (from the same Python script, so using boto3 perhaps) a URL of the uploaded image is retrieved (this seems to be the tricky part) and then this URL along with some other details is uploaded to the database. (this is the easy part) My ideal workflow would be a way to take that image and upload it to an S3 bucket, retrieve the URL and then upload this URL to the database all in one .py script. My question is: how do I upload an image to an S3 bucket and then retrieve its public URL all through boto3 in a Python script? I also welcome any suggestions for a better approach/strategy for storing images into MongoDB. I saw on some pages that GridFS could be a good method but that it is not recommended for the image uploads happening frequently (and really that using AWS is the more preferable way).","You don't need to 'retrieve' the public url, you get to specify the bucket and name of the s3 object when you upload it, so you already have the information you need to know what the public url will be once uploaded, its not like s3 assigns a new unique name to your object once uploaded.",0.2012947653214861,False,1,7388 2021-04-16 14:12:28.737,Import and work with large dataset (Python beginners),"since i couldn't find the best way to deal with my issue i came here to ask.. I'm a beginner with Python but i have to handle a large dataset. However, i don't know what's the best way to handle the ""Memory Error"" problem. I already have a 64 bits 3.7.3 Python version. I saw that we can use TensorFlow or specify chunks in the pandas instruction or use the library Dask but i don't know which one is the best to fit with my problem and as a beginner it's not very clear. I have a huge dataset (over 100M observations) i don't think reducing the dataset would decrease a lot the memory. What i want to do is to test multiple ML algorithms with a train and test samples. I don't know how to deal with the problem. Thanks!","This question is high level, so I'll provide some broad approaches for reducing memory usage in Dask: Use a columnar file format like Parquet so you can leverage column pruning Use column dtypes that require less memory int8 instead of int64 Strategically persist in memory, where appropriate Use a cluster that's sized well for your data (running an analysis on 2GB of data requires different amounts of memory than 2TB) split data into multiple files so it's easier to process in parallel Your data has 100 million rows, which isn't that big (unless it had thousands of columns). Big data typically has billions or trillions of rows. Feel free to add questions that are more specific and I can provide more specific advice. You can provide the specs of your machine / cluster, the memory requirements of the DataFrame (via ddf.memory_usage(deep=True)) and the actual code you're trying to run.",0.0,False,1,7389 2021-04-17 18:02:51.213,Accessing Cache Slower than Accessing Database,"I am tinkering with redis and mysql to see how caching can improve performance. Accesing data from Cache is/should be faster than accessing it from database. I calculated the time required for both the case in my program and found out that accesing from cache was much slower than accesing from the database . I was/am wondering what might be the cause(s). Some points to consider: I am using Azure Redis Cache. The main application is on VM instance. I hosted MYSQL server on another VM instance. The table is very small with 200-300 records. There is no error in the time calculation logic. EDIT: Load time for cache=about 1.2s Load time for mysql= about 15ms Turns out my application and MySQL server were in a same region while the redis cache was in a different region across the globe causing much higher latency. But I would still want someone to explain why the fetch time for sql was much more smaller.","If the table of 200-300 rows is fully cached in MySQL's ""buffer_pool"", then it won't take much time to fetch all of them and send them back to the client. 15ms is reasonable (though it depends on too many things to be more specific). If you are fetching 1 row, and you have an index (esp, the PRIMARY KEY) to locate that one row, I would expect it to be even faster than 15ms. I'm summarizing a 40K-row table; it is taking under 2ms. But note: client and server are on the same machine. 15ms could represent the client and server being a few hundred miles apart. How long does a simple SELECT 1 take? That will give you a clue of the latency, below which you cannot go without changing the physical location of machines.",0.0,False,1,7390 2021-04-18 00:50:09.637,How to manage several selenium scripts running at once on VDS?,"Currently, I have two python bots running on VDS, both of them are using selenium and running headless chrome to get dynamically generated content. While there was only one script, there was no problem, but now, it appears that the two scripts fight for the chrome process (or driver?) and only get it once the other one is done. Have to mention, that in both scripts, Webdriver is instantiated and closed within a function, that itself is ran inside a Process of multiprocessing python module. Running in virtual environment didn't do anything, each script has their own file of chrome driver in their respective directories, and by using ps -a I found that there are two different processes of chromedriver running and closing, so I am positive that scripts aren't using the same chrome. Sometimes, the error says ""session not started"" and sometimes ""window already closed"". My question is - how do I properly configure everything, so that the scripts don't interfere with each other?","For anyone having the same problem - double-triple-quadriple-check that the function, that you're passing in the Process, is the one instantiating Webdriver. I can't believe this problem is fixed just like that.",1.2,True,1,7391 2021-04-18 12:40:07.397,Can I get topics distribution of a word in LDA?,"I'm new to LDA and I want to calculate the topic similarity between words. Can I get the topic distribution of a word? If so, how can I do this in gensim.ldamodel?","Gensim's LDA mallet wrapper has a load_word_topics() function (I would assume this is true for its python LDA implementation as well). It returns a matrix that is words X topics. From that, you can get a vector of frequencies each word in each topic. That would be the topic-word distribution for a given word.",1.2,True,1,7392 2021-04-19 01:04:06.923,How can I pass information from an item to a Modal in django to edit it?,"I have a template where I'm showing with a 'for' my elements, and those elements have a Edit button, so what I want to do, is when the user clicks edit, a pop up appears with the form and the information of that item. So I don't know how to do that:(",so if you are using Javascript in your template then you can get the row index of clicked button and then get information from there and bind it to your popup.,0.0,False,1,7393 2021-04-19 01:17:15.190,How to get the first message in a channel,"I would like to know how to get the first message in a channel. But more preferably could you point me to the part of the documentation that explains this, please?","TextChannel has a history method. If you type await channel.history() you can get all messages in that text channel. But this starts from last message. To start from first message, use oldest_first=True in method. Also you can limit the amount of message with a keyword argument limit.",0.6730655149877884,False,1,7394 2021-04-19 13:14:40.823,how to add Publisher Name in Pyinstaller exe file,"I work on one project in that code in python script.py and with help of pyinstaller build exe file but issue is that I want to add publisher name in exe file. FREE exe with publisher name I browse on google but I do not get a solution. i don't have a code sign certificate. I don't have a signtool i don't know how to connect a self sign certificate with an exe file. Please guide me.","There is no way to do this for free. If you want to sign your executables, you will need to buy a code-signing certificate and use signtool to sign them. Code signing certificates cost about $300 per year. signtool is part of the Windows SDK; you can get it in the free ""community"" editions of Visual Studio.",0.0,False,1,7395 2021-04-19 13:54:25.727,Examples in docplex to use the user cut callback method technology,"Please can you provide an example of how this can used in a python notebook environment with docplex. I see examples with java on ATSP problem. The point is I do not know how to create these cuts upfront. Given a LP root node, I can generate the cut. So, ""add_user_cut_constraint(cut_ct, name=None)"" should in a way take in as input the root node. How do I retrieve that in a generic way?","Look at this code in my contribs repository: https://github.com/PhilippeCouronne/docplex_contribs/blob/master/docplex_contribs/src/cut_callback.py It is not a notebook, but you'll get the idea on how to interface callbacks with Docplex.",1.2,True,1,7396 2021-04-20 03:57:32.507,Is there any python equivalent of OOBPermutedVarDeltaError from Matlab?,"OOBPermutedVarDeltaError states that For any variable, the measure is the increase in prediction error if the values of that variable are permuted across the observations. This measure is computed for every tree, then averaged over the entire ensemble and divided by the standard deviation over the entire ensemble To find its equivalent would I need to calculate the increase in prediction error across observations and then average it across the entire ensemble? Being fairly new to ML, I am not sure how I would implement it even. Any help would be most appreciated.","No, there arent any. Python and Matlab, does not scale 1:1",0.0,False,1,7397 2021-04-20 10:17:31.917,How would I go about generating cities and countries with perlin noise?,"recently I made a little program that generates a country with a bit of info, like the country name, size and most importantly cities. It generates a random number of cities and towns and villages based on the country's size, this is all text based so that is why I would give it a nice flare with some graphics. Now, I have been researching a bit and it seems that my best option would be Perlin noise or some form of noise, so my question is, how would I go about doing this? Where do I start? Are there other ways of accomplishing this? So, in short, how do I take the randomly generated text cities and towns and villages in my program and randomly generate them on some form of map? I hope this all makes sense. Also, my program is written in python.","There is lots of problem in what you saying. What platform are you using? Arcade? PyGame? etc. I will write the arcade code for you so you can use. To use arcade, type pip install arcade in Windows, or pip3 install arcade on Linux. Edit: Please can you post your code so I can implement?",0.3869120172231254,False,1,7398 2021-04-20 10:33:44.593,Generate the data for A.I. to play the Snake game,"I would like to generate some data (position of the snake, available moves, distance from the food...) to create a neural network model so that it can be trained on the data to play the snake game. However, I don't know how to do that. My current ideas are: Play manually (by myself) the game for many iterations and store the data (drawback: I should play the game a lot of times). Make the snake do some random movements track and track their outcomes. Play the snake with depth-fist search or similar algorithms many times and store the data. Can you suggest to me some other method or should I choose from one of those? Which one in that case? P.S. I don't know if it is the right place to ask such a question. However, I don't know whom/where to ask such a question hence, I am here.","If using a neural network, start simple. Think inputs and outputs and keep them simple too. Inputs: How many squares to the left of the head are free How many squares to the right of the head are free How many squares forward of the head are free Relative position of next food left/right Relative position of next food forward/back Length of snake keep inputs normalized to the minimum and maximum possible values to keep inputs in range -1.0 to 1.0 Outputs: Turn Left Turn Right Straight Ahead (choose the output with highest activation) Next problem is training. Typical application might be use a genetic algorithm for all the weights of the above neural network. This randomizes and tests new versions of the neural network every life. After X attempts, create a new evolution and repeat to improve. This is pretty much doing random moves automatically (your second choice) Next problem is fitness for training. How do you know which neural network is better? Well you could simply use the length of the snake as a fitness factor - the longer the snake, the better and more 'fit'",1.2,True,1,7399 2021-04-20 20:56:50.407,Add comment to an order's timeline in Shopify,"Is there a way to add a comment to an order's timeline via the REST API ? If so, what's the scope access ? And how to do this. Thanks","You cannot add a comment to the timeline. You can see your App's interactions with an order on the timeline, exposed by Shopify, but you cannot inject stuff yourself. If you want to decorate an order with comments, you would add your comment to the order notes. That works fine, but as you can tell, it is not timestamped by Shopify, so it lacks an ""official"" standing... nonetheless. Just use Notes.",1.2,True,1,7400 2021-04-21 11:13:25.350,How to query only the date in a timestamp,"So in my table there are a number and a timestamp row, there are multiple numbers per day its like: number timestamp 3 20.02.2021 16:05:00 7 20.02.2021 16:10:00 20 20.02.2021 16:15:00 5 21.02.2021 16:00:00 now i want the average of the numbers of the day of 20.02.2021 but i don't know how i should do that with SQLAlchemy any suggestions?","Not sure if this will fully answer your question, but to get just the date portion of a timestamp you can recast the timestamp as date by: select your_timestamp_column::date",1.2,True,1,7401 2021-04-21 14:07:19.107,What is the best way to encode a large number of categorical features?,"I'm trying to make a small data science tool (kinda like a mini version of WEKA). Now, I have these datasets that have large amounts of features (70-100+), and they're mostly categorical. I'm using Python sklearn for the Machine Learning logic and I need to convert these categories into numeric values according to the sklearn errors I've gotten. Given this, One Hot Encoding isn't an option because it will enlarge the dimensionality too much. I've researched other ways that may work like frequency encoding, label encoding, etc. But I'm not really sure what to choose in my case. Also, would anyone know how WEKA actually handles these? I inputted my datasets in WEKA and they worked fine, they gave me good results! Any help would be greatly appreciated. Thanks!","That depends on the algorithm: Some handle categorical attributes natively, like J48 (Weka's C4.5 implementation), which performs multi-way splits on categorical attributes. Others have to convert the data, like SMO (support vector machine), which binarizes nominal attributes and increases the number of attributes to learn from.",0.0,False,1,7402 2021-04-21 15:56:20.670,Recognizing images and incorporating into code,"I have a programming project in mind, but have only scratched the surface of my programming experience. I'm just about done with my first Python class, so that's about how much experience I have. Now my question, is it possible to read and recognize an image (business card/playing card/ image with text) and produce an operation based on the information read? The image would be at a distance, and I would be using a camera or xbox kinect.","yeah it's possible, you can train machine learning models.",0.0,False,1,7403 2021-04-23 09:22:56.527,How save a C++ pointer in python to pass it again later?,"I'm trying to create something and I don't know if it's possible or ""clean"" : From python, call function A of my C++ code to compute something complicated The C++ code returns just the pointer to the python Do other things in python... From python, call function B of my C++ code, it takes the pointer and other things as arguments. I really don't need to use my complicated C++ class in my Python algorithm, that's why I just want to save the pointer in python. Anyone has any advice on how to do that ? Edit : In the end I wrapped the c++ class in python, thank you everyone.","A pointer is just data that can be marshaled and sent to anything. It is however a very bad idea because when doing that, you have to assure that that pointer remains valid as long as the python part has the pointer. There is no possibility to check whether the pointer is still valid, so dereferencing a pointer that you receive from an external party could crash your program. A better idea in a lot of situations is to send a key to a table. When that key is sent back, it can be used to get the needed information from that table and it can be handled when the table doesn't have the key anymore. It is easiest to use std::map for the table. Of course, you could store the pointer in a container and check for that, but a string or number is easier to debug.",1.2,True,2,7404 2021-04-23 09:22:56.527,How save a C++ pointer in python to pass it again later?,"I'm trying to create something and I don't know if it's possible or ""clean"" : From python, call function A of my C++ code to compute something complicated The C++ code returns just the pointer to the python Do other things in python... From python, call function B of my C++ code, it takes the pointer and other things as arguments. I really don't need to use my complicated C++ class in my Python algorithm, that's why I just want to save the pointer in python. Anyone has any advice on how to do that ? Edit : In the end I wrapped the c++ class in python, thank you everyone.","It would be better to create a class in C++ and store that pointer in the class itself as private. Then create function calls to access those pointers. Once the class is implemented generate the .so file of your lib and import it in python. This way you can simply use your C++ code in python and also will not have to save the pointer.",0.0,False,2,7404 2021-04-23 14:57:25.240,"Regex match no groups, 1st group OR 2nd group but not both. Something like 'NAND'","I can't figure out how to write regex that matches these: everyone hi hi everyone hi But not this: everyone hi everyone The regex (?:everyone )?hi(?: everyone)? will match the latter as well (which is not what I want). How to make such a regex? Or is it just not possible? I couldn't do enough research because I couldn't express the problem in correct words. Sorry if I posted a duplicate","You could explicitly make a regex for each case (the first will capture two), utilizing beginning and end of line tokens (^hi( everyone)?$) (^everyone hi$)",0.3869120172231254,False,1,7405 2021-04-23 19:24:25.200,getting an issue in sklearn.linear_model._logistic in ml,"can anyone tell me how to fix this? ModuleNotFoundError: No module named 'sklearn.linear_model._logistic' File ""c:\users\chintan\appdata\local\programs\python\python37\lib\site-packages\streamlit\script_runner.py"", line 332, in _run_script exec(code, module.dict) File ""C:\Users\chintan\Desktop\streamlit\Final_year_project\App.py"", line 329, in main() File ""C:\Users\chintan\Desktop\streamlit\Final_year_project\App.py"", line 264, in main loaded_model = load_model(""logistic_regression_hepB_model.pkl"") File ""C:\Users\chintan\Desktop\streamlit\Final_year_project\App.py"", line 96, in load_model loaded_model = joblib.load(open(os.path.join(model_file),""rb"")) File ""c:\users\chintan\appdata\local\programs\python\python37\lib\site-packages\sklearn\externals\joblib\numpy_pickle.py"", line 588, in load obj = _unpickle(fobj) File ""c:\users\chintan\appdata\local\programs\python\python37\lib\site-packages\sklearn\externals\joblib\numpy_pickle.py"", line 526, in _unpickle obj = unpickler.load() File ""c:\users\chintan\appdata\local\programs\python\python37\lib\pickle.py"", line 1088, in load dispatchkey[0] File ""c:\users\chintan\appdata\local\programs\python\python37\lib\pickle.py"", line 1376, in load_global klass = self.find_class(module, name) File ""c:\users\chintan\appdata\local\programs\python\python37\lib\pickle.py"", line 1426, in find_class import(module, level=0)",Try to install a version like: pip install scikit-learn==0.22,0.0,False,1,7406 2021-04-23 22:05:01.343,"GRPC: Sending messages from Python to C#, best method?","I am working on a project that just scrapes data from 3 devices (2xserial and 1xssh). I have this part implemented no problem. I am now heading towards the second part where I need be be able to send the data I need using protobuf to the clients computer where they will receive and display on their own client. The customer has provided examples of their GRPC servers, and it's written in C#. Currently, for security reasons, our system uses RedHat 8.3 and I am using a SSH Protocol Library called Paramiko for the SSH part. Paramiko is a Python library. Also the machine I am extracting data from only runs on Linux. Here are my main questions, and I apologize if I got nowhere. 1.) The developer from the client side provided us with a VM that has a simulator and examples written in C# since their side was written in C#. He says that it's best to use the C# because all examples can be almost re-used as it's all written, etc. While I know it's possible to use C# in Linux these days, I've still have no experience doing so I don't know how complicated/tedious this can get. 2.) I write code in C# and wrap all the python code, which is also something I've never done, but I would be doing this all in RedHat. 3.) I keep it in python because sending protobuf messages works across languages as long as it is sent properly. Also from the client side, I'm not sure if they will need to make adjustments if receiving protobuf messages written in Python(I don't think this is the case because it's just serialized messages, yea?). Any advice would be appreciated. I am looking to seek more knowledge outside my realm. Cheers, Z","If you're happy in Python, I would use option 3. The key thing is to either obtain their .proto schema, or if they've used code-first C# for their server: reverse-engineer the schema (or use tools that generate the schema from code). If you only have C# and don't know how to infer a .proto from that, I can probably help. That said: if you want to learn some new bits, option 1 (using C# in your system) is also very viable. IMO option 2 is the worst of all worlds.",0.0,False,1,7407 2021-04-24 13:54:35.623,"Python: how to get unique ID and remove duplicates from column 1 (ID), and column 3 (Description), Then get the median for column 2 (Value) in Pandas","Python: how to get unique ID and remove duplicates from column 1 (ID), and column 3 (Description), Then get the median for column 2 ID Value Description 123456 116 xx 123456 117 xx 123456 113 xx 123456 109 xz 123456 108 xz 123456 98 xz 121214 115 abc 121214 110 abc 121214 103 abc 121214 117 abz 121214 120 abz 121214 125 abz 151416 114 zxc 151416 135 zxc 151416 127 zxc 151416 145 zxm 151416 125 zxm 151416 121 zxm Procced table should look like: ID xx xz abc abz zxc zxm 123456 110 151 0 0 0 0 121214 0 0 132 113 0 0 151416 0 0 0 0 124 115","Well you have e.g. 6 'ID' with value '123456'. If you only want unique 'ID', you need to remove 5 'ID' rows, by doing this you will not have duplicate 'Description' values anymore. The question is, do you want unique ID or unique Description values (or unique combination of both)?",0.0,False,1,7408 2021-04-25 12:20:04.407,Jupyter Notebook remote browser without disconnecting,"I'm running a jupyter notebook remotely on a server by connecting to the server: ssh server:address initialize the jypter notebook ipython notebook --no-browser --port=7000 using another terminal window, stabilish remove connection to the notebook ssh -N -f -L localhost:6001:localhost:7000 server:address finally I access it throw localhost:6001 in my browser. The thing is: I'd like to keep the notebook running when I turn my computer off. Any ideas on how can I do it?","You could create a crontab on your remote server with your command ipython notebook --no-browser --port=7000 to manage the execution of Jupiter notebook, that could be the way go.",0.0,False,1,7409 2021-04-25 20:32:26.673,Command line interface for python module,"I'm not sure what to search for this. I am writing a piece of code using python fire to create a command line interface. python test.py function argument is there a way to make the shell interpret the following like the command above: test function argument Similar to how I can just call jupyter lab and it will open a notebook etc. I have a feeling this is more to do with setting up my bashrc or similar instead of something I can do in Python.","You're correct that it has to do with adding to your .bashrc. You want to set an alias. Make sure your code has an appropriate shebang line at the top, ex. #!/usr/bin/python3 Add the following to .bashrc, ex. alias test=python3 /path/to/test.py From there, you can use sys.argv in your code to handle arguments within the program.",0.0,False,2,7410 2021-04-25 20:32:26.673,Command line interface for python module,"I'm not sure what to search for this. I am writing a piece of code using python fire to create a command line interface. python test.py function argument is there a way to make the shell interpret the following like the command above: test function argument Similar to how I can just call jupyter lab and it will open a notebook etc. I have a feeling this is more to do with setting up my bashrc or similar instead of something I can do in Python.","Add the hashbang (at the start of the file, in case you don't know) #!/usr/bin/env python or #!/usr/bin/env python3 Replace the 3 with whatever version you have installed and want that file to run Save the file to an already existing PATH or add the file location to PATH Now you can hopefully run it by typing test.py function argument Rename test.py to test Now you should be able to run it as test function argument Also make sure your file is set as executable",0.0,False,2,7410 2021-04-26 13:12:23.350,"If __metaclass__ is a class attribute, how does it control the generation of the class?","We know that when generating a class in Python2, if there is a metaclass attribute, it will be generated by the metaclass referenced by the attribute. Bug when the class is not generated, it should have no attribute, how does it control the generation of the class?","Because the body of the class definition statement is evaluated before the creation of the class object. So indeed, the class doesn't have that attribute, the class doesn't even exist yet. But the class definition statement has been evaluated.",0.5457054096481145,False,1,7411 2021-04-26 19:00:52.583,analogs of socket in python,"Can you advise me on the analogs of the socket library on Python? The task is this, I need to write a very simple script with which I could execute remote commands in cmd windows. I know how this can be implemented using the socket library, but I would like to know if there are any other libraries for such a case.","Sockets is a low level mechanism by which two systems can communicate each other. Your OS provides this mechanism, there's no analogs. Next examples come from the application layer and they work with sockets in their lower communication layers: a socket open by your http server, usually 80 or 443 or a websocket open by your browser to communicate with your server. Or the DNS query that your browser executes when tries to resolve a domain name, also works with sockets between your PC and the DNS server.",1.2,True,1,7412 2021-04-27 12:25:58.437,Saving/Storing pymatgen Structures,"I'm currently dealing with a material science dataset having various information. In particular, I have a column 'Structure' with several pymatgen.core.Structure objects. I would like to save/store this dataset as .csv file or something similar but the problem is that after having done that and reopening, the pymatgen structures lose their type becoming just formatted strings and I cannot get back to their initial pymatgen.core.Structure data type. Any hints on how to that? I'm searching on pymatgen documentation but haven't been lucky for now.. Thanks in advance!","pymatgen.core.structure object can be stored with only some sort of fixed format, for example, cif, vasp, xyz... so maybe you, first, need to store your structure information to cif or vasp. and open it and preprocess to make it ""csv"" form with python command.(hint : using python string-related command).",0.3869120172231254,False,1,7413 2021-04-27 15:50:53.090,how to make a video stream bot for discord.py?,I want to make a bot with discord.py that can stream videos from mp4 into a voice channel. Is it possible? and if it is possible how would I be able to do it (and sorry if this is a stupid question i am a beginner),"At the moment it isn't possible, you can only stream audio.",0.0,False,1,7414 2021-04-28 11:58:59.870,how to make a discord bot in python that can show a youtube video?,"my goal is to make a bot that is able to show youtube videos through screen sharing or camera. Does anyone know how to do it? I tried to find out how to do it but I have not managed to find something similar on internet, even on stack overflow.",It happens that zoom will share a video in the way that you want.,0.0,False,1,7415 2021-04-28 13:57:29.203,How to use jinja tags inside Javascript file?,"Let's say i need to have the javascript in a seperate file, then how can i add a {{variable}} for example in the javascript file without having to use a