[{"Question":"In python I can get test coverage by coverage run -m unittest and the do coverage report -m \/ coverage html to get html report.\nHowever, it does not show the actual unit test report. The unit test result is in the logs, but I would like to capture it in a xml or html, so I can integrate it with Jenkins and publish on each build. This way user does not have to dig into logs.\nI tried to find solution to this but could not find any, please let me know, how we can get this using coverage tool.\nI can get this using nose2 - nose2 --html-report --with-coverage --coverage-report html - this will generate two html report - one for unit test and other for coverage. But for some reason this fails when I run with actual project (no coverage data collected \/ reported)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1862,"Q_Id":63195130,"Users Score":0,"Answer":"Ok for those who end up here , I solved it with -\nnose2 --html-report --with-coverage --coverage-report html --coverage .\/ \nThe issue I was having earlier with 'no coverage data' was fixed by specifying the the directory where the coverage should be reported, in the command above its with --coverage .\/","Q_Score":1,"Tags":"python,unit-testing,code-coverage","A_Id":63252613,"CreationDate":"2020-07-31T15:51:00.000","Title":"Python Coverage how to generate Unittest report","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a Python script using shutil to move files from an internal folder to any present USB drives automatically. Even after the script closes, it seems that the OS does not always actually move the files to the USB drive until sometime later. My research suggests the OS does this delay for wear leveling purposes, but I am not certain that's the real explanation. Is there something I can add (ideally to my Python script or tied to it) so that the write will actually be executed immediately? Perhaps a different way to move the file, some way to demand an immediate sync, verifying the files were really moved, or doing some follow-on action that would require the OS to truly execute the move?\nTo be clear, I am not talking about problems from pulling the USB while the write is actively happening. The files are in total not many KB in size and I am seeing the problem even when the drive is pulled 40+ seconds later. The drives aren't blinking. I am not seeing partial writes where some files are moved and others aren't that would suggest I'm interrupting it midway through. Even if this was the issue, I think my question is still a valid question.\nBackground: I am running Raspbian Buster desktop version and Python 3.7.3 on a Pi4. I want to run this Pi without keyboard or monitor so that no user intervention is required to pull the drives or put in replacement ones. I have to run the desktop despite there being no monitor or else the Pi will not automount USB drives, but that is a separate issue. I am a noob, so especially thorough explanations would be particularly appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":569,"Q_Id":63201971,"Users Score":1,"Answer":"As @tdelaney said in their comment, the thorough-to-the-point-of-overkill way is to call flush() on the file object, then os.fsync() on its file descriptor, which since Raspbian is based on the Linux kernel shouldn't return until the buffers are flushed.\nBut if you're using one of the shutil.copy* functions, you don't have a file object to call those on, so you can just call out to os.system(\"sync\").\nBut note that even if the kernel is dusting its hands and saying \"yup, flushed those buffers\", the data could still be working its way through the device driver internals and not yet physically written to the media. You can't get a 100% guarantee that it's all the way through unless you're manually driving the USB logic, but the next best thing is adding a command to unmount the file system.\nThe problem is that code running from the USB stick can't unmount the filesystem containing itself, so if your Python is on the stick, it can't do the unmount. You can do it manually from the command line, though. Just umount \/path\/to\/usb\/stick should do it.","Q_Score":0,"Tags":"python,raspberry-pi,raspbian,raspberry-pi4","A_Id":63217368,"CreationDate":"2020-08-01T05:03:00.000","Title":"Python on Linux: How to *immediately* move files to USB to avoid issues from OS not syncing and the USB suddenly being pulled","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I need help understanding the security of JWT tokens used for login functionality. Specifically, how does it prevent an attack from an attacker who can see the user's packets? My understanding is that, encrypted or not, if an attacker gains access to a token, they'll be able to copy the token and use it to login themselves and access a protected resource. I have read that this is why the time-to-live of a token should be short. But how much does that actually help? It doesn't take long to grab a resource. And if the attacker could steal a token once, can't they do it again after the refressh?\nIs there no way to verify that a token being sent by a client is being sent from the same client that you sent it to? Or am I missing the point?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":446,"Q_Id":63214644,"Users Score":1,"Answer":"how does it prevent an attack from an attacker who can see the user's packets?\n\nJust because you can see someone's packets doesn't mean that you can see the contents. HTTPS encrypts the traffic so even if someone manages to capture your traffic, they will no be able to extract JWT out of it. Every website that is using authentication should only run through HTTPS. If someone is able to perform man-in-the-middle attack then that is a different story.\n\nthey'll be able to copy the token and use it to login themselves and access a protected resource\n\nYes but only as the user they stole the token from. JWT are signed which means that you can't modify their content without breaking the signature which will be detected by the server (at least it is computationally infeasible to find the hash collision such that you could modify the content of the JWT). For highly sensitive access (bank accounts, medical data, enterprise cloud admin accounts...) you will need at least 2-factor authentication.\n\nAnd if the attacker could steal a token once, can't they do it again after the refressh?\n\nPossibly but that depends on how the token has been exposed. If the attacked sits on the unencrypted channel between you and the server then sure they can repeat the same process but this exposure might be a result of a temporary glitch\/human mistake which might be soon repaired which will prevent attack to use the token once it expires.\n\nIs there no way to verify that a token being sent by a client is being sent from the same client that you sent it to?\n\nIf the attacker successfully performs man-in-the-middle attack, they can forge any information that you might use to verify the client so the answer is no, there is no 100% reliable way to verify the client.\n\nThe biggest issue I see with JWTs is not JWTs themselves but the way they are handled by some people (stored in an unencrypted browser local storage, containing PII, no HTTPS, no 2-factor authentication where necessary, etc...)","Q_Score":1,"Tags":"python,jwt,access-token,django-rest-auth","A_Id":63214865,"CreationDate":"2020-08-02T09:58:00.000","Title":"JWT authorization and token leaks","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Here is the situation.\nTrying to run a Python Flask API in Kubernetes hosted in Raspberry Pi cluster, nodes are running Ubuntu 20. The API is containerized into a Docker container on the Raspberry Pi control node to account for architecture differences (ARM).\nWhen the API and Mongo are ran outside K8s on the Raspberry Pi, just using Docker run command, the API works correctly; however, when the API is applied as a Deployment on Kubernetes the pod for the API fails with a CrashLoopBackoff and logs show 'standard_init_linux.go:211: exec user process caused \"exec format error\"'\nInvestigations show that the exec format error might be associated with problems related to building against different CPU architectures. However, having build the Docker image on a Raspberry Pi, and are successfully running the API on the architecture, I am unsure this could the source of the problem.\nIt has been two days and all attempts have failed. Can anyone help?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":181,"Q_Id":63215868,"Users Score":2,"Answer":"Fixed; however, something doesn't seem right.\nThe Kubernetes Deployment was always deployed onto the same node. I connected to that node and ran the Docker container and it wouldn't run; the \"exec format error\" would occur. So, it looks like it was a node specific problem.\nI copied the API and Dockerfile onto the node and ran Docker build to create the image. It now runs. That does not make sense as the Docker image should have everything it needs to run.\nMaybe it's because a previous image build against x86 (the development machine) remained in that nodes Docker cache\/repository. Maybe the image on the node is not overwritten with newer images that have the same name and version number (the version number didn't increment). That would seem the case as the spin up time of the image on the remote node is fast suggesting the new image isn't copied on the remote node. That likely to be what it is.\nI will post this anyway as it might be useful.\n\nEdit: allow me to clarify some more, the root of this problem was ultimately because there was no shared image repository in the cluster. Images were being manually copied onto each RPI (running ARM64) from a laptop (not running ARM64) and this manual process caused the problem.\nAn image build on the laptop was based from a base image incompatible with ARM64; this was manually copied to all RPI's in the cluster. This caused the Exec Format error.\nBuilding the image on the RPI pulled a base image that supported ARM64; however, this build had to be done on all RPI because there was no central repository in the cluster that Kubernetes could pull newly build ARM64 compatible images to other RPI nodes in the cluster.\nSolution: a shared repository\nHope this helps.","Q_Score":1,"Tags":"python,docker,ubuntu,kubernetes,raspberry-pi","A_Id":63215869,"CreationDate":"2020-08-02T12:15:00.000","Title":"Python runs in Docker but not in Kubernetes hosted in Raspberry Pi cluster running Ubuntu 20","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Pytest reports errorif an assert fails in an initialization fixture, and failif a test fails after the initialization fixture has run.\nTo make the test suite stop on errors or failures, the following flags can be used:\n-x, --exitfirst exit instantly on first error or failed test.\nHow can I make the test suite stop after the first error but keep going if there are failures?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":559,"Q_Id":63248262,"Users Score":0,"Answer":"Replacing all assert's with pytest.exit(\"some_message\") in the initialization fixture does the trick.","Q_Score":1,"Tags":"python,pytest","A_Id":63260925,"CreationDate":"2020-08-04T13:45:00.000","Title":"Stop pytest on errors but not on fails","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Here is a chronological summary of what happened.\n\nMy local copy of a branch, let's call it featurebranch is fully up to date with the copy of this branch on github\nOn my local machine, I delete a file called test.csv.\nI call \"git pull origin featurebranch\" on my local machine, but the test.csv does not show up on my local machine\nI call \"git status\" and output is \"Changes not staged for commit: deleted test.csv\"\nI call \"git add test.csv\"\nI call \"git status\" and output is \"Changes to be committed: deleted test.csv\"\nI call \"git commit - m \"delete test file\"\"\nI call \"git pull origin featurebranch\" and output is \"Already up to date\"\n\nIt's not up to date though. test.csv still exists on github but not on my local machine. How do I get this file back on my local machine? I assume there is something about how git works that I do not realize. Thank you for reading.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":30,"Q_Id":63250623,"Users Score":0,"Answer":"git pull is used to \"sync\" your branch with the latest commits in the remote repository (GitHub). It is not used to sync files.\nSince featurebranch was never updated in the remote with new commits that you don't have, git pull has nothing to do - there are no new commits to fetch and sync to. Your commit is the most up-to-date version of that branch.\nIf you want your file back, you can either git reset the branch to some older commit that contained the branch. Or you can git revert the commit that deleted that file. Or you can git checkout -- test.csv to selectively restore the file from that contains the file. Or you can git checkout or git switch to some other branch\/commit to change your working directory to a commit that actually had that file.","Q_Score":0,"Tags":"python,git,github,terminal,branch","A_Id":63250771,"CreationDate":"2020-08-04T15:55:00.000","Title":"After deleting a file from my local machine, how do I pull from github to obtain that file again?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to send formatted message from Viber Bot with Markdown or HTML tags?\nIf yes - then how? What attributes to specify?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1402,"Q_Id":63267388,"Users Score":3,"Answer":"Response from Viber Developer Support:\n\nformatting text with our API is only possible for keyboard or rich media buttons, not for text messages.","Q_Score":1,"Tags":"bots,viber,viber-api,viber-bot,viber-bot-python","A_Id":63446335,"CreationDate":"2020-08-05T14:30:00.000","Title":"How to send markdown or HTML message via Viber bot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to send formatted message from Viber Bot with Markdown or HTML tags?\nIf yes - then how? What attributes to specify?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1402,"Q_Id":63267388,"Users Score":0,"Answer":"Good news from future, add a character on both sides without space:\nbold with *,\nitalic with _,\nwasted with ~,\nmonospace with ```.\nBut the formatted view is rendered only in the mobile version.","Q_Score":1,"Tags":"bots,viber,viber-api,viber-bot,viber-bot-python","A_Id":66764341,"CreationDate":"2020-08-05T14:30:00.000","Title":"How to send markdown or HTML message via Viber bot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was trying to test run my python solution in Foobar platform using verify solution.py option . But I am continuously getting this error : 'CSRF Failed: CSRF token missing or incorrect.'\nShould I change my cookie preferences ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":167,"Q_Id":63270317,"Users Score":0,"Answer":"Try enabling cookies in your browser and reloading the page.","Q_Score":0,"Tags":"python,python-3.x,google-chrome,csrf","A_Id":65066245,"CreationDate":"2020-08-05T17:17:00.000","Title":"CSRF Failed: CSRF token missing or incorrect. error while submitting the foobar solution in Google's foobar platform","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to put a python script on a pyboard that\u2019s running micro python. Is there a python equivalent of .zfill In MicroPython?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":714,"Q_Id":63271522,"Users Score":0,"Answer":"welcome to SO!\nNo, MicroPython does not have a zfill method on strings.\nIf you're looking for a specific width, you'll need to get a len(str) and then concatenate the desired string of \"0\"s to the start of string.","Q_Score":1,"Tags":"micropython","A_Id":63272834,"CreationDate":"2020-08-05T18:35:00.000","Title":"Is there a Zfill type function in micro python. Zfill in micro python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I don't get the benefits of using TA-Lib abstract \u00bfis it speed? \u00bfless processing? I went through the documentation, examples, and code examples, but can't get it. \u00bfcan anyone explain it?\nEDIT: This question is not opinion-based, as you can see in the answer, it's about performance of the function API vs abstract API of ta-lib","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":170,"Q_Id":63279925,"Users Score":1,"Answer":"This API allows you to list all TA functions implemented in DLL (because python's ta-lib module is just a wrapper around compiled C library) and call them by indicator name (a string), instead of hardcoding switch with 200+ cases and rebuilding your app every time TA-lib adds new indicator. It also allows you to get info about data that indicator requires which may be used to adjust UI for end user asking him to enter the required data. So this API is designed not for a python data scientists who play with single TA indicator, but for desktop and web programmers writing GUI applications or web services addressed to wide audience. There is no any performance benefits.","Q_Score":0,"Tags":"python,ta-lib","A_Id":63287682,"CreationDate":"2020-08-06T08:44:00.000","Title":"TA-Lib abstract API benefits","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I`m quite new to python packages and I just want to know if a Python package can contain modules written in other languages as for example C or C++.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":71,"Q_Id":63303131,"Users Score":1,"Answer":"Yeah, some of the packages are written in c and c++ in order to improve speed. For eg open cv is written in c++.","Q_Score":0,"Tags":"python,python-3.x,namespaces,package,python-module","A_Id":63304133,"CreationDate":"2020-08-07T13:46:00.000","Title":"Can a Python package contain a module written in C or C++?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"after I type python\nthe SSH goes run python in command line. How to exit? I want to type new \"SUDO\" command but i can't exit python \"mode\".","AnswerCount":5,"Available Count":3,"Score":0.0798297691,"is_accepted":false,"ViewCount":1723,"Q_Id":63309189,"Users Score":2,"Answer":"Just use exit(). It will exit python.","Q_Score":1,"Tags":"python,command-line,read-eval-print-loop","A_Id":63309205,"CreationDate":"2020-08-07T21:10:00.000","Title":"How to go back to command line","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"after I type python\nthe SSH goes run python in command line. How to exit? I want to type new \"SUDO\" command but i can't exit python \"mode\".","AnswerCount":5,"Available Count":3,"Score":0.1194272985,"is_accepted":false,"ViewCount":1723,"Q_Id":63309189,"Users Score":3,"Answer":"Give the console exit() should work.","Q_Score":1,"Tags":"python,command-line,read-eval-print-loop","A_Id":63309214,"CreationDate":"2020-08-07T21:10:00.000","Title":"How to go back to command line","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"after I type python\nthe SSH goes run python in command line. How to exit? I want to type new \"SUDO\" command but i can't exit python \"mode\".","AnswerCount":5,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":1723,"Q_Id":63309189,"Users Score":3,"Answer":"You can press Ctrl + D or type exit() in console to be able to exit Python's shell.","Q_Score":1,"Tags":"python,command-line,read-eval-print-loop","A_Id":63309212,"CreationDate":"2020-08-07T21:10:00.000","Title":"How to go back to command line","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I recently began learning C++. As a programmer coming from Python, I've noticed some general similarities when it comes to how certain things in C++ do the same thing over in Python.\nOne question I had is understanding Preprocessor directives. I\/O Stream seems to be a common one to use in beginner programs.\nIs #include effectively the same thing as import in Python, or is it completely different than importing \"modules\"?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":147,"Q_Id":63310209,"Users Score":3,"Answer":"C++ did not have modules until the latest standard (C++20). #include is not the same as import in the languages that support modules. Instead, it is a source code - level inclusion of a \"header\" file. Usually, the headers only contain declarations but not definitions of what you are \"importing\". The definitions are contained in compiled libraries that are added by the linker.","Q_Score":1,"Tags":"c++,include,python-import","A_Id":63310266,"CreationDate":"2020-08-07T23:10:00.000","Title":"Understanding Preprocessor Directives in C++ as a beginner","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an email form on my webpage where the goal is for users to be able to send my account an email. They give me their email but is there a way to send a message from their email to my email without their password. All i'm seeing online is code to send out emails through flask not recieve. What work arounds do you guys suggest where I can have users send me an email through my website.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":28,"Q_Id":63322561,"Users Score":1,"Answer":"I am pretty sure that this is not possible.\nOtherwise you would have \"access\" on their account and could write mails to everyone you want.\nA solution would be to save the message in the database and if you need it, you can send the message to you, with all the needed information, by your own mail adresse (like AKA commented).","Q_Score":0,"Tags":"python,html,forms,email,flask-mail","A_Id":63326079,"CreationDate":"2020-08-09T04:49:00.000","Title":"Recieving emails from my website through flask?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am wondering if there is a method to connect 3ds Max and Maya. For example, I want to use a Maya plugin to send a maxscript to 3ds Max to import an fbx in 3ds max. I think it just like send to Max function in Maya, and it seems like the OneClickDispatch does similar work, but I do not how OneClickDispatch sends the script to 3ds max and execute it. Does anyone know how to do it?\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":259,"Q_Id":63334042,"Users Score":0,"Answer":"For example SublimeEditor is doing it by finding 3dsMax window handle, then is finding handle of childwindow \"Scintilla\" - maxscript listener, send text there, like filein @\"X:\\location\\to\\your\\temp\\script\" and then return char - should be easy to snitch from Sublime, otherwise you have to be quite familiar with Windows ShellApi","Q_Score":0,"Tags":"python,maya,3dsmax,maxscript","A_Id":63944618,"CreationDate":"2020-08-10T04:13:00.000","Title":"Send and Execute maxscript or python from Maya to 3ds Max","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I wanna add members of a specific telegram group to another group. But there is an issue, I have a problem with flood waiting of Telegram.\nIs it possible to add whole members of the group with their user_id to my contacts then adding them to my group?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":1788,"Q_Id":63337120,"Users Score":-1,"Answer":"This is not possible because you can not add a member who did not save the ID in your Telegram contact.\nit is like to create a new group.\nTelegram does not allow you","Q_Score":0,"Tags":"javascript,python,telegram,telegram-bot","A_Id":63337325,"CreationDate":"2020-08-10T09:00:00.000","Title":"How can I move member from telegram group to another group","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have 2 Raspberry Pi 4 units.Both have been updated and upgraded and both flashed with rasbian lite. I created a really simply script, on the first raspi which connects to my pc on port 5999 and performs a basic function of grabbing the time and sending that on said port. My pc accepts it, prints it and writes it to a file. The second raspi has the exact same script with same permissions etc and the script does not work. No errors etc returned. I would for example run the server side on my pc, run the client side on the first raspi, works 100%, disconnect and run the same script on second raspi and no response on server side or client side. I have check \"netstat -a\"command, port listening etc on pc, have changed the port numbers on one and both raspis' but still cannot get the first raspi to send data.\nAny similar experiences? Thank you in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":22,"Q_Id":63338245,"Users Score":0,"Answer":"Problem solved, sorry guys, thx anyway for reply, omitted the 6 in the LAN IP address in the code on one of the raspberry Pi units.\nIf anyone wants the code then I will post, client and server working on PI4 units. Just let me know in comments.","Q_Score":0,"Tags":"python,raspberry-pi,raspberry-pi4,python-sockets","A_Id":63339650,"CreationDate":"2020-08-10T10:16:00.000","Title":"Two Raspi4 different responses on Socket Programming to PC","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to know if it's possible to write a script for my keyboard, which can change single letters. For example, I want to type \"e\" instead of \"p\". Is it possible to get the \"p\" after entering a keystroke like \"e\"?\nThe purpose is: I've a broken keyboard and I want to replace some letters for my main usage. So the script must run immadiately after entering a keystroke. If that makes sense!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":56,"Q_Id":63354719,"Users Score":1,"Answer":"I'd recommend Autohotkey instead.","Q_Score":4,"Tags":"python,keyboard","A_Id":63354975,"CreationDate":"2020-08-11T08:50:00.000","Title":"Python Script to change keyboard letters","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In my github repository, I have a python script say script.py.\nI want to check if this produces the desired output or not? \nI can copy the code of this file ad run it on my local machine but this script.py is using functions and modules from other files in the repository as well. So I cannot simply copy script.py and run it to test it.\nSo what should I do? How do I make sure that this produces the right output?\nI am very new to git and VC so please answer elaborately.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":125,"Q_Id":63361427,"Users Score":1,"Answer":"It depends on what you want to do.\nFirst, try to think GitHub as a place only to put your code, without any other functionalities (which actually is not the case). So if you want to run a script script.py and it depends on other files in the same repo, then you have to download at least itself and the files it depends on, more easily just download the entire repo. This is also the easiest way since if there are updates in the remote repo, you can pull the change to your local repo. It guarantees you have the same content between remote and local.\nAnd yes, there are other ways. Like @yflelion said, you can try travis CI (or any CI). Think of CI being some program runners, and once you have some code changes it will run though some pre-defined code and make sure all of them are correct. This approach leads you into the concept of software testing and DevOps. It requires a lot more work than just simply clone the repo and run, but it is automated and can assure the code quality through an intensive and long developing process of a product.\nBTW just out of curiosity, why are you trying not to clone the repository? Is there any non-trivial reason?","Q_Score":0,"Tags":"python,git,file,testing,github","A_Id":63370948,"CreationDate":"2020-08-11T15:28:00.000","Title":"How to test my script in a github repo which is dependent upon other files in the repo","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In my github repository, I have a python script say script.py.\nI want to check if this produces the desired output or not? \nI can copy the code of this file ad run it on my local machine but this script.py is using functions and modules from other files in the repository as well. So I cannot simply copy script.py and run it to test it.\nSo what should I do? How do I make sure that this produces the right output?\nI am very new to git and VC so please answer elaborately.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":125,"Q_Id":63361427,"Users Score":1,"Answer":"why you don't clone your repository and run your script?","Q_Score":0,"Tags":"python,git,file,testing,github","A_Id":63361487,"CreationDate":"2020-08-11T15:28:00.000","Title":"How to test my script in a github repo which is dependent upon other files in the repo","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to use Python3.7 for a project, but Ubuntu 20.04 doesn't have python3.7-dev in the apt repositories. I've installed Python3.7 from a tarball, but it doesn't install the headers. I noticed in the build directory that libpython3.7m.a exists, but I'm looking for libpython3.7.so. I don't see any options to build shared versus static library, and I don't where that file goes, I was hoping the build script would take care of that.\nDoes anyone know the recommended way to install python headers from older versions?","AnswerCount":3,"Available Count":1,"Score":-0.1325487884,"is_accepted":false,"ViewCount":14222,"Q_Id":63369951,"Users Score":-2,"Answer":"maybe you can use libpython3.7m-pic.a instead, which acts like libpython3.7.so to some extent","Q_Score":4,"Tags":"python,python-3.7,ubuntu-20.04","A_Id":66524988,"CreationDate":"2020-08-12T04:48:00.000","Title":"How to install python3.7-dev on Ubuntu 20.04?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Is there any way to get the person who invited the bot to the server? My point is to dm that person to tell her what to do so things go smoothly and I don't want the bot to just write it in a random text channel that everybody could see. Thanks in advance","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":210,"Q_Id":63386784,"Users Score":1,"Answer":"There isn't any way yet to know who invited the bot.\nWhat you can do is DM the Server Owner when its added to a Server.","Q_Score":1,"Tags":"python,python-3.x,discord,discord.py","A_Id":63386809,"CreationDate":"2020-08-13T01:23:00.000","Title":"Get person who invited the discord bot discord.py","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I use theano.test() to test the theano, it report\uff1a\nImportError: The nose module is not installed. It is needed for Theano tests.. But I check the package by pip list, I find that nose 1.3.7 is already exsist.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":402,"Q_Id":63408266,"Users Score":1,"Answer":"It might be the Python version?\nCurrently, Theano Release 1.0 only supports >=3.4 and <3.6. If your Python version is higher than 3.5.X, try downgrading and then re-run the Theano test. Do let everyone know if that works.","Q_Score":2,"Tags":"python,theano,nose","A_Id":63876255,"CreationDate":"2020-08-14T07:18:00.000","Title":"report \"ImportError: The nose module is not installed. It is needed for Theano tests.\" when use \"theano.test\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Do I need a domain for both of the apps or I can just embed them on one server and make them communicate to each other","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":60,"Q_Id":63423582,"Users Score":0,"Answer":"What you probably need is a cloud hosting, then php can run on port 80 while python on 81 or any other port.\nSo 127.0.0.1 for php and 127.0.0.1:81 for python","Q_Score":0,"Tags":"php,python-3.x","A_Id":63423636,"CreationDate":"2020-08-15T07:19:00.000","Title":"How to make two web app talk to each other one developed with PHP and the other with python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I\u2019m looking to essentially use two devices: raspberry pi 3 and Mac 10.15. I am using the pi to capture video from my web cam and I want to use my Mac to kind of extend to the pi so when I use cv2.videocapture I can capture that same video in preferably real-time or something close. I\u2019m programming this using python on bout devices. I thought of putting it on a local server and retrieving it but I have no idea how I could use that with opencv. If someone could provide and explain a useful example, I would greatly appreciate it. Thank you.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":63433319,"Users Score":0,"Answer":"To transfer a video stream, you could use instead of a custom solution a RTMP server on the source machine feeding it with the cam source and the target opens the stream and processes it.\nA similar approach to mine is widely implemented into IP cameras: They run a RTMP server to make the stream available for phones and PC.","Q_Score":0,"Tags":"python-3.x,opencv,raspberry-pi3","A_Id":63433404,"CreationDate":"2020-08-16T04:59:00.000","Title":"Play video from one device to another","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Do Modelica environments offer interfaces to the Python language so that\n\nBuilding the system to be simulated in the visual modeling environment while the settings for the simulation are created wit Python. In this way, I will be able to run the simulation several times within an optimization algorithm in Python.\n\nBuilding complex systems as functions in a language that I already know, for example, I want to create a function in Python that represent the system, then run this function from a \"block\".","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":137,"Q_Id":63444148,"Users Score":2,"Answer":"Usually most Modelica simulation environments would offer interfaces to scripting languages like Python. Another alternative is to export a Modelica model using any simulation environment to so called Functional Mockup Units (FMU) which are stand-alone software programs. There are software solutions in Python for simulating an exported FMU multiple times, e.g. each with different values of parameters.\n\nThe Modelica language supports calls to external functions written in C\/Fortran but not Python.","Q_Score":0,"Tags":"python,modelica","A_Id":63449212,"CreationDate":"2020-08-17T03:23:00.000","Title":"Open Source Simulation program to work along with Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to make a command where when someone types for example '!messages @mee6' it shows how many messages that person has said in the server. So say if I typed \"a\" \"b\" \"c\" then did \"!messages\"\nthe bot would reply with \"@user has sent 3 messages in this server. Does anyone know if this would be possible and if so how would I go about doing it in discord.py?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":56,"Q_Id":63456592,"Users Score":0,"Answer":"The principle is the following:\nYou'd have to take advantage of the Message Received event. Once a message is received, update the counts for the person, and when the !messages command is ran, display the amount.\nLooping through every channel in the server and filtering all messages from the user is extremely inefficient and time taking, as well as it can get your bot ratelimited.","Q_Score":0,"Tags":"python,discord.py","A_Id":63457199,"CreationDate":"2020-08-17T18:23:00.000","Title":"Is it possible to make a command !messages @user","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using a raspberry pi as a server to host a program. Part of what this program does is interface with websites such as spotify, google sheets, and google forms through their respective APIs (or a library wrapper)\nIn order to interface with spotify, i've attempted to use a python module called 'spotipy' which is a wrapper for the spotify API. However, i'm having trouble getting it to work, and I have a feeling its because the API requires authentication which utilizes the systems browser, i.e. chromium on the pi, but chromium does not have support for open.spotify.com due to its limited capabilities.\nIs it reasonable to say that a web API wont work without access to the website you are attempting to interface with?\nHopefully this is provides enough information, thanks.","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":68,"Q_Id":63461337,"Users Score":-1,"Answer":"github.com\/plamere\/spotipy#quick-start\nto answer your question, you don't need chromium to use APIs. According to the quickstart that I linked above\n\nyou need to register your raspberry pi as an App on spotify dev site and acquire the \"credentials\"\nthen declare those credentials in your script","Q_Score":0,"Tags":"python,api,raspberry-pi,spotipy","A_Id":63461488,"CreationDate":"2020-08-18T03:11:00.000","Title":"Using web APIs with limited website access (raspberry pi)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm brand new to Github but experienced using Python and just wondered how to use both so that I can upload and export scripts for others to use! I have created a repository to start with! Any help would be great.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":15,"Q_Id":63467101,"Users Score":0,"Answer":"for a beginner with GitHub as you, it will be great to use GitHub desktop.\nDownload it and clone the repository you created. Now move your files into the repository folder. In GitHub desktop add a quick summary about what you changed and click the \"commit\" button. With this you created a timestamp in the history of your repository, but it is only available on your local machine. Now click the \"push origin\" button on the top in GitHub desktop. This will push the changes to the repository. When your repository will become more popular, people might want to commit changes to it. To do this, they will open a pull request and you just need to approve it and their changes will be merged into your repository. I hope this helped. If you don't understand anything about GitHub, feel free to ask. :)","Q_Score":0,"Tags":"python,github,repository","A_Id":63467226,"CreationDate":"2020-08-18T10:53:00.000","Title":"How do you create a GitHub Repository so that I can automatically import and export python scripts?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have multiple large CSV files (~1GB) that are compressed as GZ. My problem is that they are encoded in ISO-8859-1 and I would like them to be in UTF-8.\nObviously I could just decompress each file, convert them to UTF-8, and compress them back but this seems quite inefficient memory-wise to me.\nIs there a clean and efficient way to do this on-the-spot and avoid having to temporary store large files?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":144,"Q_Id":63474786,"Users Score":1,"Answer":"You mentioned two different concerns, \"inefficient memory-wise\" and \"temporary store large files\" as if they were one question. They aren't.\nYou certainly do not need to and should not load the entire file into memory. You can use Python's GzipFile class to read small chunks of a file and write small chunks back out. So no memory problem.\nIn doing that, you would need to retain the input file in mass storage until the output file is complete, at which point you can delete the input file. While you can avoid having an intermediate uncompressed file in mass storage, you will at least need, temporarily, enough free mass storage for a second copy of the file.","Q_Score":0,"Tags":"python,encoding,utf-8,gzip","A_Id":63477273,"CreationDate":"2020-08-18T18:42:00.000","Title":"How to efficiently convert the encoding of a gzipped text file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I currently have a bot that pings people if certain criteria are met. The issue is that the bot will ping spam if the content is repeated. For example, say user JohnSmith#1234 says \"ping me if someone says 'apple' or 'apples' in the chat.' It'll do so. However, say there are 4 messages in quick succession:\n\nUser1: \"Hey, do you like apples?\"\nUser2: \"Yeah, I like apples\"\nUser1: \"What's your favorite kind of apple?\"\nUser2: \"I don't really have a favorite apple, but I like Granny Smith\"\n\nthen the bot will say:\n\n@JohnSmith#1234 for \"apple\"\n@JohnSmith#1234 for \"apple\"\n@JohnSmith#1234 for \"apple\"\n@JohnSmith#1234 for \"apple\"\n\nbecause \"apple\" was mentioned 4 times. Is there a way to tell the bot \"if you pinged JohnSmith#1234 in the last 10 seconds, don't ping him again?\" I basically want an action to not execute if it's been done recently.\nEdit:\nWhile the answers shown seem to work for just 1 user, they don't seem to work for multiple. The answers will accommodate JohnSmith#1234 just fine, but as of now, it'll render the bot useless until JohnSmith#1234's delay is done.\nI'm not sure how to tell the bot \"keep doing what you're doing, but run the delay loop on the side.\" Here's what the bot is currently doing, continuing off of the example I provided previously:\n1: Say @JohnSmith#1234 for 'apple'\n2: Puts John Smith into a waiting dictionary until 10 seconds is up. (Note: the bot won't do anything else but wait. This is bad because it should ping users besides John Smith).\n3: If those 10 seconds are up, it'll ping John Smith again. Otherwise, it'll keep doing stuff for other users.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":380,"Q_Id":63476864,"Users Score":1,"Answer":"Create a cooldown dictionary where you can store people the bot has already pinged and the end of the cooldown. Ex: cooldows = {\"JohnSmith#1234\": 1597786825}.\nThen when your bot tries to ping someone just check if they are in the dictionary. if they are check the epoch timestamp, if the time now is greater than the time listed, remove the user from the dictionary and ping him, if its not don't ping them. If they are not in the dictionary the bot can ping them","Q_Score":0,"Tags":"python,discord.py","A_Id":63477038,"CreationDate":"2020-08-18T21:27:00.000","Title":"Is there a way to stop a Discord.py bot from doing a repeat action if it's been done in the past X seconds?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am developing module for web server. In one of my php modules I am using system($command, $response) call in order to execute python script, but I get response \"1\" which means \"operation not permitted\". I did the following actions in order to solve this problem, but nothing helped:\n\nchmod 777 for every php file in execution pipeline and chmod 777 for executed my_python_script.py.\nchown my_server_daemon for my_python_script.py.\n\nA little more useful information for case understanding:\n\nServer system: Linux 2.6.32-042stab141.3 x86_64 GNU\/Linux\nPython file was written on Win10, but line ending were changed using dos2unix my_python_script.py\n\nDo you have any ideas how to solve this problem? Everything works fine, when I execute script manually in terminal, but fails, when I try to do this using PHP system().","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":27,"Q_Id":63496747,"Users Score":0,"Answer":"The question is closed. It's really stupid, I didn't pay attention that my_python_script.py works with external .txt file, which hadn't write permission for other users. Be careful :)","Q_Score":0,"Tags":"php,python-3.x,linux,permissions,webserver","A_Id":63497225,"CreationDate":"2020-08-20T00:31:00.000","Title":"Can't execute python script via system() call in PHP","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Whenever I am trying to run testcases in Robot framework through cmd, i am getting the below error:\nParsing failed UnicodeDecodeError: 'utf-8' codec can't decode byte 0x92 in position 31: invalid start byte\nThe above error thrown for some files and below error for some files\nParsing failed UnicodeDecodeError: 'utf-8' codec can't decode byte 0x92 in position 47: invalid start byte\nAnd then my test fails saying there is no such tag in the suite I am referring to, but I have the tag in my file.\nInitally I thought it was because of some setting in the editor(STS) I am using and changed the settings under Window-> preferences -> General -> Workspace -> text file encoding option to 'Other' and selected utf-8, gave workspace rebuild, restarted the STS, but still no luck.\nBeen searching for a solution since weeks. Can someone help me on this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":451,"Q_Id":63501153,"Users Score":0,"Answer":"Checking each and every Testcases by removing and adding them in new file and also by removing all the special characters used in keyword definition as well in testcase definition in the robot files resolved the issue","Q_Score":0,"Tags":"python-3.x,unicode,utf-8,robotframework,decode","A_Id":67487485,"CreationDate":"2020-08-20T08:26:00.000","Title":"Getting UnicodeDecodeError: 'utf-8' when robot framework testcases are run in command prompt","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"My bot is in a few servers now and one of the main bits of feedback I've gotten is that server admins would like to block the bot from responding in certain channels without having to go through Discord's permissions manager. However I am unsure of where to start with this so I thought I'd reach out here and see if I can get any advice or code snippets to use!\nBasically the admin would use like !fg ignore 'channel name or id' and then somewhere the bot would store this and not respond, and then similarly if they use !fg unignore 'channel name or id' it would then remove that from the list or where ever its stored.\nAny help would be greatly appreciated, thanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":493,"Q_Id":63514605,"Users Score":0,"Answer":"You'll need to keep the channels ids in a list then in the bots on_message function check if the message is not in that channel and if not then run your commands.","Q_Score":0,"Tags":"python,python-3.x,discord,discord.py","A_Id":63514633,"CreationDate":"2020-08-20T23:47:00.000","Title":"Discord.py - How would I go about making a command that will allow server admins to block the bot from responding in specified channels?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to know which user is connected with the organization via OAuth2.0 .I noticed in the xero developer site it contains some information but not clear enough. Is there anyone who is having python code written for this.\nReason : Currently I am getting all the organisation informations from the API connection.I need to filter the content of these output based on the user type who is connected(Ex: Manager).So for that I need to know which user(user email address) is connected with Oauth2.0","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":56,"Q_Id":63536726,"Users Score":2,"Answer":"To find out the email address of the authorizing user you need to ask for the openid profile email scopes during authorization. You will then receive an id token back (along with the access and refresh token) which you can decode to get the user's name and email address.\nAny OpenID Connect library will allow you to do this.","Q_Score":1,"Tags":"python,xero-api","A_Id":63551620,"CreationDate":"2020-08-22T13:30:00.000","Title":"Oauth2.0 Expose which user connected the organization via OAuth","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing index.py for my web page test on my Ubuntu laptop.\nI wrote #!usr\/bin\/env python3 at the top of the code and used some print() lines below it.\nwhen I open the webpage under my IP address... the page is not printing what I intended and shows the whole code directly.\nCould you see what I was wrong with?\nThanks!\nPaul","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":63538389,"Users Score":0,"Answer":"Browsers don't understand python and they shouldn't run any file on your PC, so they will show the file as if it were HTML.\nTo make a website with python, you can either use a webframework like django or just write the ouput of your python script into a html\/text file.","Q_Score":0,"Tags":"python,html,shebang","A_Id":63538634,"CreationDate":"2020-08-22T16:16:00.000","Title":"shebang python line on ubuntu is not working for my webpage","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am setting up a discord game which uses folders as profiles, how do I fix the problem that if someone changes their username the bot can no longer access their profile?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":50,"Q_Id":63547065,"Users Score":1,"Answer":"Use the UserID instead of the Username.\nThis never changes unless they change to a different account, so you won\u2019t have to worry about usernames changing.","Q_Score":0,"Tags":"python,discord,discord.py","A_Id":63547104,"CreationDate":"2020-08-23T12:40:00.000","Title":"Python\/Discord Username changes prevents my bot from recognizing players","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So as the title says.. ''Is there a way to get the emails of new YouTube subscribers? Python''\ni am planning to build an emailing list wherein if a person subscribes to my youtube channel, i want to be able to automatically send them an email containing my latest blogs and video updates. so is there a way to do that? maybe using the youtube api? or external codes or websites?\ni know that i could just ask them for their email addresses using a google form and link that to a python script that sends emails using SMTP but i want to do it automatically when they subscribe to my youtube channel.\nany help will help alot\nthank you","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":222,"Q_Id":63571445,"Users Score":0,"Answer":"Yes, you can. You can use the youtube api. Simply call the api, and get whatsoever the element is, for new subscribers. Then, you can create a text and mail it to yourself.\nFor making it run all the time, you have to go to the terminal and keep it running...","Q_Score":0,"Tags":"python,python-3.x,email,youtube,youtube-data-api","A_Id":63576069,"CreationDate":"2020-08-25T03:00:00.000","Title":"Is there a way to get the emails of new YouTube subscribers? Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hello i need to install Anbox for running some of android apps in my parrot machine,i tried install the anbox by the documentation provide by them , For installing the Kernel Modules i need to add ppa repo it give exception\nsudo add-apt-repository ppa:morphis\/anbox-support\ngives exception\naptsources.distro.NoDistroTemplateException: Error: could not find a distribution template for Parrot\/n\/a\nCan you help me to install the anbox in my parrot machine","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1122,"Q_Id":63617916,"Users Score":0,"Answer":"Parrot OS does not take add-apt-repository command.\nTry adding manually in the sources file instead.","Q_Score":0,"Tags":"python,android,linux,parrot-os","A_Id":64254397,"CreationDate":"2020-08-27T14:11:00.000","Title":"How to install Anbox in Parrot OS?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am just getting into python and am specifically using Pillow and piexif to extract and edit EXIF data for bunch of jpegs that I have. I used piexif to extract and read the EXIF data information like ImageDescription, and noticed lots of fields have random letters in front; when I first pulled ImageDescription, it read b'Olympus.....' I edited the tag and when I output it now gave me, as a test, just test (no b or apostrophe's, and samples from piexif showed u's)\nAnyone know the purpose of the apostrophe and\/or the random letters?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":63619836,"Users Score":0,"Answer":"I did some research and found that there are several letters that are used like u, r or b. If an r is found before the string, it becomes a string literal, and u and b are just encoding options.","Q_Score":0,"Tags":"python,python-imaging-library,exif,piexif","A_Id":63742073,"CreationDate":"2020-08-27T15:56:00.000","Title":"Importance of Random Letters when Reading EXIF Information Via piexif","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to write and receive data from a frequency response analyser. I am connecting to the instrument using a serial connection via a Serial-USB adapter. The manual says it will only transmit when CTS (pin8) is high, and only receive when DCD (pin1) is high, both are listed as input pins. Does anyone know if there is a way to send high signals to these pins when i want to transmit\/receive using pySerial?\nThanks.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":596,"Q_Id":63620277,"Users Score":0,"Answer":"In the end I used a wire to manually connect the CTS and DCD pins to a pin that constantly outputs a high signal.","Q_Score":0,"Tags":"python,serial-port,pyserial","A_Id":63628974,"CreationDate":"2020-08-27T16:22:00.000","Title":"Setting RS232 pins using python serial","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to write and receive data from a frequency response analyser. I am connecting to the instrument using a serial connection via a Serial-USB adapter. The manual says it will only transmit when CTS (pin8) is high, and only receive when DCD (pin1) is high, both are listed as input pins. Does anyone know if there is a way to send high signals to these pins when i want to transmit\/receive using pySerial?\nThanks.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":596,"Q_Id":63620277,"Users Score":0,"Answer":"Today, connecting a PC to a device through a serial port is often done in a peer-to-peer relationship.\nIn that case, a cable called a cross cable is used to connect the two, but there is no standard specification for the pin assignment, and there are many variations.\nDCD (and RI) is an input signal on both the PC and the device, and there is no corresponding output signal, so the RTS or DTR signal should be used as an alternative.\nHow you can handle them in software depends on the connection specifications of the cable hardware you choose.\nAfter confirming that the RTS\/DTR signal on the PC side is connected to the CTS\/DCD pin on the device side of the cable, by setting rts and dtr of PySerial to True by software, the CTS\/DCD on the device side turns on.\n\nIn response to comment:\nIf you fix the signal on the device side as described in the comment and the device side can operates in that state, the PC side will be able to send and receive at any time without additional control processing.","Q_Score":0,"Tags":"python,serial-port,pyserial","A_Id":63626195,"CreationDate":"2020-08-27T16:22:00.000","Title":"Setting RS232 pins using python serial","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was just wondering if it was possible to tweet an mp4 file with tweepy (maybe using api.update_with_media). I've seen a post from a few years ago saying that it's not possible with the official tweepy, but I find it really hard to believe that there's no way to do it with the official tweepy. Can anyone please help?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":703,"Q_Id":63625810,"Users Score":1,"Answer":"update_with_media was deprecated as a Twitter API method about 5 years ago. This pre-dated the ability to upload GIFs and video MP4s. If you want to post media on Twitter via the API, you must find a library that supports the media upload endpoints (and chunked uploads). The process is\n\nupload the media file (chunked if necessary depending on size and format)\nretrieve a media ID string\npost a Tweet, and add the media ID to the Tweet.\n\nNote that you can only post multiple images on a single Tweet; you can only post a single GIF or video file on a single Tweet, not multiple.\nI do not believe the default Tweepy release supports this but I could be wrong, you\u2019ll need to check the Tweepy documentation.\nDo NOT use update_with_media - it\u2019s very old and unsupported as an API path.\nAlso worth being aware that tweepy itself is a third party library - that we at Twitter LOVE - but this is not officially supported.","Q_Score":1,"Tags":"python,api,twitter,tweepy,twitterapi-python","A_Id":63625966,"CreationDate":"2020-08-28T00:24:00.000","Title":"Can I tweet mp4 files with tweepy?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am building a custom Linux image in Yocto Zeus (Previously used Yocto Thud). I have moved all the required code to Python3 and hence don't require Python2 anymore. Is there a way we can remove python2 and its modules completely from Image","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":796,"Q_Id":63628282,"Users Score":2,"Answer":"Start from an image inheriting core-image-minimal and add packages manually. Only the packages that are specified to be installed explicitly in your image recipe and the packages specified in RDEPENDS and RRECOMMENDS of those packages will be installed in the recipe.\nSome packages are also pulled because of configuration files (machine, distro or local.conf).\nIf there are RRECOMMENDS you don't want, you can use BAD_RECOMMENDATIONS in your image recipe to ask the image to not pull them in.\nIf it's an RDEPENDS that you don't want, maybe it's pulled because of a selected PACKAGECONFIG that you don't need, in that case create a bbappend for that recipe and set PACKAGECONFIG accordingly.\nIf that still does not do it, you'll have to dig deeper into what can be removed from RDEPENDS and for which reason (is it a mistake? is it safe in one specific configuration in which RDEPENDS is not needed?).\nThe way to know which package is pulling which package is to use -g as argument of bitbake. Do not attempt to create a scheme\/drawing\/image from the dot files, they are too big for dot to handle properly (takes hours and the result is unusable). \"recipeA:do_foo\" => \"recipeB:do_bar\" means that do_foo task from recipeA depends on do_bar from recipeB.\nPACKAGE_EXCLUDE in one of the configuration files (local.conf or distro.conf) should\nalso make it easier to identify which recipe needs the one recipe you don't want.","Q_Score":2,"Tags":"python-3.7,embedded-linux,yocto,bitbake,openembedded","A_Id":63631141,"CreationDate":"2020-08-28T06:01:00.000","Title":"Remove Python2 and related components completely in Yocto","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"$ python -c 'from gi.repository import Gtk'\n-c:1: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded.\nwhat should i do?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3352,"Q_Id":63631072,"Users Score":0,"Answer":"I had the same issue as described in the question. I tried to change the order of the above listed commands in the source file, but some extension of VS Code was resetting the order to bottom up the oder suggested in the above answer. When I force-saved the code with the sequence as suggested, it solved the query. This might work in most cases. Thank you.","Q_Score":2,"Tags":"python,linux,centos,gtk,tryton","A_Id":72136509,"CreationDate":"2020-08-28T09:28:00.000","Title":"PyGIWarning: Gtk and Rsvg were imported without specifying a version first. Use gi.require_version","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Python codebase with some tests that I am able to run with the python -m unittest... command however, when I run the same tests with bazel test, the tests just get stuck and time out. One thing to note is that the code is using python's multiprocessing, and also makes a bunch of post requests to an external service.\nUsing bazel run and logging entry points in several parts of the code verifies the code is randomly stuck.\ntop also does not show a lot of resources being used.\nAny ideas on how to debug this? Most of the tests are set to size=large and have the \"exclusive\" tag.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":399,"Q_Id":63634304,"Users Score":0,"Answer":"The bazel sandbox by default blocks all network requests. You can specify that a given test requires network access by adding the tag requires-network.\nAlternatively you can add the tag no-sandbox to disable the sandbox completely for the given test \/ action.\nIt is also possible that network access is disabled by a bazelrc option such as --modify_execution_info=TestRunner=+block-network so you might want to check your bazelrc too if the requires-network tag doesn't fix the timeouts in the tests.","Q_Score":1,"Tags":"python,multiprocessing,bazel","A_Id":63635141,"CreationDate":"2020-08-28T13:01:00.000","Title":"Bazel testing getting stuck","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I developed a small program with twilio a few days ago and it was working perfectly until today. When I run the code I get the error \"No module named 'twilio'\". I already tried uninstalling and reinstalling it, I also checked, and don't have any archive called twillio, the python version i'm using is the latest, the library seems to be correctly installed... Any idea of what may be happening?\nThe line of code that im trying to run is from twilio.rest import Client","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":361,"Q_Id":63649453,"Users Score":1,"Answer":"If you are installed 'twilio' in a virtual environment then you are probably not activating and using it properly.\nThe error can also be caused due to Circular import, which happens when you have a file named 'twilio' in the same directory as the program file. You can prevent that by changing the name to something else.\nIf you have more than one version of python you are probably using the wrong version, so select the correct version of the interpreter for python in your IDE.","Q_Score":0,"Tags":"python,twilio","A_Id":63649732,"CreationDate":"2020-08-29T16:43:00.000","Title":"ModuleNotFoundError: No module named 'twilio'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm getting decoding exception errors when reading export files from multiple applications. Have been running into this for a month, as I learn far more about unicode than I ever wanted to know. Some fundamentals are still missing. I understand utf, I understand codepages, I understand how they tend to be used in practice (a single codepage per document e.g., though I can't imagine that's still true today--see the back page of a health statement with 15 languages.)\n\nIs it true that utf-8 can and does encode every possible unicode char? How then is it possible for one application to write a utf-8 file and another to not be able to read it?\nwhen utf is used, codepages are NOT used, is that correct? as I think it through, the codepage is an older style and is made obsolete by utf. I'm sure there are some exceptions.\nutf could also be looked as a data compression scheme, less than an encoding one.\n\nBut there I'm stuck, as in practice, I have 6 different applications made in different countries, which can create export files, 3 in ut-f, 3 in cp1252, yet python 3.7 cannot read them without error:\n'charmap' codec can't decode byte 0x9d in position 1555855: character maps to \n'charmap' codec can't decode byte 0x81 in position 4179683: character maps to \nI use Edit Pro to examine the files, which successfully reads the files. It points to a line that contains an extra pair of special double quotes:\n\"Metro Exodus review: \u201cNot only the best Metro yet, it's one of the best shooters in years\u201d | GamesRadar+\"\nRemoving that \u201d allows python to continue reading in the file, to the next error.\npython reports it as char x9d, but an (really old: Codewright) old editor reports it as x94. Codewright I believe. Verified it is an x94 and x93 pair on the internet so it must be true. ;-)\nIt is very troublesome that I don't know for sure what the actual bytes are, as there are so many layers of translation, interpretation, format for display, etc.\nSo the visual studio debug report of x9d is a misdirect. What's going on with the python library that it would report this?\nHow is this possible? I can find no info about how chars in one codepage can be invalid under utf (if that's the problem). What would I search under?\nIt should not be this hard. I have 30 years experience in programming c++, sql, you name it, learning new libraries, languages is just breakfast.\nI also do not understand why the information to handle this is so hard to find. Surely numerous other programmers doing data conversions, import\/exports between applications have run into this for decades.\nThe files I'm importing are csv files from 6 apps, and json files from another. the 6 apps export in utf-8 and cp1252 (as reported by Edit Pro) and the other app exports json in utf-8, though I could also choose csv.\nThe 6 apps run on an iPhone and export files I'm attempting to read on windows 10. I'm running python 3.7.8, though this problem has persisted since 3.6.3.\nThanks in advance\nDan","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":51,"Q_Id":63653114,"Users Score":1,"Answer":"The error 'charmap' codec can't decode byte... shows that you are not using utf-8 to read the file. That's the source of your struggles on this one. Unless the file starts with a BOM (byte order mark), you kinda have to know how the file was encoded to decode it correctly.\n\nutf-8 encodes all unicode characters and python should be able to read them all. Displaying is another matter. You need font files for the unicode characters to do that part. You were reading in \"charmap\", not \"utf-8\" and that's why you had the error.\n\n\"when utf is used\" ... there are several UTF encodings. utf-8, utf-16-be (big endian), utf-16-le (little endian), utf-16 (synonym for utf-16-le), utf-32 variants (I've never seen this in the wild) and variants that include the BOM (byte order mark) which is an optional set of characters at the start of the file describing utf encoding type.\n\n\nBut yes, UTF encodings are meant to replace the older codepage encodings.\n\nNo, its not compression. The encoded stream could be larger than the bytes needed to hold the string in memory. This is especially true of utf-8, less true with utf-16 (that's why Microsoft went with utf-16). But utf-8 as a superset of ASCII that does not have byte order issues like utf-16 has many other advantages (that's why all the sane people chose it). I can't think of a case where a UTF encoding would ever be smaller than the count of its characters.","Q_Score":0,"Tags":"python,unicode,utf-8","A_Id":63653274,"CreationDate":"2020-08-30T01:08:00.000","Title":"Python unicode errors reading files generated by other apps","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to get my Arduino to talk to PyCharm via serial port but it keeps throwing up the following error:\n[Errno 20] could not open port \/dev\/tty\/ACM0: [Errno 20] Not a directory: '\/dev\/tty\/ACM0'\nThis is definitely the right port for the Arduino Uno, as confirmed by the Arduino IDE. In fact, the script works perfectly without issue using 'COM4' or similar on Windows. Unfortunately I need to move it over to linux and it doesn't seem to be a simple solve of substituting 'COM4' for '\/dev\/tty\/ACM0'.\nI've ran python -m serial.tools.list_ports to check that ports are found and it's returning 2 ports: \/dev\/tty\/ACM0 and \/dev\/ttyS0 which is a good sign.\nI've scoured the internet but can't seem to find any threads where someone has had this specific error code.\nI'm not sure what it means by 'Not a directory' and what the workaround would be for this.\nAny help would be greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":752,"Q_Id":63674089,"Users Score":0,"Answer":"for archive purposes I'll post my solution to my own question, I've realised that I've mistyped \/dev\/tty\/ACM0 instead of \/dev\/ttyACM0 in the port name in the following line:\narduino = serial.Serial('portname', 115200, timeout=.1)","Q_Score":0,"Tags":"python,arduino,pycharm,pyserial","A_Id":63674127,"CreationDate":"2020-08-31T15:52:00.000","Title":"Serial port with arduino on PyCharm pyserial error - \/dev\/tty\/ACM0 not a directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have encoded my program so I can sell it to customers.\nAlso I want to convert it to exe with the tool auto-py-to-exe so the customers won't have to install python.\nWhen I launch the encoded program from Visual Studio Code all works as intended.\nBut when I convert it to exe it returns an error message:\n\nTraceback (most recent call last):\nFile \"test.py\", line 8, in \nFile \"\", line 2, in \nModuleNotFoundError: No module named 'selenium'\n[11189] Failed to execute script test\nlogout\n\nWhen I do not encode my program I can convert it without any issues.\nAny idea what I might be missing here?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":55,"Q_Id":63683604,"Users Score":0,"Answer":"Solution was, to add the \"import\" lines for all my modules on the top level of the .py\nWorking now.","Q_Score":0,"Tags":"python,selenium,base64,pyinstaller","A_Id":63683692,"CreationDate":"2020-09-01T08:00:00.000","Title":"Python Base64 Selenium module missing when converting to exe","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a 15-year student. I am a student as well as a growing programmer. I want to create a bot that reminds the teacher that \"It's your time to leave the class!\" I heard somewhere that \"running bots on websites is illegal\". So, I thought to ask you regarding this.\nPlease tell me if I can run the time remainder bot on Google Meet.\nThank you and have a great day.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":151,"Q_Id":63686124,"Users Score":0,"Answer":"Making a bot would be possible, although the problem is that bots are against Google Rules, they would ban the bot.\nYou will not face any law complications, if this bot will be looking just as a normal user then it's fully possible.\nAnother thing - Running bots on websites is legal while owner approves your bot, but still 1 or 2 bots which will tell the teacher \"It's time to end the lesson\" aren't a reason for which a giant company would waste its time to start a court hearing.\nYou can do it, but if your bot gets banned don't make a new one.","Q_Score":0,"Tags":"python,selenium,automation,google-meet","A_Id":63686681,"CreationDate":"2020-09-01T10:44:00.000","Title":"Can i run a bot on google meet","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know very little regarding python,I'm using it to get data from twitter.\nmy old laptop has python version 3.7.3 it works fine, but I didn't set it up.\nI installed python on my new laptop, but I think I also need to install some packages from my old python (laptop)\nthe error shows in my new laptop \"no module named twitter\"\nI don't know how this works.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":59,"Q_Id":63699030,"Users Score":0,"Answer":"First, you need to cd to your python project and then activate your virtual environment and run\npip install twitter","Q_Score":1,"Tags":"python,python-3.x,twitter,module","A_Id":63699273,"CreationDate":"2020-09-02T05:08:00.000","Title":"I have python 3.7.3 in my old laptop, I installed python 3.8 on my new laptop and it's not working anymore","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried to print the \"Hello World\" in VSCode Terminal and received this message\n\"The term 'python' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included,\nverify that the path is correct and try again. \"\nI've already installed python interpreter, adding evironment variables and WHEN I ATTEMPTED TO RUN MY PYTHON FILE VIA THE COMMAND PROMPT it printed without any problem (including printing lists or performing functions).\nI've also checked python in the command and it replies version 3.8.5, however PowerShell keeps denying and appear the \"not recognized\" issue, no matter restarting the computer.\nCan anyone help me with this problem?\nP\/s: not only Python files, but my cpp files with C++ programming also have similar problems. I've installed MinGW and the program still can't run.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":954,"Q_Id":63703848,"Users Score":0,"Answer":"From your description, do you mean the python command can be recognized in cmd both in VSCode and out of VSCode and can not be recognized in the PowerShell both in VSCode and out of VSCode?\nIf it's right, can you do these actions out of VSCode?\nStep1: Open cmd type in 'where python' to find out the location of python which you are using as you described you can run python in cmd.\nStep2: Open PowerShell type in 'get-command python' to check whether can you find python in PowerShell. And as you described, you should not get the location of the python command.\nStep3: Then copy the path you get in step1 and enter into it in PowerShell, then type 'python' to check what will you get.\nStep4: In Step3 you should get the python command work. And this means python was installed correctly, but your PowerShell can not find it. This is because your system environment path was changed temporarily in your PowerShell.\nStep5: Enter into this location: C:\\Users{UserName}\\Documents\\WindowsPowerShell, you can find 'profile.ps1' and 'Microsoft.PowerShell_profile.ps1'. Clear them.","Q_Score":0,"Tags":"python,c++,visual-studio-code","A_Id":63734189,"CreationDate":"2020-09-02T10:41:00.000","Title":"My VSCode is unable to run py file with the 'not recognized as the name of a cmdlet' problem","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm implementing get text on my Discord bot and I have a few strings that come from configuration files for example: Regions where the game is from (Global server, Korean server, Japanese server, Asia server, etc.) that I want to also be translated into. Since these files are stored as JSON, I can't really use get text on them.\nSo I was wondering what can I do to get these strings translated? I came up with a few approaches that would solve my problem but they don't look that nice to me.\nMethod 1 - Use .py files for these settings\nThis one is self explanatory. I can use python modules to store the configuration for that, which would allow me to use the _(...) get text function which would allow xgettext to pick up the strings to be translated.\nMethod 2 - Hard code the strings\nThis would come in two ways, hardcoding them inside the module they're going to be used on or in a module where I would hard code all the strings that come from external data sources.\nIs there any better approach to tackle this?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":40,"Q_Id":63713616,"Users Score":1,"Answer":"Extract the strings from the configuration files into an additional .pot file like config.pot. You can then pass this file as an additional input file to xgettext because xgettext will always recognize .po or .pot files as input regardless of the programming language.","Q_Score":0,"Tags":"python-3.x,translation,external,gettext,xgettext","A_Id":63914412,"CreationDate":"2020-09-02T21:12:00.000","Title":"Translating strings that are outside of the range of gettext","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Lately, I got this warning:\n\nCryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in a future release.\n\nShould I upgrade Gspread or Python ? Cause all code are in Python 2, it is hard to move to python 3.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2974,"Q_Id":63716878,"Users Score":0,"Answer":"pip install cryptography==2.2.2\nWorks fine with out warnings","Q_Score":2,"Tags":"python","A_Id":71317457,"CreationDate":"2020-09-03T04:31:00.000","Title":"CryptographyDeprecationWarning with python 2","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can you please tell me how can I integrate the python automation in my flutter app. Such that suppose I have a text field and I have entered a youtube channel name. Then the app will automatically go to that channel and play the latest video for me as we do in desktops using selenium.\nYes, something like that. Also, I want to perform many such tasks using python automation. Please tell me if you have any reference links or knowledge regarding this.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":238,"Q_Id":63717551,"Users Score":1,"Answer":"Whatever data you have automated in Python, you can expose as an API in Flask, then make HTTP requests to that endpoint from your Flutter app.","Q_Score":0,"Tags":"python,android,flutter,automation","A_Id":63717718,"CreationDate":"2020-09-03T05:44:00.000","Title":"How to use python automation in flutter app?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to make a command that with a parameter of a role that lists everybody who has that role in a discord server. Is there a way to do this?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":83,"Q_Id":63728413,"Users Score":0,"Answer":"If you can get the list of people, you can iterate through the list of players and use playerList[index].roles[index] == \"Some Role\"","Q_Score":2,"Tags":"python,discord,discord.py,discord.py-rewrite","A_Id":63728512,"CreationDate":"2020-09-03T17:01:00.000","Title":"Is there a way to make a command that lists everybody who has a certain role in a discord server?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hello I have a usb webcam and am too broke for the picamera, is there anyway I can write a python program that can record video??","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3689,"Q_Id":63748941,"Users Score":1,"Answer":"A few ideas spring to mind...\n\nIdentify which webcam you have\n\nPlug it in and see if you can see it with:\nsudo lsusb\n\nInstall v4l-utils and see if it is accessible:\nsudo apt-get install v4l-utils\nv4l2-ctl --list-devices\n\nInstall ffmpeg and try using it:\nsudo apt install ffmpeg\nffplay \/dev\/video0\n\n\nIf this works, you can record with ffmpeg or use OpenCV videocapture() to grab and record frames.","Q_Score":0,"Tags":"python,python-3.x,raspberry-pi,camera,picamera","A_Id":63765604,"CreationDate":"2020-09-04T23:09:00.000","Title":"How to take video on a raspberry pi with a usb webcam","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to be able to run python code on each \"node\" of the network so that I can test out the code properly. I can't use different port numbers and run the code since I need to handle various other things which kind of force using unique IP addresses.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":171,"Q_Id":63756753,"Users Score":0,"Answer":"I think vmware or virtual box can help you.","Q_Score":1,"Tags":"python,networking,simulation,p2p","A_Id":63770811,"CreationDate":"2020-09-05T17:33:00.000","Title":"Is there a way to simulate a network so that I can test my p2p network code written in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was building a telegram bot using python. and I was trying to find a method to change the bot about description of the bot from my code!\ncan I do that?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":117,"Q_Id":63758461,"Users Score":0,"Answer":"No, you can do this only using @BotFather.\nBut you can try to use telethon library to programmatically access to it from your personal account.","Q_Score":1,"Tags":"python,telegram,python-telegram-bot","A_Id":63772745,"CreationDate":"2020-09-05T20:59:00.000","Title":"Changing Telegram Bot About Description","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wonder about which algorithm does Python use for estimating square root values ? Is it Newton or Babylonian or other ?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":153,"Q_Id":63759501,"Users Score":1,"Answer":"It depends on the implementation; the language does not define the algorithm. ShadowRanger already hit two common ones. These are general, software-based methods.\nHowever, it's quite common for the processor itself to have a machine-level SQRT function. Intel chips have implemented basic transcendental functions in the late 1980s. As a result, iPython simply in-lines the on-chip function; there is no software algorithm, as the on-chip code determines the value by a couple of hardware operations, deriving mantissa and characteristic in parallel.","Q_Score":2,"Tags":"python,algorithm,sqrt","A_Id":63759883,"CreationDate":"2020-09-05T23:50:00.000","Title":"Which algorithm does Python use for estimating square root value?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I am working on a small project that includes Python and a Firebase realtime database.\nBy now I have everything pretty much finished and the only thing I want to add is that it is hosted by Firebase as well.\nCan one run a python file via the firebase servecommand in order to host my web-app using Firebase?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":313,"Q_Id":63785755,"Users Score":0,"Answer":"The Firebase CLI isn't meant for hosting. You're supposed to deploy your project to have it hosted in the cloud using the URL it provides for you.\nAfter you do that, bear in mind that it will only host static web assets like HTML, CSS, and JS. It will not run python programs. If you want to run code on your backend, you should look into integrating Firebase Hosting with Cloud Functions. You can run python in Cloud Functions.","Q_Score":0,"Tags":"python,firebase,firebase-realtime-database,firebase-hosting,firebase-tools","A_Id":63785889,"CreationDate":"2020-09-08T00:44:00.000","Title":"Run Python script with `firebase serve`","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"In my application I have 4 camera modules (one mic in each) (same vendorid and productid) connected to a Ubuntu linux system.\nI want to connect to all 4 mics and identify which channel correspond with specific camera module which is connected in a particular USB physical path (e.g 2-1.3 -> USB bus 2 - Port 1 - Port 3)\nHow can I (by python code) get the input_device_index for a particular USB device based on his route?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":52,"Q_Id":63792877,"Users Score":0,"Answer":"At least four years ago there there was no way to do that. Not on Linux nor Windows. I could imagine only somehow kick out audio driver and read sound directly from USB endpoints but this is crazy solution...","Q_Score":1,"Tags":"python,usb,pyaudio","A_Id":63846641,"CreationDate":"2020-09-08T11:24:00.000","Title":"How can I open specific device in pyaudio based on USB physical port?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Does the python script have to be named as handler.py in AWS Lambda?\nI can't remember where I read this from, it says lambda is configured to look for a specific file, usually named 'handler.py',just wondering where we can configure this or does it have to be 'handler.py'? Thanks.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":641,"Q_Id":63797601,"Users Score":2,"Answer":"You can name this Python script whatever you want. Be sure to reference it properly.\n\nYou can tell the Lambda runtime which handler method to invoke by setting the handler parameter on your function's configuration.\n\n\nWhen you configure a function in Python, the value of the handler setting is the file name and the name of the handler module, separated by a dot. For example, main.Handler calls the Handler method defined in main.py.","Q_Score":1,"Tags":"python,amazon-web-services,aws-lambda,handler","A_Id":63797939,"CreationDate":"2020-09-08T16:01:00.000","Title":"Does the python script have to be named as handler.py in AWS Lambda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I wrote a python script which is deployed in a EC2 Instance and lets say this EC2 reside in AWS account A1. Now my script from A1 want to access 10 other AWS account.\nAnd remember I don't have any AWS_ACCESS_KEY or SECRET_KEY of any account cause using AWS_ACCESS_KEY or SECRET_KEY is strictly prohibited here.\nI can easily do that if I have access key. But I can't figure it out how can I do that without access key?\nIs there any possible way to do that?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":234,"Q_Id":63810941,"Users Score":2,"Answer":"The EC2 should assume an IAM Role.\nThen log in to all your 10 other accounts and create roles there. These roles should give cross account access to the EC2 instance role. It is also in these roles that you define what permissions the EC2 instance should have.","Q_Score":0,"Tags":"python,python-3.x,amazon-web-services,boto3","A_Id":63811205,"CreationDate":"2020-09-09T11:43:00.000","Title":"Accessing multiple AWS accounts using boto3 without secret key?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to send \"voice\" commands to my home alexa device to do, well, anything that I \"ask\" it to.\nSo I want to interact with my Alexa device via python. I feel like I'm going around in circles trying to get this to work. I got it at one point using \"gTTS\" to convert my text to an audio file and attempt to send that audio file to an alexa endpoint but it also doesn't do anything. I have even created a \"product\" and gotten my product id, client id, secret id, and refresh token and have been attempting to use those.\nIs this possible? I need some hope here. I'm feeling a little down like this isn't possible.\nIf it is possible am I going down the right track?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":823,"Q_Id":63862982,"Users Score":0,"Answer":"Your home device is only meant to take commands via the mic. You could create a DIY hardware or software device that consumes the Alexa Voice Service and feed audio to it.","Q_Score":1,"Tags":"python-3.x,alexa,alexa-skill","A_Id":63868746,"CreationDate":"2020-09-12T17:22:00.000","Title":"How Can I Send \"Voice\" Commands To My Personal Alexa Device Via Python Code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to use discord.py regardless of the events inside my program, and specifically get the user's id by his nickname (they are all on the same server). bot.loop.create_task doesn't work for me, as it needs to start an event loop and my program is not related to event handling.\nI will be glad to any of your help","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":58,"Q_Id":63875058,"Users Score":1,"Answer":"In theory there is no way, because discord.py is asynchronous.\nIn practice...\nyou can try discord.ext.tasks and setup something that looks like a chron task.","Q_Score":1,"Tags":"python-3.x,discord.py","A_Id":63883726,"CreationDate":"2020-09-13T20:04:00.000","Title":"How to use discord.py regardless of events?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So, Currently if suppose I have an article of around 1500 words and I don't wanna use telegra.ph, neither I want to send two messages to send the complete article.\nI want to send the complete article in one message.\nSo for that, Can we group two messages with two different id's and link them through Inline Buttons - Next and Previous.\nThe next button will open the second message, and previous will return to the first.\nIs it possible, How can I do it if it is. And Do anyone has a better idea if it isn't.\nI am creating a group solely for writers. As stories, novels, articles, are some Times quite lengthy I want readers that feasibility to read such long writeups without having to go to Telegra.ph or reading multiple messages. Instead an ebook format for the readers to read the next page or chapter by just clicking the \"Next\" Inline button.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":33,"Q_Id":63876043,"Users Score":0,"Answer":"Yes, you can do this by adding \"Next\" InlineButton.\nRead official documentation for the library you choose and examples there.","Q_Score":0,"Tags":"javascript,python,node.js,telegram-bot","A_Id":63880678,"CreationDate":"2020-09-13T22:08:00.000","Title":"Can we Add an EBook kinda functionality to Telegram bots for viewing lengthy messages?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I started learning python recently and I know my problem may not be sth complicated. I issued below command from my Windows cmd to install pytest framework and its required dependencies\npy -3 -m pip install pytest\nand then issued:\npy -3 -m pip install pytest-pep8\nto install pep8 plug-in and required dependencies. Both commands were done successfully.\nBut when I want to run pytest by py.test --pep8 exp1.py command; I get mentioned error.\nany ideas?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":10909,"Q_Id":63878489,"Users Score":1,"Answer":"i am learning python with head first python book,\ni have been trying to use pytest module but was,\nnot working and even search online everywhere\nbut i could not find the solution the problem but\nsome how, i manage to figure it out.\nso here's the solution\nthe current version of pytest is version 6.2.2 unfortunately if use it with\npy.test --pep8\nit will not work because it has been deprecated the simple solution is to use this\nversion\npip install pytest==2.9.1\nand when it's successfully installed when you tried\nwith the\npy.test --pep8\nit will work.","Q_Score":3,"Tags":"python,pytest,pep8","A_Id":67713338,"CreationDate":"2020-09-14T05:21:00.000","Title":"'py.test' is not recognized as an internal or external command, operable program or batch file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"We have a large project with many proto-files. Many of those contain messages that are no longer used anywhere, and hence I'd like to delete them. However, due to the size of the project, it's non-trivial to see, which of those messages are still necessary and which ones are not.\nMy initial approach was something like comment-out the message and comment back-in until the compiler is happy (Java, C++). Unfortunately, we also have significant amounts of python, where this approach doesn't work and always running all test-cases is too expensive.\nHas anyone faced this kind of situation before? Are there any tools that can help detect unused protobuf-messages across Java, C++ and Python?\nEDIT:\nI should probably add, we currently (still) have all its usages under our control, so nobody outside our project is using them.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":222,"Q_Id":63887684,"Users Score":1,"Answer":"It's an interesting question but I suspect (!?) the challenge for a tool is that it's difficult (impossible?) to determine your protos' downstream dependencies.\nThe protobuf sources are compiled to at least one language's sources and these sources are then imported as dependencies into code. This code is itself (often) compiled and bundled (e.g. as a container image somewhere) and deployed into production.\nAdditionally, protos are often distributed to others (other teams, departments, organizations etc.) by way of defining software interfaces and each of these entities creates the same downstream digital chain.\nRather than \"delete\" (erase), you may wish to have a formal archival process either in-place by commenting out messages or moving protos to an archival directory.\nEither of these approaches should permit you to detect future compilation errors and recover the messages if necessary.\nIt may be prudent to ensure that, when messages become redundant, the process includes the above archival mechanism as the formal archival mechanism rather than as a periodic \"Let's go looking for redudnancies\".","Q_Score":0,"Tags":"refactoring,protocol-buffers,protobuf-java,protobuf-c,protobuf-python","A_Id":63891942,"CreationDate":"2020-09-14T15:48:00.000","Title":"Find unused protobuf messages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm just wondering if anybody knows how I should approach the problem of automating extracting attachments from emails, putting the attachment through an excel macro, and then sending an email out! I have experience working with Python and R for data science but don't have much straight coding experience. Anybody got any resources I could read up on\/scripts that exist on GitHub for something similar?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":88,"Q_Id":63930958,"Users Score":0,"Answer":"well you can use beautiful soup to automatically scrape csv\/xlsx files from your email and use pandas to extract needed data and then use smptlib to send emails out.","Q_Score":0,"Tags":"python,automation,scripting,extract","A_Id":63931112,"CreationDate":"2020-09-17T03:44:00.000","Title":"How to automate extracting attachments from email","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created five functions in AWS which are being triggered by an ALB.\nThe lambdas are written in Python and I need to create a single swagger doc for them.\nI considered using flask_swagger_ui but the only way I found to make it work is to use a single lambda (instead of five) and let flask do the routing inside that lambda (A solution which is not good for me)\nAny ideas on how this can be achieved?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":93,"Q_Id":63932522,"Users Score":0,"Answer":"You can create an additional Lambda, which is just for documentation purpose.\nThe functions in that Lambda are just annotated placeholders, and the ALB listener routes only the documentation path requests to this lambda, and the other requests to the \"real\" Lambdas.","Q_Score":0,"Tags":"python,flask,aws-lambda,swagger,swagger-ui","A_Id":64739755,"CreationDate":"2020-09-17T06:36:00.000","Title":"Creating a single swagger doc for for multiple python lambdas that are being triggered by ALB","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Curious, if there is way to avoid skipping messages sent from Telegram Bot while web-server that accepts Webhooks is down (because of redeploy, failure or maintenance).\nWhen you use polling - Telegram API sends messages starting from last retrieved and no message are skipped.\nBut how to be with Webhooks? Use polling or there are some special mechanism for that?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":856,"Q_Id":63933435,"Users Score":0,"Answer":"I had the same problem recently but I just resolved it by when the server starts save the started time to a variable and then use Telegrambot.Message.date and compare the time if it was sent before the server start time or not.","Q_Score":0,"Tags":"telegram,telegram-bot,python-telegram-bot,telegram-webhook,node-telegram-bot-api","A_Id":63948225,"CreationDate":"2020-09-17T07:43:00.000","Title":"How to get messages that were not delivered while Telegram Bot web-server was down?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to setup Atom as a Python IDE.\nI have installed atom-ide-ui, and ide-python packages. Python and pyls are installed as well to the latest versions. Nonetheless I am not able to use any of the functions the packages should provide (e.g. autocomplete, highlighting, etc.), they just do not seem to be active.\nI have tried to set the python-ide Python Executable path to the actual install path (C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python38-32\\python), as I though it could be a problem with the defaults. Still nothing.\nI am wondering if I am missing any import step in the setup, or if I am using something wrongly.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":180,"Q_Id":63940568,"Users Score":0,"Answer":"Did you load the language-python extension? Its necessary to run Python. Was your file in color after opening a valid python code?\nYou should also load the extension named Script. Script is required to run your python file. after you start atom, under the Packages menu you'll see the word Script. Click on this and you'll get another pane that says run script. Click on this to run you python code\/","Q_Score":0,"Tags":"python,atom-editor","A_Id":63973995,"CreationDate":"2020-09-17T14:44:00.000","Title":"Can't use any Atom Python IDE functions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to access all modules no matter what my cwd is. Is there any way to access all my modules without adding sys.path or PYTHONPATH=?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":35,"Q_Id":63970819,"Users Score":1,"Answer":"My simplest answer is to create an example.pth inside the lib\/site-packages and add any working directory that you want there.","Q_Score":1,"Tags":"python,visual-studio-code,python-module","A_Id":63970883,"CreationDate":"2020-09-19T16:11:00.000","Title":"Organizing packages for use in vscode?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Running Sublime Text 3 on Ubuntu here, Version 3.2.2 build 3211.\nProblem: When running a script with Python3 or Latex, the process stays in memory after it's finished. I have to kill them manually. I discovered this after my computer froze at least twice, and it was caused by python processes from Sublime eating up all RAM and swap. Also, I had problems with matplotlib complaining that all available resources for new windows were taken.\nExpectation: when a job is finished, the process should be killed, freeing up memory.\nTests: I didn't test with other languages besides Latex or Python. I tried in Sublime build 3210 and 3209, and it had the same behavior. I tried to look for in Sublime forums and here on Stack Overflow, and I couldn't find anything related.\nThanks in advance for any help!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":129,"Q_Id":63985492,"Users Score":0,"Answer":"The problem was a \"-i\" flag in the build configuration for Python3... I copied this config somewhere and forgot to check. Now the processes are correctly closed!\nAbout the Latex one, I will uninstall Latex packages and try to install them again.","Q_Score":0,"Tags":"python,build,sublimetext3","A_Id":64038207,"CreationDate":"2020-09-21T02:34:00.000","Title":"Sublime Text 3 doesn't kill processes when finished","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am experiencing a very strange error when analyzing a Python project in jenkins with sonarscanner.\nIn fact, after a commit where a lot of code lines has been removed, I ran a coverage scan (with python module) and when i tried to pass the report to the sonar-scanner binary plugin on to Jenkins, a java exception appeared, told me that \u00ab\u00a0line XXX is out of range in file YYY\u00a0\u00bb. Where XXX is part of my deleted line, and YYY is one of my source file.\nIs anybody experienced the same behaviour ?\nI already tried to remove .sonar cache in jenkins home and .sonarwork in my jenkins pipeline, but no effect...\nThank you in advance for your help !\nCheers !","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":385,"Q_Id":64014889,"Users Score":0,"Answer":"The issue is with the coverage xml format and latest sonar cli version to analysis the XML for metrics notification. We had two choice:\n1- Add a blankspace. (at the bottom of the coverage.xml file). This worked for an old pytest tests.\n2- In another project, I updated the following packages: pytest, pytest-cov, and coverage, this to the latest version. (Worked like a charm).\nOne catch here: when updating to the latest pytest version you might find methods that no longer exist for conftest.py. Eg: get_marker which can be substituted by the new get_closest_marker. Or reserved words like \"request\". For the latest case you can rename the method named request.","Q_Score":0,"Tags":"python,jenkins,sonarqube,jenkins-pipeline,sonarqube-scan","A_Id":68505074,"CreationDate":"2020-09-22T17:31:00.000","Title":"Sonarqube + Jenkins : python coverage report => Line out of range after deleting lines in sources","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Can someone please tell how to get a usb device\u2019s parent information in Python?\nI tried WMI, win32com, and pyusb without any lucks.\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":121,"Q_Id":64016792,"Users Score":0,"Answer":"The usb device has a child device com-port. I can find the child device info using serial.tools.list_ports.comports(). From the tool usbtreeview.exe, I can see the child device has a parent with class type usb. How do I retrieve the parent\u2019s info using Python?","Q_Score":0,"Tags":"python","A_Id":64016978,"CreationDate":"2020-09-22T19:51:00.000","Title":"How to get parent usb device info using Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python script that plays a video on system boot. The video has audio but when the system starts and the video plays, no audio can be heard. I have set the mute function to False and volume to 100% but nothing plays. However, if I play the video from desktop via the standard vlc application, there is audio. Then, if i run the script again and the video plays automatically from the python script, there is audio. Whats the problem here?\nUPDATE: I realized i didnt have alsa-base and pulseaudio installed on my pi. After installing them, both methods did not give audio.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":199,"Q_Id":64020825,"Users Score":0,"Answer":"Create or edit the file \/etc\/asound.conf\nFor headphone output:\npcm.!default {\ntype hw\ncard 0\n}\nctl.!default {\ntype hw\ncard 0\n}\nFor HDMI output:\npcm.!default {\ntype hw\ncard 1\n}\nctl.!default {\ntype hw\ncard 1\n}","Q_Score":0,"Tags":"python,raspbian,vlc","A_Id":68500921,"CreationDate":"2020-09-23T03:57:00.000","Title":"raspberry pi vlc-python no sound","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My client is based on angular and electron, the server is written in python language.\nI am able to send json-rpc requests between python-python and angular-angular.\nI want to send a json object to client using json-rpc websocket from python to angular.\nI am a noob so not really sure if it is possible or if there's a library available as I cannot find anything cross platform. Any help will be appreciated :)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":131,"Q_Id":64030846,"Users Score":0,"Answer":"It is possible, there seems only python 3.x rpc websocket support.\nLook for 'jsonrpcclient[websockets]'. There is a server available too.\nOn angular side, I can only suggest 'rpc-websockets'","Q_Score":0,"Tags":"python,angular,websocket,electron,json-rpc","A_Id":65813605,"CreationDate":"2020-09-23T15:03:00.000","Title":"Is it possible to receive rpc-websocket json request in angular from python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a project using social media data. An important part of it is to understand the spatial distribution of the social data, like tweets. I used the getoldtweet3 to scrape tweets but all of them are devioded of geo data. Just wonder if there a way to get the spatial features of tweets; or there are other tools to scrape other social media data with geospatial feature.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":37,"Q_Id":64037027,"Users Score":0,"Answer":"First of all, the library you are using is not accessing the Twitter API, you probably know this already. It\u2019s not official and it could stop working at any moment.\nSecondly and more importantly for your question, there is only about a 1% use of geo pinning in the API. There\u2019s no special way to go around this, it is up to a user to enable geo on their Tweets.\nDoes this answer your question?","Q_Score":0,"Tags":"python,web-scraping,twitter,geospatial","A_Id":64038568,"CreationDate":"2020-09-23T22:18:00.000","Title":"Is there a way to get the geospatail data of tweets?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created a Twitter App in order to control a specified account (post tweet, etc).\nI created this app with my personal account so I can only post tweets on my personal account.\nI'd like to share permissions with my other account so I can tweet on it.\nI heard about OAuth but I don't understand how to use it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":57,"Q_Id":64043496,"Users Score":0,"Answer":"You can use twurl to authenticate to another account. The account token and secret will be stored in the .twurlrc file in your home directory, you can use those to post from another account.","Q_Score":0,"Tags":"twitter,twitter-oauth,tweepy,twitterapi-python","A_Id":64045025,"CreationDate":"2020-09-24T09:27:00.000","Title":"How to Access Twitter App with another account?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed python via anaconda on an EC2 Ubuntu Instance.\nThe command which python returns *\/home\/ubuntu\/anaconda3\/bin\/python*\nJenkins is instead installed in *\/var\/lib\/jenkins*\nI am trying to run a simple \"Hello World\" script saved on a file named *test.py* and located within the *\/home\/ubuntu\/scripts\/* folder.\nWhile running *python \/home\/ubuntu\/scripts\/test.py* works on terminal, it fails as an \"Execute shell\" build step in Jenkins.\nWhy and how do I configure Jenkins to run python scripts step by step?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":249,"Q_Id":64046579,"Users Score":0,"Answer":"The issue was that the anaconda python installation was only available to the user \"ubuntu\". For Jenkins to be able to run python scripts, the \"jenkins\" user needs to use that installation.\nTo solve the problem, this is what I did:\n\nLogged in as jenkins with the command sudo su -s \/bin\/bash jenkins\nEdited the python install location as export PATH=\/home\/ubuntu\/anaconda3\/bin:$PATH\nChecked that the path is correct through which python\nLogged back as ubuntu user\nRestarted Jenkins through sudo service jenkins restart (not sure if necessary)\n\nNow I can run python scripts through Jenkins.","Q_Score":0,"Tags":"python,jenkins,amazon-ec2,anaconda","A_Id":64061420,"CreationDate":"2020-09-24T12:36:00.000","Title":"How to configure Jenkins to run Python scripts?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"qs\nwhen run locust --master and client locust --master-host,\nlocust can not run api stress,why?\nenv\nserver: locust -f locustfile.py --master (centos)\nclient: locust -f locustfile.py --worker --master-host 10.200.6.1 (mac)\nstatus\nvisit webUI,worker show 1 worker,but start test,\nit will stop immediately after three seconds,\nrps and result still show None.\ncmd log\nerror log : lewis-test\/INFO\/locust.main: Starting Locust 1.2.3\npasslog :\nlewis-test\/INFO\/locust.main: Starting Locust 1.2.3\nlewis-test\/INFO\/locust.runners: Spawning 100\nusers at the rate 100 users\/s (0 users already running)...\nlewis-test\/INFO\/locust.runners: All users spawned: MyUser: 100 (0 already running","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":80,"Q_Id":64074975,"Users Score":0,"Answer":"it work\ndiferent locust version,ths","Q_Score":0,"Tags":"python,centos,locust","A_Id":64075278,"CreationDate":"2020-09-26T07:22:00.000","Title":"when run locust --master and client locust --master-host,locust can not run api stress,why?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know that first line of python file always give the info of encoding.\nBut I don't know even than the first line words are encoded with specific encoding, how does editor know the correct encoding of the first line words.\nthanks for you reply","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":309,"Q_Id":64086854,"Users Score":1,"Answer":"Each editor has it's own built-in algorithms that depend on the byte code and sometimes file extensions to determine the encoding. For most file extensions, if the editor is not able to determine the encoding, it falls back to a common encoding, which is usually UTF-8 for text files and such since it supports a larger set of signs and is widely used.\nTake for example, Python itself. During the era of Python 2, the default\/fallback encoding for source code was ASCII. So your first few lines where you mention your encoding should be valid ASCII for Python2 to process it. In Python 3, this has been switched to UTF-8. So, the python interpreter will interpret the first few lines as valid UTF-8 and then override it with whatever custom encoding that you provide.","Q_Score":1,"Tags":"python","A_Id":64669082,"CreationDate":"2020-09-27T09:21:00.000","Title":"how does editor know python file's encoding?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know that first line of python file always give the info of encoding.\nBut I don't know even than the first line words are encoded with specific encoding, how does editor know the correct encoding of the first line words.\nthanks for you reply","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":309,"Q_Id":64086854,"Users Score":0,"Answer":"I don't believe there is any full-proof way of knowing a file's encoding other than guessing an encoding and then trying to decode with it.\nThe editor might assume, for example, a UTF-8 encoding, a very common encoding capable of encoding any Unicode character. If the file decodes without errors there is nothing else to do. Otherwise, I am sure the editor has a strategy of trying certain other encodings until it succeeds and produces something without a decoding error or finally gives up. In the case of an editor that understands content, even if the file decodes without an error, the editor might additionally check to see if the content is representative of what is implied by the file type.","Q_Score":1,"Tags":"python","A_Id":64669546,"CreationDate":"2020-09-27T09:21:00.000","Title":"how does editor know python file's encoding?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"The Python Virtual Machine is different for different Operating Systems, but the bytecode is portable. I mean, why was the bytecode designed in the first place? Wouldn't Python be much faster if its code ran directly on a native machine?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":39,"Q_Id":64093321,"Users Score":1,"Answer":"Yes it would be faster, but as you've mentioned, bytecode is used for portability. Anything which can run the virtual machine can run a Python program, without needed to recompile the code","Q_Score":0,"Tags":"python,operating-system,pvm","A_Id":64093344,"CreationDate":"2020-09-27T21:04:00.000","Title":"Wouldn't Python be much faster if its code ran directly on a native machine?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I build this chat website, and I'd like to test this functionnality:\n\nif you send a message and the user is online, send message via websocket: Tested\nif you send a message and the user is offline, send a push notification (it's a REST call).\n\nObviously, in my test, I don't want to do the REST call. I'd like to mock the function \"push_notif\".\nBut, when I use unittest.patch, the function is not mocked in the consumer (probably because of some async stuff). How can I mock this \"push_notif\" function","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":100,"Q_Id":64107071,"Users Score":0,"Answer":"Out of solution, I made a decorator for my function \"push_notif\". If in test, it writes in a file \"func.__name__,args,kwargs\", then I read this file in my test to see if the right call was passed.\nUgly, but getting things done","Q_Score":0,"Tags":"django-channels,python-mock,django-unittest","A_Id":64110376,"CreationDate":"2020-09-28T17:43:00.000","Title":"Django-channels, how to use mocks","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a sh file that runs: python -m grafana_backup.cli save --config $settings_file.\nI run this file from a crontab, runnning the .sh file but I get this error: python: command not found.\nThe shell in the crontab is SHELL=\/bin\/bash and in the .sh file is #!\/bin\/bash","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":436,"Q_Id":64118478,"Users Score":1,"Answer":"do:\n\n'which python3' - a possible result is \/usr\/bin\/python3\nAdd the result of #1 to the crontab command\n\nA general advice:\nUse full path to every resource your sh script is using","Q_Score":1,"Tags":"python,shell,cron,grafana","A_Id":64118531,"CreationDate":"2020-09-29T11:15:00.000","Title":"Command not found in sh script running from crontab","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Every time when I try to run a file in the JupiterLab console I get the following message:\nERROR:root:File 'thing.py' not found.\nIn this case, my file is called thing.py and I try to run it with the trivial run thing.py command in the console. The code is running and it gives me correct results when executed in the console, but I wanted to have it saved, so I put it in a JupiterLab text file and changed the extension to .py instead of .txt. But I get the aforementioned message regardless of which file I try to run. I am new to JupiterLab and admit that I might have missed something important. Every help is much appreciated.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":748,"Q_Id":64118493,"Users Score":-1,"Answer":"You might want to understand exactly what a Jupyter Lab file is, and what a Jupyter Lab file is not. The Jupyter Notebooks have the extension, .ipynb.\nSo anyway, the Jupyter Notebooks are not saved or formatted with python extensions. There are no Jupyter Notebooks or Jupyter Labs ending with the .py extension. That means Jupyter will not recognize an extension having .py, or .txt or .R or etc.... Jupyter opens, reads, and saves files having the .ipynb extension.\nJupyter Notebooks are an open document format based on JSON.\nJupyter can export in a number of different formats. Under the File tab, is the Export feature. The last time I looked there were about 20 different export formats. But there isn't a python or .py export format. A Jupyter file can also be Downloaded. Also under the File tab is the Download feature. This will download a standard text formatted JSON file. JSON files are mostly unreadable unless you've spent years coding JSON.\nSo there's not much purpose in downloading the Jupyter file unless you are working on a remote server and cannot save your work at that site. And it makes much more sense to save and copy the Jupyter file in its native Jupyter format - that means having the extension, .ipynb . Then just open and use that file on another PC.\nHopefully this should clarify why Jupyter won't open any .py or .txt files.","Q_Score":0,"Tags":"python,jupyter,jupyter-lab","A_Id":64131515,"CreationDate":"2020-09-29T11:16:00.000","Title":"File not found when running a file in JupiterLab console","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have been using the nptdms module to do analysis of TDMS files without issue for several years. Recently, I got an error when trying to read a TDMS file for the first time. I import TdmsFile from nptdms:\nfrom nptdms import TdmsFile\nI try to read it:\ntdms_file = TdmsFile.read(path_to_my_tdms_file)\nand then get the following error:\ntype object 'TdmsFile' has no attribute 'read'\nI am using python v3.6.10, with Anaconda and the nptdms v0.12.0.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":768,"Q_Id":64124094,"Users Score":0,"Answer":"Yes, this issue is recent and real. A re-install of nptdms via pip does appear to solve it. (even though pip claimed it was up to date as of version 0.17.1)","Q_Score":0,"Tags":"python,python-3.x,anaconda,labview","A_Id":64420387,"CreationDate":"2020-09-29T16:46:00.000","Title":"Unable to apply method \"read\" to TdmsFile from nptdms","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to trigger the lambda function only for INSERT event in dynamodb stream?\nTo reduce the cost of the lambda function, is it possible to trigger the lambda function based on the type of operation\n\nINSERT - insert_lambda_function\nMODIFY - update_lambda_function\nREMOVE - delete_lambda_function","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":427,"Q_Id":64160055,"Users Score":2,"Answer":"No, this is not currently possible.","Q_Score":2,"Tags":"python,amazon-web-services,aws-lambda,amazon-dynamodb-streams","A_Id":64160180,"CreationDate":"2020-10-01T17:00:00.000","Title":"How to trigger the lambda function only for INSERT event in dynamodb stream?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Using python telegram-upload API I was able to upload the file to telegram cloud and also I stored the corresponding file_id of that file. Now this API provides telegram-download method which downloads all files from my telegram cloud, My question is how can I download some selected files only with help of file_id that I am storing. Is it possible using some other method?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":226,"Q_Id":64184585,"Users Score":0,"Answer":"You can download a file first then you send it using your code. I recommend to use telethon library to upload file faster.\nAlso you can use transload links to upload without downloading which uploads a file faster.","Q_Score":0,"Tags":"python,telegram,telegram-upload","A_Id":64427432,"CreationDate":"2020-10-03T13:01:00.000","Title":"Download selected file from telegram?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I can run pianobar from command by typing pianobar and it loads the config file just fine. I want to run it from a python script or shell script and it runs but it does not load the config file. Pianobar is a PATH that you can run from any directory and I don't know where the app is installed. I'm working on a GUI for Raspberry pi.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":67,"Q_Id":64186813,"Users Score":0,"Answer":"I found the answer, to run it from a shell do: sudo -u pi pianobar","Q_Score":0,"Tags":"python,shell","A_Id":64189988,"CreationDate":"2020-10-03T17:02:00.000","Title":"How do I run pianobar (pandora) from a shell script with config access","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to run vulnerability testing for a class and the first line of code in the script is:\nfrom metasploit.msfrpc import MsfRpcClient\nHowever, when I try to run the program, I get \"ModuleNotFoundError: No Module named 'metasploit'\"\nI am running on Kali Linux; metasploit comes standard, but either I am doing something wrong or am missing a module. Has anyone run into this and can maybe suggest a resolution?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":513,"Q_Id":64188755,"Users Score":0,"Answer":"first,\npip3 install --user pymetasploit3\n$ msfrpcd -P yourpassword -S\nand then in python,\nfrom pymetasploit3.msfrpc import MsfRpcClient\nIt can work. Good luck.","Q_Score":0,"Tags":"python,metasploit","A_Id":64196219,"CreationDate":"2020-10-03T20:36:00.000","Title":"Executing a Python Script with Metasploit","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a python module that I import into a jupyter notebook for general usage. I have a number of jit functions in the module, circa 20. The module can take up to a minute to import, but if I comment out the @njit decorators, the module will import instantaneously. I was wondering if any python wizzes know what's going on here under the hood at import. Is there any way I can bring down this agonizingly long import time?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":117,"Q_Id":64212553,"Users Score":0,"Answer":"So I figured out that removing the signatures of my functions sped up the import time significantly. However, the first executions of the functions were significantly slower. If the functions have signatures, then the functions are compiled at import, this is due to the input and return types being known. If there are no signatures, then the functions are compiled at execution, as it is only at this point where the compiler knows the input and return types.","Q_Score":0,"Tags":"python,numba","A_Id":64677776,"CreationDate":"2020-10-05T16:24:00.000","Title":"Why does my module with jit functions take so long to import?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I tried to use the command python -m twine upload --repository testpypi dist\/* and after I press enter, it appears a prompt asking for my username, I tried entering my test pypi username, __ token __, or the name of my token, but non of them works. If I enter anything, press enter, it will just go onto the next line and never does anything.\nAm I missing any steps? Or what am I doing wrong? I am following the Pypi docs btw","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":110,"Q_Id":64217785,"Users Score":0,"Answer":"Ok so I solved the problem by switching to a different terminal. Thanks!","Q_Score":0,"Tags":"python,module,pypi,twine","A_Id":64218210,"CreationDate":"2020-10-06T00:27:00.000","Title":"I'm not really sure how to use Twine to upload my project to testpypi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I bumped into the following bug. When not all files are utf-8 encodable, tests fail on poetry run pytest -v.\n\n============================================================== ERRORS ===============================================================\n____________________________________________ ERROR collecting tests\/anonymized\/test.txt\n_____________________________________________ .venv\/lib\/python3.8\/site-packages\/py\/_path\/common.py:171: in read_text\nreturn f.read() ..\/..\/..\/.pyenv\/versions\/3.8.2\/lib\/python3.8\/codecs.py:322: in decode\n(result, consumed) = self._buffer_decode(data, self.errors, final) E UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf8 in\nposition 380: invalid start byte\n====================================================== short test summary info ======================================================\nERROR tests\/anonymized\/test.txt - UnicodeDecodeError: 'utf-8' codec\ncan't decode byte 0xf8 in position 380: invalid start byte\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error\nduring collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\nIn the meantime, exactly the same setup worked with Python 3.7, and if I run tests with poetry run pytest tests\/my_tests.py.\nI am using: Python 3.8.2, poetry 1.0.5\nHow can I fix it? This bug is annoying as it fails in CI.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":300,"Q_Id":64246724,"Users Score":1,"Answer":"As it came out, the issue was not related to any version of poetry or python. I named the file test.txt and put it under the tests\/ folder. By default, pytest finds all files prefixed with test and verifies their encoding. As the test.txt was in iso-8859-1, I got a UTF-8 related issue.\nNOTE:\nMake sure that you don't name files with the test prefix when using pytest. Beware that if you decide to name them with the prefix, they should be UTF-8 encoded.","Q_Score":2,"Tags":"python,utf-8,python-3.8","A_Id":64371399,"CreationDate":"2020-10-07T14:55:00.000","Title":"How to skip Python 3.8.2 test of files encoding?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I made changes to my program and now, when I press to deploy, the app gets stuck. It says build is in progress although after 20 min not a single line has been written in the log. I tried deleting my app and creating a new one, with the same repository from github, and it still gets stuck. Anyone can help pls?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":64252824,"Users Score":0,"Answer":"Ok so basically, I let the build run for a bit more before deleting the app, and it got a timeout error. Then I deployed it again and it worked.","Q_Score":0,"Tags":"python,heroku","A_Id":64253156,"CreationDate":"2020-10-07T21:51:00.000","Title":"Build from github on Heroku is stuck, no lines are being written","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want the bot to send an inline button of \"sendPicture\" and after clicking it the user can able to click picture from the camera and send it. In this process users not able to send the picture from their gallery. Is telethon support it or is there any other methods to implement this scenario?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":188,"Q_Id":64256962,"Users Score":2,"Answer":"No. You can just send them text asking nicely.","Q_Score":2,"Tags":"python,telethon,telegram-api","A_Id":64257102,"CreationDate":"2020-10-08T06:32:00.000","Title":"Can Telegram Bot ask user to take picture from camera?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My pytest installation with ubuntu is not running with python3 instead it uses python 2.7\nHow am able to switch to python3 when running pytest?\npython3 -m pytest . is working, but it is not an option, because the program, that runs my tests uses pytest ...","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":84,"Q_Id":64260940,"Users Score":1,"Answer":"I used pytest-3 to solve this problem.","Q_Score":0,"Tags":"python-3.x,pytest","A_Id":64687533,"CreationDate":"2020-10-08T10:48:00.000","Title":"Pytest does not run with python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've recently joined a research group and I'm trying to figure out how to program in Python to set up an ADwin Gold II to speed up data gathering and processing the results. I'm very rusty with coding haven't done any in a year or so, and finding the docs on ADwin very hard to follow.\nIf anybody could explain how to used the python ADwin commands from the official python addon, or show me to any material that may be useful. This would be enormously appreciated.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":39,"Q_Id":64277402,"Users Score":0,"Answer":"Its very hard to find, but on the installation folder, in the software folder, you can find a python Manual. There was no mention of this anywhere in the manual I stumbled across it by pure chance.\nAny other poor soul out there, may this be an aid in your suffering.","Q_Score":0,"Tags":"python","A_Id":64283005,"CreationDate":"2020-10-09T09:34:00.000","Title":"Using Python to set up ADwin Gold 2 for experimental data gathering and processing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a web server which I have developed an application on using php and SQL, mainly picked php as I am more comfortable with it.\nIn short the application automates some of our network tasks .\nAs part of this I have automated some solarwinds tasks and the library orionsdk doesnt have a php library so I have used python.\nIt's all working fine but I really need to run these python scripts from my browser .\nI have considered using php shell exec and got my python scripts to accept args so I can run them and parse the output.\nI know I could also use flask or django but worry I will have a flask app to maintain aswell as a php app.\nI think the question is what the best way to achieve this or any way which I haven't mentioned .\nAny help would be very much appreciated","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":26,"Q_Id":64298228,"Users Score":0,"Answer":"So you want PHP to communicate with Python and you've already mentioned using shell commands and http traffic.\nI can imagine you could also achieve something similar by connecting up both PHP and Python up to the same database. In that case PHP could write a record in a table and Python could pick that up and do something with the data in there. Python could be either be a long-running process or fired off by a cronjob in this case. If a database seems overkill you could also write a file to some place on disk, which Python can pick up.\nPersonally I'd go for the shell exec approach if you want to keep it light weight and for a API connection if you want to have a more robust solution which needs to be expanded later on.","Q_Score":0,"Tags":"python,php,html","A_Id":64298521,"CreationDate":"2020-10-10T20:58:00.000","Title":"Best way to run python script alongside php and html","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am currently working on a personal project, where I have to deal with some chemical formulas;\nI have a form with JavaScript where I enter these formulas; The formulas are entered in a LaTeX-like style for super- en subscript.\nAn example formula can be found below:\nFe^{3+}\nWhen I use JavaScript to read the form and console.log(); the formula is working as expected.\nHowever if I send the formula to the back-end (Python with CGI), the + character seems to have disappeared and been replaced with a space.\nI thought it had something to do with escaping the character, since parts of the formula look a lot like regex's, but after looking around, I couldn't find anything that would suggest that I had to escape the + character.\nAnd now I have absolutely no idea how to resolve this... I could use a different character and replace it on the back-end but that seems like it is not the optimal solution...","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":21,"Q_Id":64302676,"Users Score":0,"Answer":"Most important question: How did you invoke the CGI script?\nWith HTTP GET or HTTP POST?\nIf you're using HTTP POST and the data was being transferred in the HTTP Data portion, then you don't need to escape the \"+\" sign.\nBut if you're using HTTP GET, then the \"+\" sign will first be translated according to URL encoding standard (thus, \"+\" becomes a space), before transferred to the CGI script.\nSo in the latter scenario, you need to escape the \"+\" sign (and other 'special' characters such as \"%\" and \"?\").","Q_Score":0,"Tags":"javascript,python,json,escaping,cgi","A_Id":64302854,"CreationDate":"2020-10-11T09:50:00.000","Title":"JSON not transferring \"+\" character to CGI script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is meant by a partially-initialized module and fully-initialized module? I searched for it on Google but couldn't find anything related to it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":102,"Q_Id":64311857,"Users Score":0,"Answer":"It's exactly what it says in plain English: the module's initialization is incomplete. This is in reference to an error message, typically for a missing symbol definition.\nThe reason behind this is that you imported a file, which starts the initialization process. During this process, a required symbol proved to be undefined, almost always due to an unintended circular reference.\nA simple search for +partially defined Python module will bring you plenty of use cases. I hope the above explanation bridges your gap in understanding the issue.","Q_Score":0,"Tags":"python,module","A_Id":64311966,"CreationDate":"2020-10-12T04:51:00.000","Title":"What is meant by a partially-initialized module and fully-initialized module?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My goal is to develop an application that can check my AWS S3 bucket for five files and once achieved, kick off the Lambda function that loads these files into my database. Loading files from an S3 event is working well. The issue I face is that, even when you upload all files at the same time, each file generates a single event. My loading function gets kicked off five separate times.\nI have some ideas on how to solve this issue. One approach is to consolidate the event notifications into one event. Is this possible? This approach would work because then I could have the process break if the client only uploads 4 files (and subsequently send an email saying to upload 5 files). Otherwise, in the event of 5 files, I can then kick off the Lambda to process everything in the bucket (if # objects in bucket = 5, of course! Which can be checked very easily.) This way, the Lambda function only runs one time.\nIn summary, I want the event notifications to be consolidated so I can run the Lambda function once instead of five times. Please advise if this is possible, and through which channel of AWS product I can find my solution in. Thank you.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":66,"Q_Id":64321992,"Users Score":2,"Answer":"There is no such concept as \"event consolidation\".\nYou will need to:\n\nTrigger an AWS Lambda function on every upload\nThat Lambda function should first check that all 5 files have been upload\nIf so, it can process the files. If not, it should exit.\n\nThe hard part is sending a notification if they \"only upload 4 files\", because this would require waiting sufficient time to allow them to upload the remaining file(s) before sending a notification. This would suggest using an AWS Step Function with a Wait so that it can check the files after a given period. The Step Function could be triggered on the first file upload (that is, when the above Lambda function sees only one file).","Q_Score":1,"Tags":"python,amazon-web-services,amazon-s3,amazon-ec2,aws-lambda","A_Id":64325454,"CreationDate":"2020-10-12T16:48:00.000","Title":"AWS S3 Notification Consolidation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I was wondering if there was anyway to check how many times admin is used within a certain time period and modify roles based off that. For example if someone started kicking loads of people within a short time span it removes their roles to do that?\nAny help is appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":649,"Q_Id":64324907,"Users Score":0,"Answer":"Setup up your bot to record to a file each time an admin command like kick was used (and the time alongside it) and increase a counter by 1, when the counter reaches a certain threshold you read the file and minus the old time from the most recent which gives you your time range. Use this to decide wherever to kick the user.\nThen you can decide. You can also reset the counter every X minutes to ensure they bot doesn't get out of control","Q_Score":0,"Tags":"python,discord,discord.py","A_Id":64324971,"CreationDate":"2020-10-12T20:25:00.000","Title":"Discord.py auto moderation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to get the environment name (dev\/qa\/prod) where my AWS Lambda function is running or being executed programatically. I don't want to give as part of my environment variables.\nHow do we do that?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":555,"Q_Id":64336337,"Users Score":0,"Answer":"Your lambda function can do one of the following :\n\ndef handler_name(event, context): - read the data from the event dict. The caller will have to add this argument (since I dont know what is the lambda trigger I cant tell if it is a good solution)\nRead the data from S3 (or other storage like DB)\nRead the data from AWS Systems Manager Parameter Store\n\n\nI don't want to give as part of my environment variables\n\nWhy?","Q_Score":0,"Tags":"python,python-3.x,amazon-web-services,aws-lambda,development-environment","A_Id":64336484,"CreationDate":"2020-10-13T13:40:00.000","Title":"Get environment name in AWS Lambda function in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So the thing is I have a github repo for my discord bot, and every time a message is sent in the server, the json file along that code is supposed to be updated, but it does not get updated after every refresh... Now is it due to the traffic of the github databases, or does the json file get updated only on the server of the bot(in my case, its heroku) and not in the github?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":222,"Q_Id":64351250,"Users Score":0,"Answer":"The file that's on your Heroku server is independent of GitHub. Even if your Heroku instance is a Git repository, that Git repository is independent of the one on GitHub. In order to get the JSON file from the repository on Heroku to GitHub, you'd have to add and commit the file, make sure that GitHub was added as a remote, and then push, using a suitable set of credentials.\nHowever, having said that, you probably don't want to do that. Data files, like your JSON file, don't belong in repositories. Code repositories are best suited to storing your code and the data it operates on should be stored elsewhere, such as in a database or in a set of files.","Q_Score":0,"Tags":"python,json,github,heroku,discord","A_Id":64363666,"CreationDate":"2020-10-14T10:20:00.000","Title":"Does the json file in a github repository require time to be updated?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I cannot get_dialogs with Telethon Bot since the method is only available for a client. Therefore when I try to access the entity with its id I receive an error. How do I access an entity(channel) if I cannot parse all channels and neither access them by id? I would like to parse messages from a private group and use Telegram Bot for it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1135,"Q_Id":64397819,"Users Score":0,"Answer":"Adding the bot to the channel while it's running should be enough for the bot to obtain its access hash. Alternatively, sending a message there while the bot is inside should also work. This hash will be saved to the .session file. Regardless, if you use the \"marked\" ID (for channels, prefix -100 to the real ID or use types.PeerChannel(real id)), Telethon will know you mean a channel, which can help make it work.","Q_Score":2,"Tags":"python,telegram-bot,telethon","A_Id":64400566,"CreationDate":"2020-10-16T23:58:00.000","Title":"How to get entity of a channel using Telethon bot API?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently creating a model in pyomo and using cplex as a solver(persistant cplex) to be specific which uses the python API.\nI tried running this on my local windows machine and after installing setup.py it work. However, when i switch to run this on my linux server, I keep getting the error \"Module cplex has no attribute CPLEX\". It is also asking to checking if I have gotten my python bindings right.\nCPLEX : v12.10\nPython : v3.6 (64 bit)\nI have tried creating virtual environments and adding the original cplex installation location(\/opt\/...) to my PATH but to no avail.\nLet me know if you need any additioanl information and any help would be apprecaited","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":132,"Q_Id":64406428,"Users Score":0,"Answer":"Windows depends on a package manager that handles programs that end in\n.exe\nAs for open source Linux systems, they depend on Debian's package manager, which means that you cannot run the Windows program on Linux and vice versa, so check with the systems' package manager","Q_Score":0,"Tags":"python,cplex,pyomo","A_Id":64406487,"CreationDate":"2020-10-17T19:20:00.000","Title":"Persistant CPLEX - module cplex has no attribute cplex","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a question; that's as to how to make a discord.py bot send a message by itself upon on_ready(): ?\nIts only in one server and it doesn't matter what channel at the moment, i couldn't find anything in the documentation-\nany help is appreciated ^^!","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":66,"Q_Id":64434044,"Users Score":0,"Answer":"I don't believe the on_ready object has access to send. So I don't think it is possible via the on_ready object. You would have to set it via a different action.","Q_Score":0,"Tags":"python,discord.py,discord.py-rewrite","A_Id":64435136,"CreationDate":"2020-10-19T19:34:00.000","Title":"How to get a bot to send a message automatically?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I made an app that counts active members of my telegram channel using Telethon(telegram api library). my app gets the active rate per hour via api and writes it into a google spreads sheet.\nI had to use 'String session' so I would not have to log in more than once, and keep the app running every day.\nHowever, I'm not really sure when this string session thing expires. The official document does not say anything about it.\nI read on a website 'Treat the session file\/string, your API ID and hash as your password. Anyone got on hold of these 3 will be able to gain full access to your Telegram account until you revoke it.' so If it is until I revoke it, I assume it lasts forever?\nIt would be great if anyone could tell me when it expires.","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":390,"Q_Id":64437962,"Users Score":4,"Answer":"StringSession is just like any other session, it won't expire unless revoke the session.","Q_Score":1,"Tags":"python-3.x,telegram,telethon","A_Id":64438217,"CreationDate":"2020-10-20T03:18:00.000","Title":"When does string session expires?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying build a BOT using put_bot boto3 API operation and processbehaviour is set to BUILD. Lex will build the bot but after 2 or 3 mins it changes its status to NOT_BUILD. When i tried to BUILD the same for second time manually or through calling put_bot api again, then it build successfully. This status change happen intermittently. This happens 1 out of 10 times. Any help in this is highly appreciated.\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":104,"Q_Id":64459384,"Users Score":0,"Answer":"I've seen similar using the Java Lex Model building SDK and in my case it was a result of the build failing.\nHave you looked for errors wtih put_bot ?","Q_Score":0,"Tags":"python,amazon-web-services,api,boto3,amazon-lex","A_Id":64643774,"CreationDate":"2020-10-21T08:13:00.000","Title":"Amazon Lex changing status from Ready to NOT_BUILD after 2 or 3 mins","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a question about manifest.yml files, and the command argument. I am trying to run multiple python scripts, and I was wondering if there was a better way that I can accomplish this?\ncommand: python3 CD_Subject_Area.py python3 CD_SA_URLS.py\nPlease let me know how I could call more than one script at a time. Thanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":830,"Q_Id":64488560,"Users Score":0,"Answer":"To run a couple of short-term (ie. run and eventually exit) commands you would want to use Cloud Foundry tasks. The reason to use tasks over adding a custom command into manifest.yml or a Procfile is because the tasks will only run once.\nIf you add the commands above, as you have them, they may run many times. This is because an application on Cloud Foundry will run and should execute forever. If it exits, the platform considers it to have crashed and will restart it. Thus when your task ends, even if it is successful (i.e. exit 0), the platfrom still thinks it's a crash and will run it again, and again, and again. Until you stop your app.\nWith a task, you'd do the following instead:\n\ncf push your application. This will start and stage the application. You can simply leave the command\/-c argument as empty and do not include a Procfile[1][2]. The push will execute, the buildpack will run and stage your app, and then it will fail to start because there is no command. That is OK.\n\nRun cf stop to put your app into the stopped state. This will tell the platform to stop trying to restart it.\n\nRun cf run-task . For example, cf run-task my-cool-app \"python3 CD_Subject_Area.py\". This will execute the task in it's own container. The task will run to completion. Looking at cf tasks will show you the result. Using cf logs --recent will show you the output.\n\n\nYou can then repeat this to run any number of other tasks commands. You don't need to wait for the original one to run. They will all execute in separate containers so one task is totally separated from another task.\n\n[1] - An alternative is to set the command to sleep 99999 or something like that, don't map a route, and set the health check type to process. The app should then start successfully. You'll still stop it, but this just avoids an unseemly error.\n[2] - If you've already set a command and want to back that out, remove it from your manifest.yml and run cf push -c null, or simply cf delete your app and cf push it again. Otherwise, the command will be retained in Cloud Controller, which isn't what you'd want.","Q_Score":1,"Tags":"python,cloud-foundry","A_Id":64489284,"CreationDate":"2020-10-22T18:39:00.000","Title":"Can I have multiple commands run in a manifest.yml file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"C:\\Users\\xxlda\\AppData\\Local\\Programs\\Python\\Python38-32\\python.exe C:\/Users\/xxlda\/PycharmProjects\/python-telegram-bot\/app.py\nCause exception while getting updates.\nTraceback (most recent call last):\n File \"C:\\Users\\xxlda\\AppData\\Local\\Programs\\Python\\Python38-32\\lib\\site-packages\\aiogram\\dispatcher\\dispatcher.py\", line 359, in start_polling\n updates = await self.bot.get_updates(limit=limit, offset=offset, timeout=timeout)\n File \"C:\\Users\\xxlda\\AppData\\Local\\Programs\\Python\\Python38-32\\lib\\site-packages\\aiogram\\bot\\bot.py\", line 95, in get_updates\n result = await self.request(api.Methods.GET_UPDATES, payload)\n File \"C:\\Users\\xxlda\\AppData\\Local\\Programs\\Python\\Python38-32\\lib\\site-packages\\aiogram\\bot\\base.py\", line 200, in request\n return await api.make_request(self.session, self.__token, method, data, files,\n File \"C:\\Users\\xxlda\\AppData\\Local\\Programs\\Python\\Python38-32\\lib\\site-packages\\aiogram\\bot\\api.py\", line 104, in make_request\n return check_result(method, response.content_type, response.status, await response.text())\n File \"C:\\Users\\xxlda\\AppData\\Local\\Programs\\Python\\Python38-32\\lib\\site-packages\\aiogram\\bot\\api.py\", line 82, in check_result\n exceptions.ConflictError.detect(description)\n File \"C:\\Users\\xxlda\\AppData\\Local\\Programs\\Python\\Python38-32\\lib\\site-packages\\aiogram\\utils\\exceptions.py\", line 137, in detect\n raise err(cls.text or description)\naiogram.utils.exceptions.TerminatedByOtherGetUpdates: Terminated by other getupdates request; make sure that only one bot instance is running\nCause exception while getting updates.\nTraceback (most recent call last):\n File \"C:\\Users\\xxlda\\AppData\\Local\\Programs\\Python\\Python38-32\\lib\\site-packages\\aiogram\\dispatcher\\dispatcher.py\", line 359, in start_polling\n updates = await self.bot.get_updates(limit=limit, offset=offset, timeout=timeout)\n File \"C:\\Users\\xxlda\\AppData\\Local\\Programs\\Python\\Python38-32\\lib\\site-packages\\aiogram\\bot\\bot.py\", line 95, in get_updates\n result = await self.request(api.Methods.GET_UPDATES, payload)\n File \"C:\\Users\\xxlda\\AppData\\Local\\Programs\\Python\\Python38-32\\lib\\site-packages\\aiogram\\bot\\base.py\", line 200, in request\n return await api.make_request(self.session, self.__token, method, data, files,\n File \"C:\\Users\\xxlda\\AppData\\Local\\Programs\\Python\\Python38-32\\lib\\site-packages\\aiogram\\bot\\api.py\", line 104, in make_request\n return check_result(method, response.content_type, response.status, await response.text())\n File \"C:\\Users\\xxlda\\AppData\\Local\\Programs\\Python\\Python38-32\\lib\\site-packages\\aiogram\\bot\\api.py\", line 82, in check_result\n exceptions.ConflictError.detect(description)\n File \"C:\\Users\\xxlda\\AppData\\Local\\Programs\\Python\\Python38-32\\lib\\site-packages\\aiogram\\utils\\exceptions.py\", line 137, in detect\n raise err(cls.text or description)\naiogram.utils.exceptions.TerminatedByOtherGetUpdates: Terminated by other getupdates request; make sure that only one bot instance is running\n\nI launch the bot's telegram, there are no errors, I write an SMS to the bot and errors pop up, what's the problem?\nhere is the link not github, there is my bot completely-https:\/\/github.com\/bloodyt3ars\/python-telegram-bot.git","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":349,"Q_Id":64490487,"Users Score":0,"Answer":"make sure that only one bot instance is running , it means you should be only person you use that bot token on the time, make sure you don't run the bot on any server like heroku... or with another console after that you can run the code","Q_Score":0,"Tags":"python-3.x,telegram-bot","A_Id":64866758,"CreationDate":"2020-10-22T21:00:00.000","Title":"I launch the bot's telegram, there are no errors, I write an SMS to the bot and errors pop up, what's the problem?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I cannot seem to figure out how to resize images and gifs using discord.py\nIf anyone could tell me how exactly to resize images and gifs using discord.py it would be greatly appreciated as it powers core features of my bot.","AnswerCount":2,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":2698,"Q_Id":64492624,"Users Score":-2,"Answer":"Use a module like Pillow (import PIL)","Q_Score":1,"Tags":"python,imagemagick,python-imaging-library,discord.py,gif","A_Id":67894597,"CreationDate":"2020-10-23T01:23:00.000","Title":"Resizing image discord.py","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to working with APIs, and I recently started a Python project making use of the Google Calendar API that has been put on github. As such, to protect the API keys I created a .env file and stored the keys as environment variables.\nI followed guides that told me to make sure to .gitignore the .env file. However, I don't understand how a user who downloads my app and uses it would be able to access the API key values in the .env file, if the .env file is not in the git repo to begin with.\nThe values in my .env file are essential to authorizing the user's Google account (via OAuth) for use with the app.\nWhat steps would I take to make sure a user of the app is able to retrieve the variables in the ignored .env file?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":39,"Q_Id":64521833,"Users Score":1,"Answer":"I see, so I would need to provide the values to them somehow, and have them configure it manually?\n\nYes, but if those values are sensitive, there should not be stored in the Git repository in the first place.\nWhich means your README (in that git repository) should include instructions in order for a user to:\n\nfetch those values\nbuild the env file","Q_Score":1,"Tags":"python-3.x,git,google-api,environment-variables,google-oauth","A_Id":64533059,"CreationDate":"2020-10-25T08:37:00.000","Title":"How would a user who installs my app access variables from the .env file, if it is ignored by git?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've been trying to create a pyramid command in twitch chat for about 2 weeks now however I'm struggling on how to repeat a word after a specific keyword for example if someone types +pyramid (emote) in chat I want to be able to repeat that specific message after they type +pyramid, im not sure how i can start to do this because I've only found out how to replace words when they are defined e.g replace test with yo. Any help would be greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":108,"Q_Id":64524514,"Users Score":0,"Answer":"you could replace \"+pyramid\" with \"\" (nothing) and that would leave you with your emote. Now you can do a for loop and times the string by the iterator variable to make a pyramid, printing on each loop.","Q_Score":0,"Tags":"python,bots,echo,twitch,mirror","A_Id":64579259,"CreationDate":"2020-10-25T13:57:00.000","Title":"python: repeating a word after a word for a twitch bot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Gurobi and CPLEX are solvers that have been very popular in recent years. CPLEX is easier for academics in terms of the license. It is also said to be very high in performance. But Gurobi is claimed to be the fastest solver in recent years, with continuous improvements. However, it is said that its performance decreases when the number of constraints increases.\nIn terms of speed and performance, which solver is generally recommended specifically for large-scale problems with the quadratic objective function, which have not too many constraints?\nWill their use within Python affect their performance?","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":4002,"Q_Id":64543863,"Users Score":3,"Answer":"As mattmilten already said, if you compare the performance of the major commercial solvers on a range of problems you will find instances where one is clearly better than the others. However that will depend on many details that might seem irrelevant. We did a side-by-side comparison on our own collection of problem instances (saved as MPS files) that were all generated from the same C++ code on different sub-problems of a large optimisation problem. So they were essentially just different sets of data in the same model and we still found big variations across the solvers. It really does depend on the details of your specific problem.","Q_Score":3,"Tags":"python,cplex,gurobi","A_Id":64554706,"CreationDate":"2020-10-26T19:36:00.000","Title":"Comparison between CPLEX and Gurobi","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Gurobi and CPLEX are solvers that have been very popular in recent years. CPLEX is easier for academics in terms of the license. It is also said to be very high in performance. But Gurobi is claimed to be the fastest solver in recent years, with continuous improvements. However, it is said that its performance decreases when the number of constraints increases.\nIn terms of speed and performance, which solver is generally recommended specifically for large-scale problems with the quadratic objective function, which have not too many constraints?\nWill their use within Python affect their performance?","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":4002,"Q_Id":64543863,"Users Score":9,"Answer":"Math programming is inherently hard and there will likely always be instances where one solver is faster than another. Often, problems are solved quickly just because some heuristic was \"lucky\".\nAlso, the size of a problem alone is not a reliable measure for its difficulty. There are tiny instances that are still unsolved while we can solve instances with millions of constraints in a very short amount of time.\nWhen you're looking for the best performance, you should analyze the solver's behavior by inspecting the log file and then try to adjust parameters accordingly. If you have the opportunity to test out different solvers you should just go for it to have even more options available. You should be careful about recommendations for either of the established, state-of-the-art solvers - especially without hands-on computational experiments.\nYou also need to consider the difficulty of the modeling environment\/language and how much time you might need to finish the modeling part.\nTo answer your question concerning Gurobi's Python interface: this is a very performant and popular tool for all kinds of applications and is most likely not going to impact the overall solving time. In the majority of cases, the actual solving time is still the dominant factor while the model construction time is negligible.","Q_Score":3,"Tags":"python,cplex,gurobi","A_Id":64551828,"CreationDate":"2020-10-26T19:36:00.000","Title":"Comparison between CPLEX and Gurobi","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I get a strange error. I tried to download the latest version of meta-python on openembedded but nothing changes\n\nERROR: Layer 'meta-python' depends on version >= 12 of layer 'core',\nbut version 11 is currently enabled in your configuration. Check that\nyou are using the correct matching versions\/branches of these two\nlayers.\n\nMY BBLAYERS\n\/home\/user\/poky\/meta \n\/home\/user\/poky\/meta-poky \n\/home\/user\/poky\/meta-yocto-bsp \n\/home\/user\/poky\/meta-openembedded\/meta-oe \n\/home\/user\/poky\/meta-openembedded\/meta-networking \n\/home\/user\/poky\/meta-openembedded\/meta-multimedia \n\/home\/user\/poky\/meta-openembedded\/meta-python \n\/home\/user\/poky\/meta-raspberrypi \\\nCan someone help me?\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":591,"Q_Id":64575739,"Users Score":0,"Answer":"core layer is in poky\/meta, so you probably have rocko\/sumo\/thud\/warrior (version 11) branch checked out and not dunfell\/gatesgarth (version 12). Check out the same branch in all of your layers.","Q_Score":1,"Tags":"python,yocto,bitbake,openembedded","A_Id":64588636,"CreationDate":"2020-10-28T15:10:00.000","Title":"Layer 'meta-python' depends on version >= 12 of layer 'core'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hope everybody is safe and happy.\nI have given a AWS task as follow.\nRequirement: As soon as file gets uploaded in s3 bucket,it should be zipped and must be uploaded back to another s3 bucket.\nI am able to complete this task using lambda(python) but it involves lots of disk IO. So ,i am looking for a solution where i will not require to store incoming s3 object at \/tmp\/ folder. As we all know , lambda provides very less memory and storage(500MB). Hence, wants to avoid this approach.\nSo, does anybody aware of how to zip the incoming s3 file on the fly? I am only aware that, it possible to do with the help of streaming of s3 object. But not able to find how it can be achieved end to end using python language.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1029,"Q_Id":64607873,"Users Score":0,"Answer":"You can use python generators in the Lambda to zip the s3 files and put the zip file back in another s3 as the generators doesn't occupy memory.","Q_Score":0,"Tags":"python,amazon-web-services,amazon-s3,aws-lambda,zip","A_Id":64608079,"CreationDate":"2020-10-30T11:53:00.000","Title":"How to create zip file and upload back to s3 using lambda python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I know this is a common error and it's been asked many times here on SO. I've been through all the solutions and none of them are working for me.\nI'm using crontab on my iMac (running Catalina) to set up a cron job:\n42 11,20 * * * cd path\/to\/directory && echo | sudo -S \/Library\/Frameworks\/Python.framework\/Versions\/3.8\/bin\/python3 filename.py >> log.txt\nThe full error I'm getting:\nPassword:\/Library\/Frameworks\/Python.framework\/Versions\/3.8\/bin\/python3: can't open file 'filename.py': [Errno 1] Operation not permitted\nI've tried:\n\nAllowing Terminal to have Full Disk Access\nSetting permissions on the files in the directory with sudo chown my-username:my-groupname filename\nAdding password in the command\n\nbut this error never changes.\nAny help gratefully accepted.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1125,"Q_Id":64666365,"Users Score":1,"Answer":"I was able to resolve this. These are steps you can try to follow:\n\nOpen up System Preferences -> Security & Privacy (Mac OSX Catalina)\nOpen Privacy tab\nClick Full Disk Access\nEnsure your version of python has been added to the list of application with access.\n\nTo do this, just find out where in your system Python is located, navigate there by pasting the path into Finder->Go->Go To Folder, finding the exe file, and dragging it into the Full Disk Access section of Privacy.","Q_Score":0,"Tags":"python,macos,cron","A_Id":64685153,"CreationDate":"2020-11-03T16:03:00.000","Title":"Errno 1: Operation not permitted while running cron job in crontab","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've got a package - we'll be creative and call it package - and in there are api and dashboard packages, each with a tests module and various files filled with tests.\nI'm using Django test runner and rather than having package.api.tests and package.dashboard.tests in my run configs, I'd like to just have package.tests and have that run all the tests in the packages below it.\nI added a tests package to package and in the init tried a few things like from package.api.tests import * or using an all declaration but that didn't work.\nIs there a way to make this happen? It's not the most annoying thing in the world, but it's a package that gets brought in to each project we do, and it would just be a bit simpler to have instructions of \"Run package.tests\", especially if we end up adding more packages beyond api and dashboard.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":66,"Q_Id":64667202,"Users Score":1,"Answer":"From the version of 1.6 in Django, you can:\n\nHave test files matching the pattern test*.py. You can therefore have test files in the form of app\/tests\/test_models.py and app\/tests\/test_views.py.\n\n\nYou could also create a file named app\/tests\/test.py and include your\nother files from there. The thing is that the runner will look for\nfiles matching the pattern test*.py and execute them.\n\nAs you mentioned, from package.api.tests import * wouldn't have worked as the test functions could have been split into many different files. Therefore performing import * or using an all import approach is plausible in this case.","Q_Score":0,"Tags":"python,django","A_Id":64670258,"CreationDate":"2020-11-03T16:57:00.000","Title":"Running Python Tests from Subpackages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a test that tests class AbbreviationGenerator. Class names should use camel case, while method names should be lower case. Should I then name the test method test_AbbreviationGenerator or test_abbreviation_generator?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":46,"Q_Id":64682152,"Users Score":1,"Answer":"If the test is a method (as you say) then it's associated with a class, let's say the class is named AbbreviationGeneratorTest. Then you can simply name the method run.","Q_Score":1,"Tags":"python,naming-conventions","A_Id":64683762,"CreationDate":"2020-11-04T14:39:00.000","Title":"Convention for test method names in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to make a business out of my discord.py skills. I have made a discord.py bot and want to export it from pycharm to be able to sell it on a site like fiverr. Does someone know how I could do that? (I am an absolute noob at this, pls help me anyone...)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":55,"Q_Id":64685987,"Users Score":0,"Answer":"So you're exporting the source code? If so, you could copy & paste, but it isn't the most professional way of doing things, you could send them a link to a private github repo, or else send them the folder with the src files etc. There's plenty of ways of doing it. But find out what works for you. :)","Q_Score":0,"Tags":"python,discord.py","A_Id":64770431,"CreationDate":"2020-11-04T18:47:00.000","Title":"Discord.py - Exporting code from pycharm for selling","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to be able to read your current position in an audio file using FFmpeg?\nI want to make it so my discord bot plays an audio clip and then on exit, it saves the current position and then when it rejoins the VC it can resume at that point. I know how to get it to resume at the correct time using -ss but I am not sure how to get the timestamp at the point ti leaves.\nAny help would be appreciated :)!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":206,"Q_Id":64688123,"Users Score":1,"Answer":"I figured out a better way to do it if anyone is interested. if you set a global variable to the time since epoch and set that as start, then when the bot is disconnected set the time since epoch to end. You can then subtract start from end and you are left with the amount of time into the audio clip you are. this can then be stored and retrieved at a later date.","Q_Score":1,"Tags":"python,ffmpeg,discord.py","A_Id":64703377,"CreationDate":"2020-11-04T21:41:00.000","Title":"Being able to read the current audio frame using ffmpeg and python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been using IronPython libraries in C# to alter the values in the python script beforehand before running the python script. I do not want the engine to execute the python code before C# has taken the variables from the python script and manipulated them before putting the new values into the python script variables. I like the getvariable method except for the fact that it seems like it needs the engine to execute first before being able to obtain the variables. Any ideas?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":69,"Q_Id":64704937,"Users Score":0,"Answer":"Here's what I would be doing in this case (of course if possible). You could create a JSON File (or any other medium) in C# with all the variables you want to have changed and then just read it at the beginning of your python script.\nIf that does not work for you, can you maybe elaborate on why you want to change the variables in a python script before running it?\nSidenote: I looked into IronPython for myself and decided to leave my fingers from it as much as possible. At least for my purposes it often does not support the libraries I am interested in and does not seem like there will be support coming anytime soon as it rarely gets significant updates and seems to be dying out. (Microsoft gave up its support quite a long time ago already)","Q_Score":0,"Tags":"python,c#,ironpython","A_Id":64894279,"CreationDate":"2020-11-05T20:38:00.000","Title":"Is there a way to get C# to get and set variables from a python script without executing it beforehand?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I think this mayn't be the right platform for my question. but would like to take inputs. We have developed a chatbot using Python NTLK and tested with Tinker so far.\nWould like to integrate this with our existing GUI developed on Angular 8.\nHow a typical architecture works for GUI to Python based app. do we need to use websockets etc?\nAre there any libraries that we can leverage on Angular side.\nAppreciate any ideas.\nThank you","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":124,"Q_Id":64708746,"Users Score":0,"Answer":"You might be able to make use of dash or flask. They are python front ends","Q_Score":0,"Tags":"python,angular,nltk,chatbot","A_Id":64708872,"CreationDate":"2020-11-06T04:10:00.000","Title":"Integrate chatbot with angular 8 application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need some advise in one of my usecase regarding Cloudtrail and Python boto3.\nI have some cloudtrail events like configured and i need to send the report of all those events manually by downloading the file of events.\nI am planning to automate this stuff using python boto3. Can you please advise how can i use boto3 to get the cloudtrail events for some specific date i should paas at runtime along with the csv or json files downloaded and sent over the email. As of now i have created a python script which shows the cloudtrail event but not able to download the files. Please advise","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":95,"Q_Id":64719698,"Users Score":0,"Answer":"My suggestions is to simply configure the deliver of those events to an S3 bucket, and you have there the file of events. This configuration is part of your trail configuration and doesn't need boto3.\nYou can then access events files stored on S3 using boto3 (personally the best way to interact with AWS resources), and manipulate those files as you prefer.","Q_Score":0,"Tags":"python,amazon-web-services","A_Id":64722873,"CreationDate":"2020-11-06T18:15:00.000","Title":"Download cloudtrail event","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python script stored in one of my S3 buckets, I want to create a lambda function to execute this python script along with passing parameters to my python script.\nThings I tried -\nI am successfully able to read my python script from the lambda handler function using boto3.\nCreated the environment variables successfully to pass to my python script.\nGot a few answers from Stackoverflow that I can copy the script to \/tmp and then import and execute. That is not working.\nQuestion - Reading is fine but how to execute the python script.\nLet me know the options.\nThank You.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":154,"Q_Id":64747153,"Users Score":0,"Answer":"we can create one more AWS Lamba and call from main Lambda. For this you need to create a IAM role to execute the Lambda from Lambda.","Q_Score":0,"Tags":"python,amazon-web-services,aws-lambda","A_Id":71559800,"CreationDate":"2020-11-09T07:09:00.000","Title":"How to execute a python script stored in AWS S3 using AWS Lambda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"When I try to design package structures and class hierarchies within those packages in Python 3 projects, I'm constantly affected with circular import issues. This is whenever I want to implement a class in some module, subclassing a base class from a parent package (i.e. from some __init__.py from some parent directory).\nAlthough I technically understand why that happens, I was not able to come up with a good solution so far. I found some threads here, but none of them go deeper in that particular scenario, let alone mentioning solutions.\nIn particular:\n\nPutting everything in one file is maybe not great. It potentially can be quite a mass of things. Maybe 90% of the entire project code?! Maybe it wants to define a common subclass of things (whatever, e.g. widget base class for a ui lib), and then just lots of subclasses in nicely organized subpackages? There are obvious reasons why we would not write masses of stuff in one file.\n\nImplementing your base class outside of __init__.py and just importing it there can work for a few places, but messes up the hierarchy with lots of aliases for the same thing (e.g. myproject.BaseClass vs. myproject.foo.BaseClass. Just not nice, is it? It also leads to a lot of boilerplate code that also wants to be maintained.\n\nImplementing it outside, and even not importing it in __init__.py makes those \"fully qualified\" notations longer everywhere in the code, because it has to contain .foo everywhere I use BaseClass (yes, I usually do import myproject...somemodule, which is not what everybody does, but should not be bad afaik).\n\nSome kinds of rather dirty tricks could help, e.g. defining those subclasses inside some kind of factory methods, so they are not defined at module level. Can work in a few situations, but is just terrible in general.\n\n\nAll of them are maybe okay in a single isolated situation, more as kind of a workaround imho, but in larger scale it ruins a lot. Also, the dirtier the tricks, the more it also breaks the services an IDE can provide.\nAll kinds of vague statements like 'then your class structure is probably bad and needs reworking' puzzle me a bit. I'm more or less distantly aware of some kinds of general good coding practices, although I never read \"Clean Code\" or similar stuff.\nSo, what is wrong with subclassing a class from a parent module from that abstract perspective? And if it is not, what is the secret workaround that people use in Python3? Is there a one, or is everybody basically dealing with one of the mentioned hacks? Sure, everywhere are tradeoffs to be made. But here I'm really struggling, even after many years of writing Python code.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":54,"Q_Id":64760663,"Users Score":0,"Answer":"Okay, thank you! I think I was a bit on the wrong way here in understanding the actual problem. It's essentially what @tdelaney said. So it's more complicated than what I initially wrote. It's allowed to do that, but you must not import the submodule in some parent packages. This is what I do here in one place for offering some convenience things. So, it's maybe not perfect, maybe the point where you could argue that my structure is not well designed (but, well, things are always a compromise). At least it's admittedly not true what I posted initially. And the workaround to use a few function level imports is maybe kind of okay in that place.","Q_Score":1,"Tags":"python,python-3.x","A_Id":64760915,"CreationDate":"2020-11-09T23:22:00.000","Title":"Python: What is wrong with subclassing a class from a parent package?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python script that runs for a few hours. There is some probability of it failing or hanging. Therefore, I would like to find a way to monitor this script's progress while away from the computer it runs on. I have been looking into multiple options, but none of them are robust and straightforward enough.\nIf someone has some ideas, I'd love to hear them.\nHere are some options I considered:\n\nThe computer running python is connected to my dropbox account. Therefore, I could write an HTML file to my dropbox. This would work on other computers. I could open the HTML file on another computer and refresh the page to get the latest version. However, this would not work on my phone. It would also not push any updates (not necessary, but that would be a great feature).\n\nI looked into building an online dashboard that would visualize data. The idea would be to update the data as the script runs, thereby getting the script's latest state. I looked into plotly and anvil. However, I could not find a way of programmatically updating the data online.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":169,"Q_Id":64761733,"Users Score":0,"Answer":"As a very simple quick fix you could make a log file and have it update it at intervals. Pretty straightforward.","Q_Score":0,"Tags":"python","A_Id":64762514,"CreationDate":"2020-11-10T01:53:00.000","Title":"Monitoring the progress of a python script online, or on my phone, or another computer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have recently installed RPi.GPIO into my pycharm library as well as my linux operating system, but it seems as though anytime I run a command, I receive an error that states:\nTraceback (most recent call last):\nFile \"\/home\/jpxso\/PycharmProjects\/pythonProject\/venv\/Sweep.py\", line 2, in \nimport RPi.GPIO as GPIO\nModuleNotFoundError: No module named 'RPi'","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":699,"Q_Id":64778524,"Users Score":0,"Answer":"Try to use pip install RPi.GIPO. If that doesn't work, then try using the easy_install function in the console.","Q_Score":0,"Tags":"python,raspberry-pi,pycharm,python-import,raspberry-pi-zero","A_Id":64778633,"CreationDate":"2020-11-10T23:54:00.000","Title":"No module named RPI error (even though it is installed)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently learning how to use the Tweepy API, and is there a way to filter quoted Tweets and blocked users? I'm trying to stop search from including quoted Tweets and Tweets from blocked users. I have filtered Retweets and replies already.\nHere's what I have:\nfor tweet in api.search(q = 'python -filter:retweets AND -filter:replies', lang = 'en', count = 100):","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":85,"Q_Id":64780218,"Users Score":0,"Answer":"To filter quotes, use '-filter:quote'","Q_Score":0,"Tags":"python,search,filter,tweepy","A_Id":68703363,"CreationDate":"2020-11-11T03:48:00.000","Title":"Tweepy API Search Filter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm comparing in python the reading time of a row of a matrix, taken first in dense and then in sparse format.\nThe \"extraction\" of a row from a dense matrix costs around 3.6e-05 seconds\nFor the sparse format I tried both csr_mtrix and lil_matrix, but both for the row-reading spent around 1-e04 seconds\nI would expect the sparse format to give the best performance, can anyone help me understand this ?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":413,"Q_Id":64784929,"Users Score":2,"Answer":"arr[i,:] for a dense array produces a view, so its execution time is independent of arr.shape. If you don't understand the distinction between view and copy, you need to do more reading about numpy basics.\ncsr and lil formats allow indexing that looks a lot like ndarray's, but there are key differences. For the most part the concept of a view does not apply. There is one exception. M.getrowview(i) takes advantage of the unique data structure of a lil to produce a view. (Read its doc and code)\nSome indexing of a csr format actually uses matrix multiplication, using a specially constructed 'extractor' matrix.\nIn all cases where sparse indexing produces sparse matrix, actually constructing the new matrix from the data takes time. Sparse does not use compiled code nearly as much as numpy. It's strong point, relative to numpy is matrix multiplication of matrices that are 10% sparse (or smaller).\nIn the simplest format (to understand), coo, each nonzero element is represented by 3 values - data, row, col. Those are stored in 3 1d arrays. So it has to have a sparsity of less than 30% to even break even with respect to memory use. coo does not implement indexing.","Q_Score":1,"Tags":"python,performance,matrix,sparse-matrix","A_Id":64790236,"CreationDate":"2020-11-11T10:45:00.000","Title":"dense matrix vs sparse matrix in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing because I have a discrete optimization problem which I have to solve, and I think there might be already some theoretical results or even libraries in Python implementing it (such as OR-Tool from Google).\nThe problem is the following: I have different objects that are printed using different molds. You can think of objects being little soldiers or anything else. There is a different mold for every kind of object. In total, I have 3 different printers, 2 of which can use (at the same time) 8 molds and 1 which can use 10 molds. When an order for different objects arrives, I have to print all of them trying to minimize the number of prints. There is another side-constraint, which is very important, but which does not have to enter directly the theoretical formulation of the problem: every time I change the molds, I have a huge loss of the printing mater\nial. Therefore, minimizing the number of mold replacements is even more relevant than minimizing the number of prints (in other words, it is better to print more times than required the same objects, if I may change the molds one time less).\nHere is an example which might help the comprehension:\n\nOrders:\n\nObject A: 80\nObject B: 95\nObject C: 101\n\u2026.\nObject Z: 71\n\n\nMolds:\n\nA: 1\nB: 2\nC: 3\n\u2026.\nZ: 1\n\n\nAvailable printers (quantity of molds they handle):\n\nP1: 8\nP2: 8\nP3 10\n\n\n\nNote: a printer always need to be fully loaded with molds.\nI thought of a simple algorithm to arrive to a solution for a single printer, exploiting the ratio order\/number_of_molds per each object, but I am confident there is something better, even to consider multiple \u201cprinter\u201d at the same time. In some sense, it is similar to a bin-packing problem, but it is a bit more complex, with more conditions.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":75,"Q_Id":64794256,"Users Score":0,"Answer":"My thoughts about this are as follows. Prints are (partially) wasted if for any molt (but not all) mounted to a printer the ordered amount of objects is exceeded. This happens if the number of ordered objects for molts mounted to the same printer is not equal.\nThe first step of optimization is therefore to build groups of 8 or 10 molts with a similar amount of ordered objects. Let's keep it simple first and only take groups of 8 into account and forget about the third printer.\nThe sum of wasted prints is the sum of the differences between the largest number of orders and the lowest number of orders within each group.\nWe can optimize this number by splitting the number of orders across the available molts (if more than one). For simplicity, let's forget for the moment that we could split the number also by using the same molt again in a different setup. This gives us M-1 degrees of freedom for each type of molt which we can use to minimize the number of wasted prints (M is the number of molts available).\nThis is far from a complete solution but might be a starting point.","Q_Score":0,"Tags":"python,scheduled-tasks,discrete-optimization","A_Id":64826195,"CreationDate":"2020-11-11T21:16:00.000","Title":"Optimizing combination and number of prints based on order, molds","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to create bot in whatsapp. The Idea is here when a user sends a whatsapp message to my phone number that should reply to them.\nI have researched twillio since it's like a sandbox twillio uses it own whatsapp number and So when a new user comes the user should send the sandbox number. Then I searched for whatsapp API I don't have any company or anything so there I can't use the official whatsapp API.\nIs there some other way of using whatsapp API when I recieve a message it should reply immediately.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":597,"Q_Id":64815647,"Users Score":2,"Answer":"Unfortunately, since WhatsApp is only opening its APIs to its trusted\/business partners, you can only access it using their services. Some of the examples includes,\n\nVonage\nInfobip\nWati\nTwilio as you mentioned\n\nIf these are not enough for you, you can always write your own bot in Python using selenium to scrape the web app for WhatsApp and listen to new message by checking the page regularly.","Q_Score":0,"Tags":"python,automation,whatsapp","A_Id":64816080,"CreationDate":"2020-11-13T04:47:00.000","Title":"How to create a whatsapp bot?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does anybody know what is the IP address of the sender when using Python smtplib to send emails? The sender's email address will be Gmail. Does the email originate from the IP of the computer in which the Python script is executed? Or is it an IP from the Gmail servers?\nI want to make an email marketing program such as Mailchimp for my personal use, but much smaller and with far fewer features than Mailchimp. One key aspect of marketing software is IP. The emails need to be sent from an IP with a good reputation. So, when you send emails with Mailchimp, they are sent from the Mailchimp (well reputable) IPs. I'd like to know what IP will Python send emails from.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":271,"Q_Id":64823473,"Users Score":1,"Answer":"Does the email originate from the IP of the computer in which the Python script is executed? Or is it an IP from the Gmail servers?\n\nNeither. As shown in the example in the docs, it will be the IP address of the server you're connecting to, to send the email. So you'll probably want to connect to the SMTP server of your domain host.\nIf you run an SMTP server locally, it will be IP addr of that machine. And the connection is likely to be rejected by the recipient's smtp server.\nHowever note that in any case, the SMTP server may add the originating IP address to the email headers.\nTo not have your emails outright rejected by the server, take a look at Sender Policy Framework (SPF). Doesn't ensure your email won't get marked as Spam though.","Q_Score":1,"Tags":"python,ip,smtplib","A_Id":64824225,"CreationDate":"2020-11-13T15:22:00.000","Title":"From what IP address does SMTP lib send an email from?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to install Bazaar on Debian 10.6, but cloning the central repository (from the course server) to my local machine. I get the following error:\n\nbzr: ERROR: Unsupported protocol for url \"sftp: \/\/@\/home\/\/public\/trunk\": Unable to import paramiko (required for sftp support): No module named paramiko.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":24,"Q_Id":64828543,"Users Score":1,"Answer":"Paramiko is a python package that is used for SSH connections.\nI guess clone command is trying to make an SSH connection and because Paramiko is not installed you get an Error.\nTry to make pip install paramiko and then make the clone again (:","Q_Score":0,"Tags":"python","A_Id":64828600,"CreationDate":"2020-11-13T21:57:00.000","Title":"Problems installing Bazzar on Debian 10.6","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"when i try to install psycopg2 the error appears\nfatal error: Python.h: No such file or directory\n#include \nbecause, there is a search for this file along the path \/usr\/include\/python3.8\nbut this file is located in the path \/usr\/local\/include\/python3.8\/Python.x\nHow to solve this problem?? Is Python installed in the wrong directory?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2180,"Q_Id":64830200,"Users Score":1,"Answer":"Its not clear what version of Ubuntu you are using. Assuming it is a fresh install and you don't have these installed. I would suggest you install the following\nsudo apt-get install python3 python-dev python3-dev build-essential\nOnce these are installed then try again installing psycopg2","Q_Score":0,"Tags":"python,ubuntu","A_Id":64830233,"CreationDate":"2020-11-14T01:56:00.000","Title":"Ubuntu, fatal error: Python.h: No such file or directory #include","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have an issue executing pytest from GitBash.\nIn GitBash im located in directory of my pytest and .py file. Writing pytest in GitBash gives me bash: pytest: command not found. I know that i can execute pytest from the PyChamr's terminal, but it's not this comfortable to use as executed from Bash.\nI looked in internet and found, that pytest installed in venv, this may cause some issue.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":453,"Q_Id":64838404,"Users Score":0,"Answer":"You need to either add the directory where pytest is located to your PATH environment variable or you need to specify the full path in the command. For GitBash, you can do this by editing the .bashrc file in your home directory.","Q_Score":0,"Tags":"python,pytest","A_Id":64838419,"CreationDate":"2020-11-14T20:39:00.000","Title":"Executing pytest from GitBash","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm writing a project which writes using the same data a ton of times, and I have been using ray to scale this up in a cluster setting, however the files are too large to send back and forth\/save on the ray object store all the time. Is there a way to save the python objects on the local nodes between the calls of the remote functions?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":404,"Q_Id":64840392,"Users Score":2,"Answer":"Writing to files always tends to be tricky in distributed systems since regular file systems aren't shared between machines. Ray generally doesn't interfere with the file system, but I think you have a few options here.\n\nExpand the object store size: You can change the plasma store size and where it's stored to a larger file by setting the --object-store-memory and --plasma-directory flags.\n\nUse a distributed file system: Distributed filesystems like NFS allow you to share part of your filesystem across machines. If you manually set up an NFS share, you can direct Ray to write to a file within NFS.\n\nDon't use a filesystem: While this is technically a non-answer, this is arguably the most typical approach to distributed systems. Instead of writing to your filesystem, consider writing to S3 or similar KV store or Blob Store.\n\n\nDownsides of these approaches:\nThe biggest downside of (1) is that if you aren't careful, you could badly affect your performance.\nThe biggest downside of (2) is that it can be slow. In particular, if you need to read and write data from multiple nodes. A secondary downside is that you will have to setup NFS yourself.\nThe biggest downside to (3) is that you're now relying on an external service, and it arguably isn't a direct solution to your problem.","Q_Score":3,"Tags":"python,python-3.x,ray","A_Id":64867574,"CreationDate":"2020-11-15T01:25:00.000","Title":"Store objects between remote functions in Ray","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a solo project which I published to PyPi. Now that I've installed it with pip rather than using it from my git repo, what is the best-practice for continuing development ?\nI've tried two approaches till now:\n\nThe naivete: edit scripts in site-packages folder, test them, once finalized, copy to repo and push( and build, publish etc)\nThe doppelganger: make a (sparse) repo to track the scripts in site packages, push whenever. Once ready to publish, go to the folder with the full repo, pull and then build>publish.\n\nNow, 1. is too clunky, while 2. leaves me thoroughly unsatisfied. I was thinking of using bash tricks to streamline 2., but I thought that the sages here might have something much more streamlined, so I ask.\nThank You!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":83,"Q_Id":64893450,"Users Score":1,"Answer":"For development you will still want to get and edit source code from the git repository, not from PyPi.\nFor example, if your git repository lived under ...\/src\/myproject\/, I would run pip install . inside myproject. This emulates an installation in the exact same way that pip install myproject=={version} would if it downloaded from PyPi. (copies the code to site-packages)\nEven better for development is pip install -e ., which sets a symbolic link from site-packages back to your source directory. So while it looks like your project is installed in your venv, it's actually just using the source code from your git repo folder.\nIn general the downloads from PyPi are for users of your script, not contributors.\nLet me know in the comments if you want me to expand on any of this.","Q_Score":0,"Tags":"python,git,packaging,pypi","A_Id":64893615,"CreationDate":"2020-11-18T12:47:00.000","Title":"Canonical workflow for python packaging and GitHub","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have two raspberrypis.\nraspberrypi 1\nraspberrypi 2\nI want to send a text message from raspberrypi 1 to raspberrypi 2 using python. Is there anyway to do it without using sockets?\nor connect both raspberrypis to each other and create a local network?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":26,"Q_Id":64894913,"Users Score":0,"Answer":"To establish communication you need access from one to another, whether its a local network or you home network. That does not really change the need that you have to use some kind of protocol or create one. Both solutions include creating a socket.\nThe first solution would save you from writing any of that, but still you would need to decide how they are going to communicate which basically can be defined by what you want them to talk about.","Q_Score":0,"Tags":"python,sockets,raspberry-pi","A_Id":64895002,"CreationDate":"2020-11-18T14:20:00.000","Title":"How to send a text message from raspberrypi 1 to raspberrypi2 using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have one old certificate and one new certificate in my keystore hence i want to remove the old cert by using the wsadmin script and also import the new one using wsadmin script.\ni have listed the cert using this command -\nCommand to List certs -\nAdminTask.listPersonalCertificate('[-keystorename -keystorescope ')\ni received complete output and also i want to compare the certs using the validity so that i will remove the old cert only.\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":401,"Q_Id":64905811,"Users Score":0,"Answer":"Typically you would use the admin console, with command assistance turned on, to perform the operation you wish to script, then examine the output of command assistance. Just note, not all admin console operations go through a scriptable path, in that case, you'll need to look at the security mbean operations for examples.","Q_Score":0,"Tags":"python,websphere,jython,websphere-8,wsadmin","A_Id":64917696,"CreationDate":"2020-11-19T05:18:00.000","Title":"How to create script to import and delete personal certificate in websphere application server using wsadmin?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm working in Python. I'm trying to connect a Windows PC with a Raspberry Pi. I have a sensor connected to the Pi, and a small Python script to publish data to the MQTT broker, also located on the Raspberry Pi.\nThe general logic is for the Window's PC to publish a \"send\" message to \"topic 1\". The RasPi listens to \"topic 1\", and when it see's \"send\", it gets the latest sensor data, and publishes it to \"topic 2\". The Window's PC then listens to \"topic 2\", and grabs the data.\nMy issue:\nI'm always one sensor reading behind. I never get the sensor reading attached to when my \"send\" message.\nI am expected to publish a \"send\", and read the latest data once it has been sent.\nAny thoughts?\n-Parsko\nPS - New poster here on SO, still learning how to ask questions of the community.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":119,"Q_Id":64912691,"Users Score":0,"Answer":"There is no need for the Windows machine to send any request messages.\nMQTT is a pub\/sub protocol, which is a very different mindset from a request\/response protocol (e.g. HTTP)\nThe sensors should just publish their values to sensor specific topics and the Windows machine should just subscribe to those topics. This way it will always have the most up to date data.","Q_Score":0,"Tags":"python,raspberry-pi,mqtt,sensors,missing-data","A_Id":64913027,"CreationDate":"2020-11-19T13:28:00.000","Title":"MQTT two way sensor data collection","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We speak of a large report with many pages and visualisations on it.\nThe only quite obvious idea I have is to open each page and review all the visualisations and text areas\nmanually but I wonder if there can be a script that would help with the task.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":76,"Q_Id":64917688,"Users Score":0,"Answer":"You might be able to get some of this information out of the Spotfire database. I'm still on version 10.3, not the newer version, but I know that they are tracking more and more user actions in later versions.","Q_Score":1,"Tags":"python,ironpython,spotfire","A_Id":64919474,"CreationDate":"2020-11-19T18:19:00.000","Title":"How to identify unused columns\/calculated columns present in the report (IronPython perhaps?)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working out of R Studio and am trying to replicate what I am doing in R in Python. On my terminal, it is saying that I have xlrd already installed but when I try to import the package (import xlrd) in R Studio, it tells me: \"No module named 'xlrd'\". Does anyone know how to fix this?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":66,"Q_Id":64918902,"Users Score":1,"Answer":"I have solved this on my own. In your terminal, go to ls -a and this will list out applications on your laptop. If Renviron is there, type nano .Renviron to write to the Renviron file. Find where Python is stored on your laptop and type RETICULATE_PYTHON=(file path where Python is stored). ctrl + x to exit, y to save and then hit enter. Restart R studio and this should work for you.","Q_Score":1,"Tags":"python,r","A_Id":64919232,"CreationDate":"2020-11-19T19:45:00.000","Title":"No module names xlrd","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Basically as you all know we can backtest our strategies in Zipline, the problem is that Zipline is developed for stock markets and the minimum order of an asset that can be ordered is 1 in those markets but in crypto markets we are able to order a fraction of a Crypto currency.\nSo how can I make zipline to order a fraction of Bitcoin base on the available capital?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":117,"Q_Id":64930701,"Users Score":0,"Answer":"You can simulate your test on a smaller scale, e.g. on Satoshi level (1e8).\nI can think of two methods:\n\nIncrease your capital to the base of 1e8, and leave the input as is. This way you can analyse the result in Satoshi, but you need to correct for the final portfolio value and any other factors that are dependent on the capital base.\nScale the input to Satoshi or any other level and change the handle_data method to either order on Satoshi level or based on your portfolio percentage using order_target_percent method.\n\nNOTE: Zipline rounds the inputs to 3 decimal points. So re-scaling to Satoshi turns prices that are lower than 5000 to NaN (not considering rounding errors for higher prices). My suggestion is to either use 1e5 for Bitcoin or log-scale.","Q_Score":0,"Tags":"python-3.x,quantitative-finance,catalyst,zipline,back-testing","A_Id":67819691,"CreationDate":"2020-11-20T13:54:00.000","Title":"How to Order a fraction of a Crypto (like Bitcoin) in zipline?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I get a some big files from a web page. They're binary. I need to scan them to detect thier encode, because chardet.detect let be my script too slow. I tought to use readline but i can't 'cause i have only binary. It's possibile to do something like readline on a binary object?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":159,"Q_Id":64934344,"Users Score":1,"Answer":"You can't know when there is a newline because you don't know how is it encoded. You can simply take a small part of your binary data data[:100] and run chardet.detect on that.","Q_Score":0,"Tags":"python,python-3.x,encoding,binary,chardet","A_Id":64934954,"CreationDate":"2020-11-20T17:45:00.000","Title":"Python: chardet.detect with a big binary object","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have seen a discord bot existing that could show specific videos from its camera.\nIs there any way I could add a command that would accept a direct video link and display it on a discord bot's camera? At least to show a video. (During streams)","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":6909,"Q_Id":64939089,"Users Score":0,"Answer":"To my knowledge there is no way (yet) for a bot to stream a video in video format on Discord. Bots cannot stream anything other than audio on a voice channel.","Q_Score":1,"Tags":"python,video,discord,bots,discord.py","A_Id":64944981,"CreationDate":"2020-11-21T01:54:00.000","Title":"Is it possible to show a video on discord bot camera?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have seen a discord bot existing that could show specific videos from its camera.\nIs there any way I could add a command that would accept a direct video link and display it on a discord bot's camera? At least to show a video. (During streams)","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":6909,"Q_Id":64939089,"Users Score":3,"Answer":"I think that it may be possible but not yet available to the general public. I think maybe the bot you are referring to could have been taken down for breaking TOS. You might be able to do it but I do not think its allowed.","Q_Score":1,"Tags":"python,video,discord,bots,discord.py","A_Id":64948022,"CreationDate":"2020-11-21T01:54:00.000","Title":"Is it possible to show a video on discord bot camera?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Pycharm IDE for my python projects. When I try to send my projects by email it gets blocked for security issues but, when I delete the script folder in my projects it is sent. But, will it run in the destination computer correctly without the script folder?\nThank you for your help","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":64941145,"Users Score":0,"Answer":"Allow users to manage their access to less secure apps :\nYou may be able to connect to the Gmail server with your Google username and password. This setup is only available when:\nYou have enabled the option to allow access to less secure apps in the Google account that you use to connect to the Gmail service.\nYou have not enabled 2-Step Verification for this Google account.\nIf you have enabled 2-Step Verification for this Google account, you need to generate and use an App Password. Configure the SMTP settings in Hub as if access to less secure apps were disabled.","Q_Score":0,"Tags":"python-3.x","A_Id":64941335,"CreationDate":"2020-11-21T08:29:00.000","Title":"delete script folder of python projects","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Pycharm IDE for my python projects. When I try to send my projects by email it gets blocked for security issues but, when I delete the script folder in my projects it is sent. But, will it run in the destination computer correctly without the script folder?\nThank you for your help","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":30,"Q_Id":64941145,"Users Score":0,"Answer":"As long as systems have same version of python running and fully functional code without any missing dependencies, it'll run file.\nAll you need is python file and associated data to run it successfully on any system.","Q_Score":0,"Tags":"python-3.x","A_Id":64941190,"CreationDate":"2020-11-21T08:29:00.000","Title":"delete script folder of python projects","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an n-element array. All elements except 4\u221an of them are sorted. We do not know the positions of these misplaced elements. What is the most efficient way of sorting this list?\nIs there an O(n) way to do this?\nUpdate 1:\ntime complexity of an\u200b insertion sort is O(n) for almost sorted data (is it true in worst case?)?","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":1084,"Q_Id":64956096,"Users Score":6,"Answer":"There is a fast general method for sorting almost sorted arrays:\n\nScan through the original array from start to end. If you find two items that are not ordered correctly, move them to a second array and remove them from the first array. Be careful; for example if you remove x2 and x3, then you need to check again that x1 \u2264 x2. This is done in O(n) time. In your case, the new array is at most 8sqrt(n) in size.\n\nSort the second array, then merge both arrays. With the small number of items in the second array, any reasonable sorting algorithm will sort the small second array in O(n), and the merge takes O(n) again, so the total time is O(n).\n\n\nIf you use a O(n log n) algorithm to sort the second array, then sorting is O(n) as long as the number of items in the wrong position is at most O (n \/ log n).","Q_Score":5,"Tags":"python,arrays,algorithm,sorting,data-structures","A_Id":64956474,"CreationDate":"2020-11-22T15:41:00.000","Title":"insertion sort worst time complexity for near sorted array?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was writing code to make a facial recognition, but my code did not work because I was writing on verison 3, do you know how to download python 3 on the raspberry pi?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":65,"Q_Id":64956516,"Users Score":0,"Answer":"Linux uses package managers to download packages or programing languages\n,raspberry pi uses apt(advanced package tool)\nThis is how you use APT to install python3:\nsudo apt-get install python3\nOR\nsudo apt install python3\nand to test if python3 installed correctly type:\npython3\nIf a python shell opens python3 has been installed properly","Q_Score":1,"Tags":"python","A_Id":64956560,"CreationDate":"2020-11-22T16:19:00.000","Title":"Raspberry pi python editor","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently working on a non-convex optimization problem, and I have used Bayesian Optimization as a method to solve this problem. And it didn't show good convergence. (Is Bayesian Optimization is an effective way to solve this problem?)\nAnyone can help me to see if there're other efficient ways to solve the non-convex optimization problem?\nI'm using python, so, could anyone show me some package in python that can do it?\nThank you!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":116,"Q_Id":64977532,"Users Score":0,"Answer":"There\u2019s way too little information about your problem to suggest a solution. How many parameters do you have in your objective function? Do you have analytical gradients available? Is your objective function expensive to evaluate or very fast? Do you have bound constraints? Linear and\/or nonlinear constraints? Do you care about trying to find a global optimum or are you happy with a good enough local minimum\/maximum? Any reason why you chose Bayesian optimization to start with?","Q_Score":0,"Tags":"python,optimization,non-convex","A_Id":64999506,"CreationDate":"2020-11-23T22:32:00.000","Title":"Non-convex function optimization","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to develop a script in Python 3.7 using Appium in which I want to enter any text in the text fields using the keyboard opened by the app. Is there any way to type the text using keyboard without using send_keys method in appium.\nI am also not sure how send_keys works internally, whether it only works when the app keyboard is opened or its just simply enters the text without keyboard opened.\nI would prefer to type the text, character by character, using the keyboard of the smartphone.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":442,"Q_Id":65011748,"Users Score":0,"Answer":"Actually, this is not a good idea because there is no way to touching keyboard keys as an element. I mean the appium cannot see the keyboard as elements. Also, you will need this if you only want to test the functionality of the keyboard itself. Otherwise technically element.send_keys() acts the same with no difference on std-out. Also, element.set_text() act the paste if you want.\nAnyway, to reach this you should:\n1- Open the keyboard by clicking on the input field\n2- Find the coordinates of the keys and store them in a variable.\n3- Touch the coordinates directly.","Q_Score":1,"Tags":"python,appium,ui-automation,appium-android","A_Id":65091554,"CreationDate":"2020-11-25T19:47:00.000","Title":"How to type texts with Android Keyboard using Appium and Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I was in the middle of creating a script that takes in utf-8 characters from stdin and outputs the number of bits the tree takes up + the Huffman tree + Huffman encoding of the characters. I want to use strict encoding so in the event of an unexpected character there will be a UnicodeError outputted to the console (using python 3).\nI want to know what is objectively better to do in the event of a crash:\n\noutput to stdout if and only if no error will be encountered.\nOr, output what has already been encoded to stdout with a UnicodeError following it (which gets printed to stderr of course)\nor, it doesn't matter.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":14,"Q_Id":65015760,"Users Score":1,"Answer":"Thanks for the help IronMan: Here is a summary.\nIt depends:\n\nIf you need the entire data file in order to output an answer, it doesn't matter.\nIf you can stream the output (like file conversion), then you should error when you encounter it.","Q_Score":1,"Tags":"python-3.x,shell,scripting","A_Id":65015917,"CreationDate":"2020-11-26T03:36:00.000","Title":"General scripting best practices when an error occurs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Trying to run \"helloworld.py\" in PyCharm 2020.2 which I thought I'd installed via Anaconda\nthis error appears in a few threads but the discussions are always about stuff that's a bit beyond a hello world program. I think it might be something to do with this PYTHONPATH thing but I don't understand where this is set (its not in Windows system environment variables), or who set it, or how to fix it.\n\nC:\\Users\\DrMan\\anaconda3\\python.exe\nC:\/Users\/DrMan\/AppData\/Local\/Programs\/Python\/Python39\/helloworld.py\nPython path configuration:\nPYTHONHOME = (not set)\nPYTHONPATH ='C:\\Users\\DrMan\\AppData\\Local\\Programs\\Python\\Python39'\nprogram name = 'C:\\Users\\DrMan\\anaconda3\\python.exe'\nisolated = 0\nenvironment = 1\nuser site = 1\nimport site = 1\nsys._base_executable = 'C:\\Users\\DrMan\\anaconda3\\python.exe'\nsys.base_prefix = ''\nsys.base_exec_prefix = '' sys.executable =\n'C:\\Users\\DrMan\\anaconda3\\python.exe'\nsys.prefix = ''\nsys.exec_prefix = ''\nsys.path = [\n'C:\\Users\\DrMan\\AppData\\Local\\Programs\\Python\\Python39',\n'C:\\Users\\DrMan\\anaconda3\\python38.zip',\n'C:\\Users\\DrMan\\anaconda3', ]\nFatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem\nencoding Python runtime state: core initialized ModuleNotFoundError:\nNo module named 'encodings'\nCurrent thread 0x000098b8 (most recent call first): \nProcess finished with exit code 1","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2592,"Q_Id":65047781,"Users Score":0,"Answer":"In my case it was my root python 3.9 installation (used by my venv), that imported a file from my pycharm project (because my project was in PYTHONPATH).\nThe easiest way to solve the problem was to rename the file python was trying to import, so python would not find it anymore and fall back to the correct file in (my case) C:\\python39.","Q_Score":2,"Tags":"python-3.x,pycharm","A_Id":68815566,"CreationDate":"2020-11-28T08:30:00.000","Title":"PyCharm: Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"Trying to run \"helloworld.py\" in PyCharm 2020.2 which I thought I'd installed via Anaconda\nthis error appears in a few threads but the discussions are always about stuff that's a bit beyond a hello world program. I think it might be something to do with this PYTHONPATH thing but I don't understand where this is set (its not in Windows system environment variables), or who set it, or how to fix it.\n\nC:\\Users\\DrMan\\anaconda3\\python.exe\nC:\/Users\/DrMan\/AppData\/Local\/Programs\/Python\/Python39\/helloworld.py\nPython path configuration:\nPYTHONHOME = (not set)\nPYTHONPATH ='C:\\Users\\DrMan\\AppData\\Local\\Programs\\Python\\Python39'\nprogram name = 'C:\\Users\\DrMan\\anaconda3\\python.exe'\nisolated = 0\nenvironment = 1\nuser site = 1\nimport site = 1\nsys._base_executable = 'C:\\Users\\DrMan\\anaconda3\\python.exe'\nsys.base_prefix = ''\nsys.base_exec_prefix = '' sys.executable =\n'C:\\Users\\DrMan\\anaconda3\\python.exe'\nsys.prefix = ''\nsys.exec_prefix = ''\nsys.path = [\n'C:\\Users\\DrMan\\AppData\\Local\\Programs\\Python\\Python39',\n'C:\\Users\\DrMan\\anaconda3\\python38.zip',\n'C:\\Users\\DrMan\\anaconda3', ]\nFatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem\nencoding Python runtime state: core initialized ModuleNotFoundError:\nNo module named 'encodings'\nCurrent thread 0x000098b8 (most recent call first): \nProcess finished with exit code 1","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2592,"Q_Id":65047781,"Users Score":0,"Answer":"OK I found in the settings where I could change the Python Interpreter which I removed and added a link to the directory where i run IDLE and now it works.\nIf anyone has a good link\/reference to understanding all this I would appreciate it. I am a beginner, so haven't really got into worrying about environments and packages and versions but I would like to \"grok it\" so I don't get into bad habits, like from the ground up how environments, packages and paths and settings are working.","Q_Score":2,"Tags":"python-3.x,pycharm","A_Id":65047837,"CreationDate":"2020-11-28T08:30:00.000","Title":"PyCharm: Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"A python evdev device has a .grab() function that prevents other processes from getting input events on the device. Is there any way to limit this to specific events from a device?\nFor my example, if I .grab() a pen input device that has pressure sensitivity and tilt and 2 click buttons on the side, how would I 'grab' ONLY the 2 click buttons but let the rest of the input (the tip, pressure sensitivity and tilt) be caught by the rest of the system as normal?\nOne of my pen buttons is normally a right click mouse event. I want to make it do something else but it still pops up the right click menu so I'm trying to figure out how to stop that.\nI tried doing the grab and ungrab when the event occurs. Like event > grab > do my stuff > ungrab. But that is obviously too late and the OS still pops up the menu.\nI tried doing the full grab, then in the event loop if it is a button press do my stuff, otherwise create a UInput event injection by just passing the event back to the system. This was a bit of a tangled mess. Permissions are required. When I finally got past that, the movement was offset and the pressure\/tilt wasn't working... I think it is something to do with the DigiMend driver that actually makes that stuff work and\/or xinput settings I have to pass to calibrate the tablet. But I'm not interested in writing all the pressure\/tilt functionality from scratch or anything like that, so I need the DigiMend stuff to work as normal. So I gave up on this idea for now.\nThe only other thought I had was figure out why the OS defaults to the behavior it does and see if I can just manually disable the actions (i.e. Why does it think that button is a right mouse click and make it think that button is nothing instead.)\nSo I guess this is a 3 level question.\n\nCan I achieve the the grab functionality on select events instead of the device as a whole?\nIf the passthrough idea was better, is there a way to achieve this without having to do any permission modifications and be able to pass the exact event (i.e. no offset and such that I experienced?)\nIf evdev does not have this ability or it'd be easier to do in another way, like disabling the defaults for the pen in the OS somehow, I am open to suggestions. I am using Kubuntu 20.04 if that helps.\n\nAny help would be appreciated, let me know if more info is needed, thanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":233,"Q_Id":65062658,"Users Score":0,"Answer":"I ended up going with #3 and using xinput. Figured I'd put up this answer for now in case others come across this and want to do something similar.\nThe workaround was actually kind of simple. I just use xinput to remap the 2 buttons. So evdev doesn't have to grab at all. Just disable those buttons and everything goes normally except those, which I listen for with evdev.\nxinput set-button-map {} 1 0 0 4 5 6 7\nMy device has 7 buttons and are normally mapped 1-7. Which are all mouse equivalents of left click, middle click, right click, etc...\nBy using that string and passing the device ID in for the {} I just run that with subprocess first. And voila, no more right click menu. And I can use evdev to map the events to whatever I want.","Q_Score":0,"Tags":"python,linux,ubuntu,kde-plasma,evdev","A_Id":65068235,"CreationDate":"2020-11-29T16:53:00.000","Title":"Does Python evdev library have an event specific grab or passthrough?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am resposible for doing Alexa Skill on my company. We received a new Skill to do. This skill needs to contact the data that is saved on Amazon Redshift and Alexa will get information like \"what was the number of sales on November?\" things like that. It is possible to connect this two services: Alexa Skill and Amazon Redshift?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":32,"Q_Id":65073107,"Users Score":0,"Answer":"Yes and I've done it in the past but there is a catch. Alexa can run Lambda functions and Lambda can access Redshift. It is a little more complicated than that but not much. I had Lambdas that started and stopped a Redshift cluster (plus a few more actions) and had an office Alexa enabled to run these.\nThe catch is the authentication model. How do you know who is speaking to Alexa? Anyone that can speak to an authorized Alexa can execute the Lambda functions you have defined for it to run. Enabling Alexa to have access to anything sensitive is problematic and Redshift often contains sensitive information. We quickly disallowed Alexa from running these and just kept them executable from Slack.","Q_Score":0,"Tags":"python,amazon-web-services,alexa-skills-kit,alexa-skill","A_Id":65078035,"CreationDate":"2020-11-30T11:56:00.000","Title":"It is possible to use Alexa Skill with Amazon Redshift?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Im trying to make a script that sent an email with python using smtp.smtplib , almost of examples i found while googling shows how to call this function with only smtpserver and port parameters.\ni want to added other paramaters : domain and binding IP\ni tried this : server = smtplib.SMTP(smtpserver, 25,'mydomain.com',5,'myServerIP')\nI got this as error : TypeError: init() takes at most 5 arguments (6 given)\nCan you suggest a way to do this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":58,"Q_Id":65094095,"Users Score":0,"Answer":"This error is likely because the parameters are invalid (there is one too many). Try looking at the smtplib docs to see what parameters are valid","Q_Score":0,"Tags":"python,smtplib","A_Id":65094148,"CreationDate":"2020-12-01T16:05:00.000","Title":"Added more parameters to smtplib.SMTP in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently working on a project in which I am using a webcam attached to a raspberry pi to then show what the camera is seeing through a website using a client and web server based method through python, However, I need to know how to link the raspberry pi to a website to then output what it sees through the camera while then also outputting it through the python script, but then i don't know where to start\nIf anyone could help me I would really appreciate it.\nMany thanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":111,"Q_Id":65141422,"Users Score":0,"Answer":"So one way to do this with python would be to capture the camera image using opencv in a loop and display it to a website hosted on the Pi using a python frontend like flask (or some other frontend). However as others have pointed out, the latency on this would be so bad any processing you wish to do would be nearly impossible.\nIf you wish to do this without python, take a look at mjpg-streamer, that can pull a video feed from an attached camera and display it on a localhost website. The quality is fairly good on localhost. You can then forward this to the web (if needed) using port forwarding or an application like nginx.\nIf you want to split the recorded stream into 2 (to forward one to python and to broadcast another to a website), ffmpeg is your best bet, but the FPS and quality would likely be terrible.","Q_Score":0,"Tags":"python,raspberry-pi","A_Id":65146963,"CreationDate":"2020-12-04T09:56:00.000","Title":"raspberry pi using a webcam to output to a website to view","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am having the script to send outlook email through python libaray win32\/Automagica .\nThe email have successfully send if i run the script in normal way(using IDE)\nwhen i try to run the same script from jenkins ,it throws \"Exception: Could not launch Outlook, do you have Microsoft Office installed on Windows?\"\noutlook = Outlook(account_name=accountName)\nFile \"C:\\Python39\\lib\\site-packages\\automagica\\utilities.py\", line 41, in wrapper\nreturn func(*args, **kwargs)\nFile \"C:\\Python39\\lib\\site-packages\\automagica\\activities.py\", line 4186, in init\nself.app = self._launch()\nFile \"C:\\Python39\\lib\\site-packages\\automagica\\activities.py\", line 4202, in _launch\nraise Exception(\nException: Could not launch Outlook, do you have Microsoft Office installed on Windows?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":96,"Q_Id":65142863,"Users Score":0,"Answer":"Yeah ..Now it is working ..it is because of Jenkins running under Admin rights and Outlook is in User Rights...after i start to run Jenkins on User rights(not Admin)it is able to send email through Outlook","Q_Score":0,"Tags":"python,jenkins,outlook","A_Id":65178555,"CreationDate":"2020-12-04T11:36:00.000","Title":"Cannot able to send email from Jenkins using python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have some pdf files in a directory. Some of them are password protected, some of them are not. I know the passwords for each of the password protected files. How do I automate the process of removing passwords from each of the pdf files? I am thinking of something like:\n\nGetting the password protected file.\nTrying the given passwords from a wordlist I've made.\nPrinting out the password for the file.\nSaving the file as 'Decrypted_filename.pdf'","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1311,"Q_Id":65177156,"Users Score":0,"Answer":"I think you can solve your problem with pyPdf","Q_Score":2,"Tags":"python,python-3.x,pdf,unix","A_Id":65177219,"CreationDate":"2020-12-07T06:43:00.000","Title":"How do I remove passwords of some of all the pdf files in a directory with python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am testing Python 3.6 on Windows iis 10.0 and get the error 401 from browser when I call a .py file.\n\nI have iis working on ASP pages and HTML\nI have phyton.exe installed and working\nI have added a .py handler in iis\nI have tried to allow anonymous access and set up authorization as IUSR in iis\n( And I allowed IUSR and IIS_IUSR... Full access on application directory)\n\nI looked on Google and tried out many suggetsions!\nBUT No way to esecute the script!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":173,"Q_Id":65180178,"Users Score":0,"Answer":"You have to add %s %s at the end of the Python Interpreter address.","Q_Score":0,"Tags":"python,iis","A_Id":65427202,"CreationDate":"2020-12-07T10:41:00.000","Title":"How can I eliminate 401 error on IIS when calling Python script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I appear to be missing some fundamental Python concept that is so simple that no one ever talks about it. I apologize in advance for likely using improper description - I probably don't know enough to ask the question correctly.\nHere is a conceptual dead end I have arrived at:\nI have an instance of Class Net, which handles communicating with some things over the internet.\nI have an instance of Class Process, which does a bunch of processing and data management\nI have an instance of Class Gui, which handles the GUI.\nThe Gui instance needs access to Net and Process instances, as the callbacks from its widgets call those methods, among other things.\nThe Net and Process instances need access to some of the Gui instances' methods, as they need to occasionally display stuff (what it's doing, results of queries, etc)\nHow do I manage it so these things talk to each other? Inheritance doesn't work - I need the instance, not the class. Besides, inheritance is one way, not two way.\nI can obviously instantiate the Gui, and then pass it (as an object) to the others when they are instantiated. But the Gui then won't know about the Process and Net instances. I can of course then manually pass the Net and Process instances to the Gui instance after creation, but that seems like a hack, not like proper practice. Also the number of interdependencies I have to manually pass along grows rather quickly (almost factorially?) with the number of objects involved - so I expect this is not the correct strategy.\nI arrived at this dead end after trying the same thing with normal functions, where I am more comfortable. Due to their size, the similarly grouped functions lived in separate modules, again Net, Gui, and Process. The problem was exactly the same. A 'parent' module imports 'child' modules, and can then can call their methods. But how do the child modules call the parent module's methods, and how do they call each other's methods? Having everything import everything seems fraught with peril, and again seems to explode as more objects are involved.\nSo what am I missing in organizing my code that I run into this problem where apparently all other python users do not?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":81,"Q_Id":65217340,"Users Score":1,"Answer":"The answer to this is insanely simple.\nAnything that needs to be globally available to other modules can be stored its own module, global_param for instance. Every other module can import global_param, and then use and modify its contents as needed. This avoids any issues with circular importing as well.\nNot sure why it took me so long to figure this out...","Q_Score":0,"Tags":"python,concept","A_Id":66012638,"CreationDate":"2020-12-09T13:03:00.000","Title":"How do I handle communication between object instances, or between modules?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"this is kind of a dumb question but how would I make a discord.py event to automatically react to a message with a bunch of different default discord emojis at once. I am new to discord.py","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":265,"Q_Id":65223410,"Users Score":0,"Answer":"You have to use on_message event. Its a default d.py function. It is an automatic function.","Q_Score":0,"Tags":"python,discord,discord.py","A_Id":65923529,"CreationDate":"2020-12-09T19:13:00.000","Title":"How would I use a bot to send multiple reactions on one message? Discord.py","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am considering working on a project to emulate circuits in order to get more invested in an electronic circuits class that I am currently taking. I have found it useful to create Python scripts to work on my homework calculations, but now I would like to make a website to share with classmates to use these scripts.\nFrom my understanding, I can run only run Javascript on the browser and can only use Python on the backend. I've gotten comfortable with using Python for math and have heard that it's better in general for mathematics. In my assignments, the most that I've worked with is pi and long floating point numbers.\nSo...\nWould it be worth my time to create a python backend to run calculations? Or can I get by with browser `Javascript` for calculations. I am comfortable with both languages.\nAlso as a follow-up question, could I use Flask to run Python in the browser?\nThank you!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":126,"Q_Id":65228710,"Users Score":3,"Answer":"The only case in which one would definitely be preferable to the other would be if the calculations to be performed may get very expensive, in which case it would be much more user-friendly to have the server shoulder the load, rather than having the client do it (since low-end clients may become unresponsive for too long while calculating).\nIf that's a potential issue for your case, running the expensive code on the backend would be the way to go. (It doesn't have to be Python on the backend - it could even be server-side JS, or even PHP or whatever else you prefer and is performant enough for your needs.)\nIf that isn't something to worry about for your case, then feel free to choose whatever you like (calculate on the client or on the server), using whatever approach you're most comfortable with - there isn't an objective way to choose between them.","Q_Score":0,"Tags":"javascript,python,math","A_Id":65228748,"CreationDate":"2020-12-10T04:56:00.000","Title":"Would it be better to use Javascript or Python for calculations on my website","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Can I actually run a unit test without mark 'load demo data' on my database? If yes, what are the consequences? What are the best practises for unit testing? Can you do testing on your actual database? I'm using odoo12 and now working on unit test2 for python codes. Please help me with this matter","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":341,"Q_Id":65230551,"Users Score":1,"Answer":"Yes you can run test without demo data. If you run odoo with --test-enable then odoo runs test for all installed and updated modules. (-u ...)\nI believe stock test are failing if you don't have demo data installed.\nNever run tests in production database it will leave marks on the database.\nI am running tests in isolation and without demo data. But i am running own tests only.","Q_Score":0,"Tags":"python,unit-testing,odoo,odoo-12","A_Id":65232690,"CreationDate":"2020-12-10T07:58:00.000","Title":"Unit Test without Demo Data in odoo","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've tried to google this but nothing helpful is coming up.\nBasically I have an src folder, and within it are two modules - app.py and app_test.py. In app, there are about 17 functions, and I've written a test for one of them in app_test. A very simple one that checks whether a filepath is being created properly.\nBut when I click on \"Run Tests\", what happens? My whole app.py code runs. I tried with UnitTests instead and get an error that a relative path doesn't exist...which is not referenced anywhere in app_test or the simple test that exists in there on its own. The same thing happens if I run pytest src\/app_test.py from the command line.\nI'm assuming I've set something up wrong but can't work out what!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":18,"Q_Id":65254268,"Users Score":0,"Answer":"hoefling solved it in the comments! probably super obvious to most but in case anybody else is struggling -\nProbably because you have code in app.py on script level that runs on import and should be put under if name == \"main\":","Q_Score":1,"Tags":"python-3.x,unit-testing,pytest,vscode-extensions","A_Id":65254831,"CreationDate":"2020-12-11T15:37:00.000","Title":"Why would pytest be running full code rather than tests when I click \"Run Tests\"?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a python project which involves real time communication between a Raspberry Pi device and Cloud server. After receiving data in the cloud server in real time, I have to display the output in a web application in real time as well. What is the correct way to do this ?\nAs web applications use socket.io (web sockets) and communication between Raspberry Pi and cloud can be done through a normal socket, I am confused on whether to proceed with normal socket or web socket.\nAny feedback will be greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":31,"Q_Id":65255354,"Users Score":0,"Answer":"It all depends on whether you want to work with the TCP stack or the HTTP stack, while TCP sockets have a smaller footprint, HTTP sockets have better support with high level libraries. If you don't need multiple simultaneous connections or high latency requirements, they are both identical, so go with the one that is easier to work with, ie the web socket.","Q_Score":0,"Tags":"python,sockets,websocket,raspberry-pi","A_Id":65257643,"CreationDate":"2020-12-11T16:48:00.000","Title":"What is the correct method to communicate in real time between Raspberry PI and Cloud Server and then display output in web app?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"The issue I am having with bcrypt is that the module can't be imported into the Pythonista app on iOS, which is where I need to run my script. What else would you recommend similar to bcrypt that can generate a random salt, and has something like the checkpw() function built-in to quickly validate salted passwords?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":60,"Q_Id":65271323,"Users Score":0,"Answer":"If pbkdf2 is natively available, I'd use that before trying to roll your own bcrypt. When its work factors are sufficiently large, it's still a solid choice when bcrypt or scrypt aren't available, and using it directly is safer than trying to recreate something else by hand.\nNot knowing more about your use case, a general recommendation: use pbkdf2 with a sufficiently large number of rounds to take about a half-second's worth of the upper end of the processor throughput of your target devices. This keeps the UX within tolerable wait times while still providing reasonable resistance to offline attack.\nI'd also recommend randomizing that number of rounds slightly over a range (like a thousand). For example, if you settled on 200,000 as having an acceptable 500ms delay, I'd randomly pick a value between 200,000 to 202,000 (or something like that) - whatever is needed to ensure that most users will have different rounds from each other (assuming that all user passwords might be aggregated into a single location that could be compromised and the hashes stolen). This is because some of the newer \"associative\" \/ \"correlation\" attacks only work well against a large set of hashes when all of the cost factors across that set of hashes are the same.\nLong term, also be sure that your code easily accepts a variable floor and ceiling for the number of rounds, so you can choose to increase your number of rounds over time as processors advance. (You could even get fancy and dynamically calculate the range of rounds based on the processor that the password is being created on, so that it's future ready without any additional intervention.)","Q_Score":0,"Tags":"python-3.x,hash,passwords,pythonista","A_Id":65272038,"CreationDate":"2020-12-13T00:38:00.000","Title":"What hashing algorithms would you recommend I use in Python3 that can generate a random salt, other than bcrypt?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have written integration tests for lambdas that hit the dev site (in AWS). The tests are working fine. Tests are written in a separate project that uses a request object to hit the endpoint to validate the result.\nCurrently, I am running all the tests from my local. Lambdas are deployed using a separate Jenkins job.\nHowever, I need to generate a code coverage report for these tests. I am not sure how I can generate the code coverage report as I am directly hitting the dev URL from my local. I am using Python 3.8.\nAll the lambdas have lambda layers which provide a database connection and some other common business logic.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":498,"Q_Id":65271425,"Users Score":1,"Answer":"Code coverage is probably not the right metric for integration tests. As far as I can tell you use integration tests to test your requirements\/use cases\/user stories.\nImagine you have an application with a shopping cart feature. A user has 10 items in that shopping cart and now deletes one of those items. Your integration test would make sure that after this operation only (the correct) 9 items are left in the shopping cart.\nFor this kind of testing it is not relevant which\/how much code was run. It is more like a black box test. You want to know that for a given \"action\" the correct \"state\" is created.\nCode coverage is usually something you use with unit tests. For integration tests I think you want to know how many of your requirements\/use cases\/user stories are covered.","Q_Score":1,"Tags":"python-3.x,aws-lambda,integration-testing","A_Id":65274825,"CreationDate":"2020-12-13T00:56:00.000","Title":"Code Coverage Report for AWS Lambda Integration test using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"So I was trying to host a simple python script on Heroku.com, but encountered this error. After a little googling, I found this on the Heroku's website: git, Heroku: pre-receive hook declined, Make sure you are pushing a repo that contains a proper supported app ( Rails, Django etc.) and you are not just pushing some random repo to test it out.\nProblem is I have no idea how these work, and few tutorials I looked up were for more detailed use of those frameworks. What I need to know is how can i use them with a simple 1 file python script. Thanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":65280380,"Users Score":0,"Answer":"Okay I got it. It was about some unused modules in requirements.txt, I'm an idiot for not reading the output properly \u200d\u2642\ufe0f","Q_Score":0,"Tags":"python,git,heroku","A_Id":65280586,"CreationDate":"2020-12-13T20:33:00.000","Title":"Git, heroku, pre-receive hook declined","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using gevent threads in my python flask application, rabbit mq messaging seems to be working fine when i am not monkey patching python thread but rabbit mq client pika stops listening when i do gevent monkey patch. would like to knows about this behaviour.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":143,"Q_Id":65287199,"Users Score":0,"Answer":"The cause of this issue is Pika and gevent.monkey_patch are not compatible when using rabbitmq.You will have to use gevent without patching system calls, if that is possible.\nIn case of if you are using threads with gevent then you might get this issue greenlet.error: cannot switch to a different thread\nThis is because of monkey patching.For this you can try use process instead of threads.","Q_Score":0,"Tags":"python,rabbitmq,monkeypatching,pika","A_Id":65322499,"CreationDate":"2020-12-14T10:16:00.000","Title":"gevent monkey patch stops rabbit mq listting messages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Can someone tell me what the difference between on_raw_message_delete()\/OnRawMessageDelete and on_message_delete()\/OnMessageDelete is?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":164,"Q_Id":65295903,"Users Score":2,"Answer":"on_raw_message_delete unlike on_message_delete it's called regardless of the state of the internal cache.\nLet's say you send a message, the bot caches it, but the bot suddenly restarts (the message won't be in the cache anymore), if you delete the message, on_message_delete won't be called, but on_raw_message_delete will.","Q_Score":0,"Tags":"python,discord.py","A_Id":65295973,"CreationDate":"2020-12-14T20:19:00.000","Title":"Difference between on_message_delete() and on_raw_message_delete()","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm building a bot that logs into zoom at specified times and the links are being obtained from whatsapp. So i was wondering if it is was possible to retrieve those links from whatsapp directly instead of having to copy paste it into python. Google is filled with guides to send messages but is there any way to READ and RETRIEVE those messages and then manipulate it?","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":10184,"Q_Id":65299796,"Users Score":0,"Answer":"You can read all the cookies from whatsapp web and add them to headers and use the requests module or you can also use selenium with that.","Q_Score":0,"Tags":"python,selenium,whatsapp","A_Id":68296269,"CreationDate":"2020-12-15T03:56:00.000","Title":"How do I read whatsapp messages from a contact using python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I will create python api using Django\nnow I trying to verify phone number using firebase authentication end send SMS to user but I don't know how I will do","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":435,"Q_Id":65322927,"Users Score":1,"Answer":"The phone number authentication in Firebase is only available from it's client-side SDKs, so the code that runs directly in your iOS, Android or Web app. It is not possible to trigger sending of the SMS message from the server.\nSo you can either find another service to send SMS messages, or to put the call to send the SMS message into the client-side code and then trigger that after it calls your Django API.","Q_Score":0,"Tags":"python,django,firebase-authentication","A_Id":65325134,"CreationDate":"2020-12-16T12:06:00.000","Title":"python api verified number usinf firebase","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I use remote-SSH to connect the server(ubuntu 20.04) and I find that if I click the button to install the module of python, it is only installed for one user.\nFor example:\n\nxxx is not installed, install?\n\nThen I find that the command in the terminal is :\npip install -U module_name --user\nSo I try to add the configuration in settings.json and install again.\n\"python.globalModuleInstallation\": true\nThe terminal has no response, however. Is this a bug?\nThough I can type the install command in terminal by myself, I still want to know if vscode can install the module globally by itself.\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":243,"Q_Id":65326646,"Users Score":0,"Answer":"To install it on the global level (for all users) you need to install it as the root user or as an administrator.\nIn short you must give the admin privileges.\nUse sudo for linux or run you VS code as admin.\nRunning the VScode as admin solved my issue. Give it a try.","Q_Score":0,"Tags":"python,visual-studio-code,vscode-settings,vscode-remote","A_Id":65326768,"CreationDate":"2020-12-16T15:50:00.000","Title":"python global module installation when using remote SSH extension","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have 3 scripts: the 1st and the 3rd are written in R, and the 2nd in Python.\nThe output of the 1st script is the input of the 2nd script, and its output is the input of the 3rd one.\nThe inputs and outputs are search keywords or phrases.\nFor example, the output of the 1st script is Hello, then the 2nd turns the word to olleH, and the 3rd one converts the letters to uppercase: OLLEH.\nMy question is how can I connect those scripts and let them run automatically, without my intervention, on AWS. What will be the commands? How can the output of the 1st script be saved, and play a role as the input of the 2nd one, etc.?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":44,"Q_Id":65338476,"Users Score":1,"Answer":"I have never used AWS so I'm unfamiliar with that, but this seems like a workflow management system would solve these issues. Take a look into snakemake or nextflow. With these tools you can easily (after you get used to it) do exactly what you describe. Run scripts\/tools that depend on each other sequentially (and also in parallel).","Q_Score":0,"Tags":"python,r,amazon-web-services,amazon-ec2","A_Id":65339243,"CreationDate":"2020-12-17T10:02:00.000","Title":"Running three \"connected\" scripts on AWS EC2","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"so I was preparing to take this year's USACO test, but noticed that there was a new rule in the about saying \"As an important change from last year, ALL SUBMISSIONS NOW USE STANDARD INPUT AND OUTPUT (e.g., cin and cout in C++) instead of file input and output. You therefore no longer need to open files to read your input or write your output. As another note, participants are advised to re-read the contest rules, as we have clarified some of the key contest regulations (in particular, that use of any previously-written code or code from external sources is NOT allowed).\" What does the Standard input and output mean? How would that work for python? Does that mean that you don't read in data from files and write them into other files?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":429,"Q_Id":65372955,"Users Score":0,"Answer":"input() and print() should suffice. It worked when I tried to do a USACO problem in python a while back.\nIf you want to read the input like a file, you can use sys.stdin and sys.stdout, but I find that it is unnecessary and probably just extra work.","Q_Score":0,"Tags":"python,input,output","A_Id":70571221,"CreationDate":"2020-12-19T18:08:00.000","Title":"USACO Contest New Rules with Standard Input and Output","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"It is about the following: I want to develop a tool where you click on a button \"Browse\", a Win Explorer window opens and there you can select a PDF file. After this is done, you click on \"Compress now\" and the file size is then automatically reduced so that you can send the PDF file, for example, via E-Mail (possibly also PDF files with images -> the quality of the images can also be degraded). Is there a way to implement such a tool with Python? If so how? Is there a specific module for it?\nI have already started to program the tool so that now I can click on \"Browse\" and select a PDF file, now I have to go to the compressing part. Does anyone have any ideas?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":413,"Q_Id":65374739,"Users Score":0,"Answer":"Absolutelly YES.\n\nTo do that you will need a gui library as tkinter or PyQt5(there are more).\nFor manipulations of pdf like splitting or merging pdfminer or PyPDF2.\nAs for ziping there is a non-third party library like zipfile where you can zip files.\nThen to make it a real app you can use cx_freeze or pyinstaller to make an exe!\n\nGood Luck!!!","Q_Score":0,"Tags":"python,pdf,compression,reduce,image-compression","A_Id":65374804,"CreationDate":"2020-12-19T21:41:00.000","Title":"Compress select PDF-Files with Python - Reduce the Size","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is the difference between pool.imap_unordered() and pool.apply_async()?\nWhen pool.imap_unordered() is preferred over pool.apply_async() or vice versa?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":111,"Q_Id":65376757,"Users Score":1,"Answer":"The result of calling pool.apply_async(f, (1, 2, 3, 4)) is that f(1, 2, 3, 4) will be called in some thread. The value returned by apply_async is an AsyncResult which you can use to wait on the result.\nThe result of calling pool.imap_unordered(f, (1, 2, 3, 4)) is an iterator. It returns the results of f(1), f(2), f(3) and f(4) is an unspecified order.","Q_Score":1,"Tags":"python,multiprocessing,pool","A_Id":65376858,"CreationDate":"2020-12-20T03:51:00.000","Title":"What is the difference between pool.imap_unordered() and pool.apply_async()?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to make a server info command and I want it to display the server name, boost count, boost members and some other stuff as well.\nOnly problem is I have looked at the docs and searched online and I cant find out how to find the boost information.\nI dont have any code as Ive not found any code to try and use for myself\nIs there any way to get this information?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2193,"Q_Id":65385757,"Users Score":4,"Answer":"Guild Name - guild_object.name\nBoost count - guild_object.premium_subscription_count\nBoosters, the people who boosted the server - guild_object.premium_subscribers\nIf your doing this in a command as I assume, use ctx.guild instead of guild_object. For anything further, you can re-read the docs as all of the above information is in it under the discord.Guild","Q_Score":1,"Tags":"python,discord.py","A_Id":65386320,"CreationDate":"2020-12-20T23:15:00.000","Title":"Get the number of boosts in a server discord.py","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So i have created a telegram bot in python.\nIt is run by its main.py file.\nIt is running on the server.\nBut sometimes it stops Due to internet or some minor issue.\nCan there be code which can automatically restart the the main.py code on server maybe using Deamonize library.\nIf Yes,please suggest how to do\n\nThank YOU","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":130,"Q_Id":65398617,"Users Score":1,"Answer":"If you are using Linux, you can use crontab\ncrontab is used for scheduling event","Q_Score":1,"Tags":"python,server,telegram-bot","A_Id":68671493,"CreationDate":"2020-12-21T19:10:00.000","Title":"Can we Automatically Restart the Telgram bot(Python) once it is stopped on server using Deamonize or something else?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want a security profiler for python. Specifically, I want something that will take as input a python program and tell me if the program tries to make system calls, read files, or import libraries. If such a security profiler exists, where can I find it? If no such thing exists and I were to write one myself, where could I have my profiler 'checked' (that is, verified that it works).\nIf you don't find this question appropriate for SO, let me know if there is another SE site I can post this on, or if possible, how I can change\/rephrase my question. Thanks","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":190,"Q_Id":65420594,"Users Score":3,"Answer":"Usually, python uses an interpreter called CPython. It is hard to say for python code by itself if it opens files or does something special, due a lot of python libraries and interpreter itself are written in C, and system calls\/libc calls can happen only from there. Also python syntax by itself can be very obscure.\nSo, by answering your suspect: I suspect this would need specific knowledge of the python programming language, it does not look like that, due it is about C language.\nYou can think it is possible to patch CPython itself. Well it is not correct too as I guess. A lot of shared libraries use C\/C++ code as CPython itself. Tensorflow, for example.\nGoing further, I guess it is possible to do following things:\n\npatch the compiler which compiles C\/C++ code for CPython\/modules, which is hard I guess.\njust use an usual profiler, and trace which files, directories and calls are used by python itself for operation, and whitelist them, due they are needed, which is the best option by my opinion (AppArmor for example).\nmaybe you can be interested in the patching of CPython itself, where it is possible to hook needed functions and calls to external C libraries, but it can be annoying due you will have to revise every added library to your project, and also C code is often used for performance (e.g. json module), which doesn't open too much things.","Q_Score":5,"Tags":"python-3.x,security","A_Id":65506767,"CreationDate":"2020-12-23T07:39:00.000","Title":"Finding or building a python security profiler","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am on an Ubuntu machine and I want to use python in my C code but when I include the Python.h header file, it shows a warning:\nPython.h: No such file or directory\nAny method for this. I have already tried to use:\nsudo apt-get install python3-dev and;\nsudo apt-get install python-dev\nBut it keeps showing error.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":32,"Q_Id":65428162,"Users Score":1,"Answer":"The Python.h file is not in the default compiler include path.\nAdd the output of pkg-config --cflags python3 to your compiler command line.\nNow the compiler will know where to find Python.h (and any dependencies it may have)","Q_Score":0,"Tags":"c,python-3.8,ubuntu-20.04","A_Id":65431056,"CreationDate":"2020-12-23T17:08:00.000","Title":"How to make Python.h file work in Ubuntu?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"atbswp is a software that help you automate all the mouse clicks and movements and keyboards keys so you can automate everything u do and repeat it or replay it\nand by using crontab you can schedule it so you can run automated sequence at specific time\nthe app extracts a python file\nand you run it inside the app or in terminal without the need of the app\nthe problem is\nwhen i run it in terminal it runs ok\nwhen i put it in crontab to run it doesnt run and i got errors in the crontab log file\ni really need help it is something amazing for everyone i think\nthis is the cron log error\nTraceback (most recent call last):\nFile \"\/home\/zultan\/bot1\", line 4, in \nimport pyautogui\nFile \"\/home\/zultan\/.local\/lib\/python3.8\/site-packages\/pyautogui\/init.py\", line 241, in \nimport mouseinfo\nFile \"\/home\/zultan\/.local\/lib\/python3.8\/site-packages\/mouseinfo\/init.py\", line 223, in \n_display = Display(os.environ['DISPLAY'])\nFile \"\/usr\/lib\/python3.8\/os.py\", line 675, in getitem\nraise KeyError(key) from None\nKeyError: 'DISPLAY'","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":95,"Q_Id":65436004,"Users Score":0,"Answer":"i found the solution for everybody\nput this\nin the crontab -e\nDISPLAY=:0\nXAUTHORITY=\/run\/user\/1000\/gdm\/Xauthority","Q_Score":0,"Tags":"python,linux,automation,cron,click","A_Id":65651053,"CreationDate":"2020-12-24T08:49:00.000","Title":"atbswp python file is not running on crontabs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to compare the differnt commits with two repos, for example Android_10.0_r2 and Android_11.0_r3\nthe changes are frequent and since Google merge inner code to AOSP, some commit even older than Android_10.0_r2 merged to Android_11.0_r3\uff0c I don't want to miss that from git log checking\nso I record all commit logs in both repos and select the different change_ids\/commit_ids.\nBut since the git log is too much in AOSP and it have 400+ repos, it runs 1 hour+ in my PC.\nAny idea that git command may have directly way for geting the different commit_ids between two repo?\nThe git diff with two repo dir shows diff of the files, since changelist is long, the commit message diff is more effective","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":348,"Q_Id":65438922,"Users Score":1,"Answer":"Every version of AOSP has its own manifest. Use repo sync -n -m \/path\/to\/manifest1.xml and repo sync -n -m \/path\/to\/manifest2.xml to fetch repositories' data of both. -n instructs repo to fetch data only and not checkout\/update the worktrees, which could be omitted if you want to see the real files.\nAnd then use repo diffmanifests \/path\/to\/manifest1.xml \/path\/to\/manifest2.xml to display the diff commits between 2 code bases. It has an option --pretty-format= which works like --pretty= in git log.\nHowever the output is still a bit rough. Another solution is making a script, in Python for example, to parse the 2 manifests and run git log or git diff to get the detailed information. It's much more flexible. To my experience, it won't take that long. Our code base has about 1500 repositories.","Q_Score":0,"Tags":"python,git,shell","A_Id":65444644,"CreationDate":"2020-12-24T13:24:00.000","Title":"git diff in two repos and got commit id list","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"How do I change the preset soundfonts for pygame or fluidsynth?\nIm using Python 3.7.3, pygame 2.0.1, fluidsynth 1.1.11 to play Midi files. When I call pygame.mixer.music.load(), I receive a few fluidsynth errors:\nfluidsynth: error: Unable to open file \"\/usr\/share\/sounds\/sf3\/FluidR3Mono_GM.sf3\" fluidsynth: error: Couldn't load soundfont file fluidsynth: error: Failed to load SoundFont \"\/usr\/share\/sounds\/sf3\/FluidR3Mono_GM.sf3\" fluidsynth: error: Unable to open file \"\/usr\/share\/sounds\/sf2\/TimGM6mb.sf2\" fluidsynth: error: Couldn't load soundfont file fluidsynth: error: Failed to load SoundFont \"\/usr\/share\/sounds\/sf2\/TimGM6mb.sf2\" \nThese soundfont files are not on my device. So I'd like to point fluidsynth to another soundfont. How do I change the preset soundfonts for fluidsynth inside PyGame?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":303,"Q_Id":65449321,"Users Score":0,"Answer":"I wasn't able to change the preset soundsfonts, but I was able to install the missing soundfonts.\napt-get install fluidr3mono-gm-soundfont for FluidR3Mono_GM.sf3\napt-get install timgm6mb-soundfont for TimGM6mb.sf2","Q_Score":0,"Tags":"python,pygame,midi,fluidsynth","A_Id":65450953,"CreationDate":"2020-12-25T15:14:00.000","Title":"PyGame change preset soundfont","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to setup lanelet2 package from their git repo. When i try to run the tutorial package on my system running Ubuntu 20.04LTS, i am getting the above error. I tried the same on a python shell and running the command ' import lanelet2', it still throws the same error.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1270,"Q_Id":65487367,"Users Score":-1,"Answer":"The issue was resolved by one of my colleague. It was mainly caused due to libboost version mismatch from anaconda in my setup. Had to uninstall all libboost packages along with anaconda at first. Then installed libboost again. This resolved the error.","Q_Score":2,"Tags":"boost,boost-python","A_Id":65623864,"CreationDate":"2020-12-29T04:40:00.000","Title":"Lanelet2: ImportError: \/usr\/lib\/x86_64-linux-gnu\/libboost_python38.so.1.71.0: undefined symbol: _Py_tracemalloc_config","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a project that needs to do the following:\n\n[C++ Program] Checks a given directory, extracts all the names (full paths) of the found files and records them in a vector.\n[C++ Program] \"Send\" the vector to a Python script.\n[Python Script] \"Receive\" the vector and transform it into a List.\n[Python Script] Compares the elements of the List (the paths) against the records of a database and removes the matches from the List (removes the paths already registered).\n[Python Script] \"Sends\" the processed List back to the C++ Program.\n[C++ Program] \"Receives\" the List, transforms it into a vector and continues its operations with this processed data.\n\nI would like to know how to send and receive data structures (or data) between a C ++ Script and a Python Script.\nFor this case I put the example of a vector transforming into a List, however I would like to know how to do it for any structure or data in general.\nObviously I am a beginner, that is why I would like your help on what documentation to read, what concepts should I start with, what technique should I use (maybe there is some implicit standard), what links I could review to learn how to communicate data between Scripts of the languages \u200b\u200bI just mentioned.\nAny help is useful to me.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":131,"Q_Id":65488962,"Users Score":0,"Answer":"If the idea is to execute the python script from the c++ process, then the easiest would be to design the python script to accept input_file and output_file as arguments and the c++ program should write the input_file, start the script and read the output_file.\nFor simple structures like list-of-strings, you can simply write them as text files and share, but for more complex types, you can use google-protocolbuffers to do the marshalling\/unmarshalling.\nif the idea is to send\/receive data between two already stared process, then you can use the same protocol buffers to encode data and send\/receive via sockets between each other. Check gRPC","Q_Score":1,"Tags":"python,c++","A_Id":65489333,"CreationDate":"2020-12-29T07:50:00.000","Title":"How to send and receive data (and \/ or data structures) from a C ++ script to a Python script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The Ruby 3.0 release has introduced Ractors and the way they're represented along their examples, brings Python's MultiProcessing module into mind.\nSo...\n\nAre Ruby's Ractors just multiple processes in disguise and the GIL is still ruling over the threads?\n\nIf they aren't, could you provide an example in which Ractors have the upper hand against MultiProcessing in both speed and communication latency?\n\nCan Ractors be as fast as C\/C++ threads and with low latency?\n\n\nThanks","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":153,"Q_Id":65505576,"Users Score":4,"Answer":"Are Ruby's Ractors just multiple processes in disguise and the GIL is still ruling over the threads?\n\n\nThe Ractor specification does not prescribe any particular implementation strategy. It most certainly does not prescribe that an implementor must use OS processes. In fact, while that would be a pretty simple implementation because the OS does all the hard work for you, it would also be a pretty stupid implementation because Ractors are meant to be light-weight, which OS processes are typically not.\nSo, I expect that every implementor will choose their own most efficient implementation strategy. For example, I would expect TruffleRuby's and JRuby's implementation to be based on something like Kilim or Project Loom, Opal's implementation to be based on WebWorkers, Realms, and Promises, Artichoke's implementation to be based on Actix, Riker, or Axiom, and maybe MRuby's implementation might even be based on OS processes because of MRuby's focus on simplicity.\nRight at this very moment, there does not exist any production-ready implementation of Ractors. In fact, there cannot be a production-ready implementation of Ractors, because the Ractor specification itself is still experimental, and thus not finalized.\nThe only implementation in existence right now is Koichi Sasada's original prototype which currently ships with YARV 3.0.0. This implementation does not implement Ractors as processes, it implements them as OS threads. YARV does not have a GIL, but it does have a per-Ractor GVL. So, only one thread of a Ractor can run at the same time, but multiple Ractors can each run one thread at the same time.\nHowever, this is not a very optimized implementation, only a prototype. I would expect TruffleRuby's or JRuby's implementation to not have any sort of global lock. They never had one before, and Ractors don't share any data, so there simply is nothing to lock in the first place.\n\n\nIf they aren't, could you provide an example in which Ractors have the upper hand against MultiProcessing in both speed and communication latency?\n\n\nThis comparison doesn't make much sense. First of all, Ractor is a specification with potentially multiple implementations, whereas to my understanding, Python's multiprocessing module is simply a way of starting multiple Python interpreters.\nSecondly, Ractors are a language feature with specific language semantics.\n\n\nCan Ractors be as fast as C\/C++ threads and with low latency?\n\n\nIt's not quite clear what you mean by this. C doesn't have threads, so asking about C threads doesn't make sense. C++ has threads, but just like Ractors, they are simply a specification with multiple possible implementations. It will simply depend on the particular implementation of Ractors and C++ threads.\nIt is certainly possible to implement Ractors using threads. The current YARV prototype is proof of that.","Q_Score":1,"Tags":"python,ruby,multithreading,multiprocessing,gil","A_Id":65506442,"CreationDate":"2020-12-30T10:36:00.000","Title":"Are Ruby Ractors the Same as Python's MultiProcessing module?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I use GMail and send a message to myself it appears unread in my inbox.\nIf I send a message via the GMail API using a python script, the message is sent up it only appears in \"All Mail\" and \"Sent\" and is marked as read.\nI have checked my filters and there is nothing there that would be doing this (and I would expect filters to apply consistently across both of the above use-cases).\nAny thoughts?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":170,"Q_Id":65531150,"Users Score":0,"Answer":"Looks like one of those \"Google\" things.\nWaited an hour - no changes to the code but the behaviour is now as expected !","Q_Score":0,"Tags":"python,gmail-api","A_Id":65532786,"CreationDate":"2021-01-01T15:47:00.000","Title":"GMail-API (Python) EMail Sent To Self - By Passes Inbox","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do I get the user\/member object in discord.py with only the Name#Discriminator? I searched now for a few hours and didn't find anything. I know how to get the object using the id, but is there a way to convert Name#Discriminator to the id?\nThe user may not be in the Server.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1332,"Q_Id":65533874,"Users Score":0,"Answer":"There's no way to do it if you aren't sure they're in the server. If you are, you can search through the servers' members, but otherwise, it wouldn't make sense. Usernames\/Discriminators change all the time, while IDs remain unique, so it would become a huge headache trying to implement that. Try doing what you want by ID, or searching the server.","Q_Score":1,"Tags":"python,discord.py","A_Id":65534406,"CreationDate":"2021-01-01T21:31:00.000","Title":"Discord.py get user with Name#0001","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm developing a matchmaking bot for discord. I read through the documentation and looked through stack exchange, I can't find relevant information on this. I'm trying to eliminate clutter and make it easier for a users to accept and decline a matchmaking request. The bot would listen for a \"!match @user\" and handle the event. I only want the @user to see and accept it and the user that sent the message to see it (obviously). Right now, I believe it's not possible unless it assigns a secret role and deletes these roles after they are finished; this wouldn't be ideal though. Any information or forward to a post, that would help tremendously. Thanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2595,"Q_Id":65541872,"Users Score":0,"Answer":"You can not currently hide messages for any specific user\/role.\nYou can try 2 approaches:\n\nSend Message in User DMs\nMake a channel and set it permissions for a specific role and assign that role to the user","Q_Score":0,"Tags":"python,discord.py","A_Id":65547946,"CreationDate":"2021-01-02T17:13:00.000","Title":"discord.py: Hide messages from all other users, but the @mention user","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have audio bytes that are AAC encoded and would like to transcode them to a bytearray in Python in WAV format (PCM signed 16-bit little-endian) without calling ffmpeg to do so. How to do this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":174,"Q_Id":65547693,"Users Score":0,"Answer":"I do that with soundfile library which is very light and portable.","Q_Score":1,"Tags":"python,wav,aac","A_Id":69177722,"CreationDate":"2021-01-03T07:51:00.000","Title":"Convert AAC bytes to WAV bytes in Python without ffmpeg?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want the person who used the command to be able to delete the result. I have put the user's ID in the footer of the embed, and my question is: how do I get that data from the message where the user reacted to.\nreaction.message.embed.footer doesn't work. I currently don't have code as I was trying to get that ID first.\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":114,"Q_Id":65549860,"Users Score":1,"Answer":"discord.Message object has no attribute embed, but it has embeds. It returns you a list of embeds that the message has. So you can simply do: reaction.message.embeds[0].footer.","Q_Score":0,"Tags":"python,python-3.x,discord.py,discord.py-rewrite","A_Id":65549978,"CreationDate":"2021-01-03T12:30:00.000","Title":"Get embed footer from reaction message","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm looking for a way to make the bot screen share a website. And the link to be a parameter after the command. (To clarify: The website starting URL doesn't change. Only a token that's given after the starting URL. For example: \"https:\/\/websitehere.com\/branch\/ 'token goes here'","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2426,"Q_Id":65560530,"Users Score":1,"Answer":"Bots Can't Screenshare! Discord Bot API Do Not Support It Yet!","Q_Score":1,"Tags":"python,discord,discord.py","A_Id":65563382,"CreationDate":"2021-01-04T09:45:00.000","Title":"Is there a way ot make a discord bot screen share a website","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I am developing a Bot using discord.py and I want to get all permissions the Bot has in a specific Guild. I already have the Guild Object but I don't know how to get the Permissions the Bot has. I already looked through the documentation but couln't find anything in that direction...","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":111,"Q_Id":65571220,"Users Score":1,"Answer":"From a Member object, like guild.me (a Member object similar to Bot.user, essentially a Member object representing your bot), you can get the permissions that member has from the guild_permissions attribute.","Q_Score":0,"Tags":"python,discord.py","A_Id":65571368,"CreationDate":"2021-01-04T23:27:00.000","Title":"discord.py get all permissions a bot has","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to store the state of the python interpreter embedded in a C program (not the terminal interpreter or a notebook) and restore it later resuming execution were it left off?\nOther questions and answers I found about this topic evolved around saving the state of the interactive shell or a jupyter notebook or for debugging. However my goal is to freeze execution and restoring after a complete restart of the program.\nA library which achieves a similar goal for the Lua Language is called Pluto, however I don't know of any similar libraries or built-in ways to achieve the same in an embedded python interpreter.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":205,"Q_Id":65573489,"Users Score":1,"Answer":"No, there is absolutely no way of storing the entire state of the CPython interpreter as it is C code, other than dumping the entire memory of the C program to a file and resuming from that. It would however mean that you couldn't restart the C program independent of the Python program running in the embedded interpreter. Of course it is not what you would want.\nIt could be possible in a more limited case to pickle\/marshal some objects but not all objects are picklable - like open files etc. In general case the Python program must actively cooperate with freezing and restoring.","Q_Score":1,"Tags":"python,c,python-embedding","A_Id":65573874,"CreationDate":"2021-01-05T04:59:00.000","Title":"Save and restore python interpreter state","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Hello and sorry for this basic question since I am new to programming.\nI have a Sony FCB IP camera that works on Visca protocol. I tried socket programming in python to send visca commands but had no idea what i was doing.\nI need to access the ptz port of my IP camera and start sending visca commands to it through my python code. How can I establish a connection between local system and the camera and ensure that commands are sent through TCP protocol?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":97,"Q_Id":65574483,"Users Score":0,"Answer":"You can ask for the .dll\/.so from OEM, in case you are stuck. ;)","Q_Score":1,"Tags":"python","A_Id":65590956,"CreationDate":"2021-01-05T07:08:00.000","Title":"Can I access an IP Camera PTZ port through socket programming in Python and send hex bytes to it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Updating the question.\nI am developing a command-line tool for a framework.\nand I am struggling with how to detect if the current directory is a project of my framework.\nI have two solutions in mind.\n\nsome hidden file in the directory\ndetect the project structure by files and folders.\n\nWhat do you think is the best approach?\nThank you,\nShay\nThank you very much","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":117,"Q_Id":65582283,"Users Score":0,"Answer":"In my opinion, a good idea would be to either have a project directory structure that you can use a signature for the project\/framework, that you can use within the tool as a list of signature-like structures, for example\nPROJECT_STRUCTURE_SIGNATURES = [ \"custom_project\", \"custom_project\/tests\", \"custom_project\/build\", \"custom_project\/config\", \"config\/environments\" ] and then just check if any(signature in os.getcwd() for signature in PROJECT_STRUCTURE_SIGNATURES).\nif the project structure is not too complex, I suppose that would be a start in order to identify the requirements that you're looking for.\nHowever, if this is not the case, then I suppose a dictionary-like structure that you could use to traverse the key-value pairs similar to the project's file structure and check the current directory against those would be a better idea, where if none of the elements from the nested dictionary traversal matches, then the directory is not within the project structure.","Q_Score":0,"Tags":"python,architecture","A_Id":67074897,"CreationDate":"2021-01-05T15:58:00.000","Title":"Detect if folder content match file and folders pattern","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am currently using Airflow to run a DAG (say dag.py) which has a few tasks, and then, it has a python script to execute (done via bash_operator). The python script (say report.py) basically takes data from a cloud (s3) location as a dataframe, does a few transformations, and then sends them out as a report over email.\nBut the issue I'm having is that airflow is basically running this python script, report.py, everytime Airflow scans the repository for changes (i.e. every 2 mins). So, the script is being run every 2 mins (and hence the email is being sent out every two minutes!).\nIs there any work around to this? Can we use something apart from a bash operator (bare in mind that we need to do a few dataframe transformations before sending out the report)?\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":170,"Q_Id":65585318,"Users Score":0,"Answer":"Just make sure you do everything serious in the tasks. It in the python script. The script will be executed often by scheduler but it should simply create tasks and build dependencies between them. The actual work is done in the 'execute' methods of the tasks.\nFor example rather than sending email in the script you should add the 'EmailOperator' as a task and the right dependencies, so the execute method of the operator will be executed not when the file is parsed by scheduler, but when all dependencies (other tasks ) will complete","Q_Score":0,"Tags":"python,airflow","A_Id":65586460,"CreationDate":"2021-01-05T19:26:00.000","Title":"How do I stop Airflow from triggering my python scripts?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"can I run 64-bit Python3 on Raspberry Pi 4B with 64-bit Raspbian OS aarch64?\nIf it is not possible, is installing 64-bit Debian\/etc. on RPi4 worth it? For example in performance, ...\nThank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1109,"Q_Id":65599461,"Users Score":1,"Answer":"Yes of course you can. It is pre-installed.","Q_Score":0,"Tags":"python-3.x,raspberry-pi,64-bit,raspberry-pi4","A_Id":65647471,"CreationDate":"2021-01-06T16:22:00.000","Title":"Raspbian OS run Python3 64-bit","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm making a python discord bot, and I don't want the bot to care about the command being in lower\/upper case.\nHow can I do that without aliases=['clear', 'Clear']?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":314,"Q_Id":65605569,"Users Score":3,"Answer":"Use the lower method. \"Clear\".lower() returns \"clear\".","Q_Score":0,"Tags":"python,discord,discord.py,discord.py-rewrite","A_Id":65605599,"CreationDate":"2021-01-07T01:42:00.000","Title":"How to make discord.py bot case-insensitive?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The following script in crontab is not executed, but it can be executed in the terminal\nCommand: * * * * * \/usr\/bin\/php artisan edit > \/dev\/null 2>&1\nError: [Errno 2] No such file or directory: 'ffprobe\\","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":25,"Q_Id":65608236,"Users Score":0,"Answer":"I think this is not a crontab issue, it says 'ffprobe' as No such file or directory.\nIn your PHP code if you are using 'ffprobe' directory, try giving this as absolute path and not a relative one. I mean the full path and not partial one. Say for example something like \/home\/myuser\/phpcodes\/ffprobe\/ and not just ffprobe.\nPlease try and let me know if this helps.","Q_Score":0,"Tags":"python,macos,cron","A_Id":65608818,"CreationDate":"2021-01-07T07:32:00.000","Title":"The following crontab does not run, but it can be run in the terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a simple GitLab CI pipeline that originally only required Python (>=3.5). The code I've been working on is just to test a prototype, so after realising there are some R libraries that already implement some of the required steps, I began using rpy2 which means that now the CI requires both Python and R.\nFrom what I understand, GitLab CI takes the images from Docker Hub but I was unable to find an image just containing both languages (in the versions that I require). I guess my option is to use the image of an OS and run the commands to install both languages in the pipeline, but that may require a lot of space, is there a simple easy way to achieve what I want?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":89,"Q_Id":65616421,"Users Score":1,"Answer":"Use echo \"Hello world\" to run the containers.","Q_Score":0,"Tags":"python,r,docker,gitlab","A_Id":65616765,"CreationDate":"2021-01-07T16:39:00.000","Title":"How to use Python and R in GitLab CI?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a simple GitLab CI pipeline that originally only required Python (>=3.5). The code I've been working on is just to test a prototype, so after realising there are some R libraries that already implement some of the required steps, I began using rpy2 which means that now the CI requires both Python and R.\nFrom what I understand, GitLab CI takes the images from Docker Hub but I was unable to find an image just containing both languages (in the versions that I require). I guess my option is to use the image of an OS and run the commands to install both languages in the pipeline, but that may require a lot of space, is there a simple easy way to achieve what I want?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":89,"Q_Id":65616421,"Users Score":0,"Answer":"What I did was to use the image 'rpy2\/rpy2' which contains R and Python 2, and run apt install python3. Probably not the best option, but it works.","Q_Score":0,"Tags":"python,r,docker,gitlab","A_Id":65616700,"CreationDate":"2021-01-07T16:39:00.000","Title":"How to use Python and R in GitLab CI?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've got a bluetooth RGB bulb that I want to use for notifications in discord. It seems that following standard guides I would need to get an admin to add a bot account to each discord I wanted this functionality in.\nIs there a way to get access to messages accessible in my main account without getting another account\/bot added? I only need to be able to read out the messages so I can parse them and trigger RGB stuff.\nI would prefer to do this in python if possible but other solutions are fine if need be.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":59,"Q_Id":65657004,"Users Score":0,"Answer":"Self bots are against discord's TOS.\nYou can try using on_message(message) and using that to parse the message.content","Q_Score":0,"Tags":"python,discord","A_Id":65657053,"CreationDate":"2021-01-10T18:34:00.000","Title":"How to access discord messages from main account instead of bot account","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to access the settings for a Twitter user using the api, specifically the notification filters.\nFor example I would like to build a code that turns on these filters or turns them off, for example the \"only see notifications from those you follow\/follow you\"\nI don't see any documentation on this or through Tweepy either. Is this possible?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":100,"Q_Id":65670459,"Users Score":0,"Answer":"No, there's no API feature for this.","Q_Score":0,"Tags":"twitter,tweepy,twitterapi-python","A_Id":65671288,"CreationDate":"2021-01-11T16:09:00.000","Title":"Can I access the Twitter notification filters from the api?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to run a python script inside php file, the problem is i can't pass the file as an argument\nsomething like this\n$a =\"python \/umana\/frontend\/upload\/main.py 'filename' \";\n$output =shell_exec($a);\nThe real problem is, the file is not opening in python script.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":129,"Q_Id":65680051,"Users Score":1,"Answer":"It's solved\n$a =\"python-path C:\/python program path '$file_uploaded_path_as_param' \";\n$output =shell_exec($a);\nwe want to add the python path before python script.","Q_Score":0,"Tags":"python,php,yii","A_Id":65697404,"CreationDate":"2021-01-12T08:06:00.000","Title":"Run python script inside php and pass file as a parameter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am stuck on the .wav file extension, I used \"gtts\" method to convert text into the speech and save the file and it is working perfectly but the problem is \"gtts\" only support the .mp3 extension but I need the output file with .wav extension.\nSo I am question is, if any function like \"gtts\" to convert text into speech and save the file with .wav extension?\nor anyone who already done work on this module. Please share your opinion. Thanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":54,"Q_Id":65713613,"Users Score":0,"Answer":"Thank you for sharing the link, it is now working after entering the environmental path of the lib.","Q_Score":1,"Tags":"python","A_Id":65714020,"CreationDate":"2021-01-14T04:54:00.000","Title":"Is there any function in which .wav file will generate","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just want to invoke a grpc method and exit from the process, I don't need the response back to the client.\nMy use case is like.\nAWS Lambda will invoke only invoke multiple grpc request and exit without waiting for the response","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":456,"Q_Id":65731855,"Users Score":0,"Answer":"gRPC on-the-wire does not support fire-and-forget RPCs. The client is free to ignore the results and the server can respond immediately before actually processing the request.","Q_Score":1,"Tags":"architecture,grpc,grpc-python","A_Id":65816083,"CreationDate":"2021-01-15T07:11:00.000","Title":"Sending grpc Requests without waiting for response?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am requesting an API which sometimes gives a string that contain \"*\" characters.\nI have to post the output on discord, where ** makes the text bold.\nI want to see if a string contains any * and if so put a markdown \\ escape character in front of the *.\nHow can I accomplish this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":48,"Q_Id":65742637,"Users Score":1,"Answer":"As @Random Davis rightly pointed out in the comments, you can use str.replace(\"*\",\"\\*\")and it will replace all the * occurrence.","Q_Score":0,"Tags":"python,python-3.x","A_Id":65742846,"CreationDate":"2021-01-15T19:45:00.000","Title":"If character in string put escape character \"\\\" in front of the found character","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have this problem when I try to import Pycryptodome.\nTraceback (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\nAnd then:\nImportError: DLL load failed while importing _AES: %1 is not a valid Win32 application.\nI'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!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":141,"Q_Id":65743181,"Users Score":0,"Answer":"oh silly me, need to install pycryptodome 3.8.2. Dumb mistake lol.","Q_Score":0,"Tags":"python,importerror,pycryptodome","A_Id":65744241,"CreationDate":"2021-01-15T20:33:00.000","Title":"Pycryptodome: ImportError: DLL load failed while importing _AES: %1 is not a valid Win32 application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to build a telegram bot. In that I need to know if anyone is registered with a email address. I checked the documentation but didn't found any answer. If it is possible with telegram core api please feel free to answer.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":104,"Q_Id":65746922,"Users Score":0,"Answer":"There is no possibility to register in Telegram using anything else except phone number.\nYou can NOT use email, social auth or any other kind of tokens.\nOnly phone number.","Q_Score":0,"Tags":"python,python-3.x,api,telegram,telegram-bot","A_Id":65761409,"CreationDate":"2021-01-16T06:02:00.000","Title":"How to programmatically check if a email is registered in the Telegram?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to create an AWS lambda function that help user collect data from a website (using selenium and headless-chromium). The website requires sms code verification during login so I need to get it from the user and pass it back to the AWS Lambda function\nthe flow will be:\n\nusername & password send to lambda function\nlambda function start, chromium auto login with username & password\nwaiting for sms code from user\nuser enter sms code, code pass to lambda function\nlambda function continue\n\nis it possible to do so? like the input() function when running python locally\nthanks!!\n*first question in stackoverflow! let me know if anything doesn't make sense","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":772,"Q_Id":65762905,"Users Score":0,"Answer":"We need at least two Lambdas.\nSecond Lambda:\n\nTakes OTP & UserId as input.\nWrites a record to DynamoDb with userId and OTP.\n\nFirst Lambda:\n\nLambda is invoked with user Id and password\nStart a selenium browser session.\nLogin and write a record to Dynamo.\nKeep checking Dynamo every second for an entry for userId with OTP in Dynamo.\nSet a timeout and complete Login Process.\n\nMain disadvantage of this approach is we have first Lambda running for entire time of login. But if we can't break the login and OTP process, I don't see another way.\nMay be having a ECS Fargate task instead of Lambda function may save some cost as we can easily run multiple selenium browser sessions in single ECS Task.","Q_Score":1,"Tags":"python,amazon-web-services,selenium,aws-lambda,headless-browser","A_Id":65763580,"CreationDate":"2021-01-17T16:07:00.000","Title":"AWS Lambda: Python user input possible?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"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 ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":65789961,"Users Score":0,"Answer":"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.","Q_Score":1,"Tags":"java,python","A_Id":65792459,"CreationDate":"2021-01-19T10:47:00.000","Title":"Run python script in Android aplication","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"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?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":410,"Q_Id":65803490,"Users Score":0,"Answer":"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).\nNote: Bot cannot delete a message if it was sent more than 48 hours ago.","Q_Score":0,"Tags":"python,telegram,telegram-bot,python-telegram-bot","A_Id":65804336,"CreationDate":"2021-01-20T05:18:00.000","Title":"Telegram Bot delete sent photos?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"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?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":410,"Q_Id":65803490,"Users Score":0,"Answer":"It's currently possible in Telegram API, not the Bot API unfortunately. It's a shame :(","Q_Score":0,"Tags":"python,telegram,telegram-bot,python-telegram-bot","A_Id":65803544,"CreationDate":"2021-01-20T05:18:00.000","Title":"Telegram Bot delete sent photos?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to build a Python script which should go to web every day at 1 pm, do some job (some web-scraping) and save a result to a file.\nIt will be deployed on a Linux server.\nI am not sure what technology to use to run it on schedule.\nWhat comes to mind:\n\nRun it with a cron job scheduler. Quick and dirty. Why bother with any other methods?\n\nRun it as a service with a systemd \/ systemctl (I never did this but I just know there is such possibility and I have to google for a specific implementation). Is this something to be considered as best practice?\n\nOther methods?\n\n\nSince, I never did this, I don't know the pros and cons of every method. May be it's just a one way of doing this properly? Please share your experience.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":94,"Q_Id":65816103,"Users Score":0,"Answer":"I use cron job to run a schedule task it works awesome with me.","Q_Score":0,"Tags":"python,automation,systemd,remote-server,cron-task","A_Id":65817101,"CreationDate":"2021-01-20T19:12:00.000","Title":"Running Python on remote server on schedule","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I was trying to figure out without success how I could exclude the dev\/test dependencies of 3rd party Python modules from the BOM generated by CycloneDX. There seems to be no straightforward way to do this. Any recommendation on how to best approach this would be highly appreciated!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":65859032,"Users Score":0,"Answer":"This is unfortunately not supported currently. But would make a great issue :)","Q_Score":0,"Tags":"python,external-dependencies","A_Id":67225494,"CreationDate":"2021-01-23T12:10:00.000","Title":"CycloneDX Exclude Python Dev\/Test Dependencies","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to code a timed ban or mute, but with that I can restart my bot. Is there a nice libary or anyone has an idea to code it?\nThank you very much!\nI code with discordpy cogs","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":75,"Q_Id":65860119,"Users Score":0,"Answer":"If it involves restarting your bot, then you cannot use your RAM to store your data but you need to use your Hard Disk for that. When your bot is running, it is storing its data inside the RAM and that's why you can re-use them while the bot is online. Once it goes offline or gets restarted, all the data are removed from the RAM because the program is shut down.\nTo store those data within the Hard Disk, you need a database. For such small projects, you can use JSON or SQLite. If the project scales, you can move to another SQL like MySQL that will handle a more complex and heavy database.\nTo make a bot that can do a timed message:\n\nYou need to store the data of when the message is going to be sent on your hard disk (database), then use that data to send that message. For example, you want to send \"hello\" in 1 day. That basically means that you want to send it at 8\/7\/2021 6:19 PM (it's 7\/7\/2021 6:19 PM right now). So, you store 8\/7\/2021 6:19 PM as a piece of data of when the bot is going to send the message.\nThen you make the bot compare the current time with the time that you saved on your database. If it is greater, then it will send the message and delete the data from the database.\nYou can use the same technique with timed ban, role and everything else.\n\nFrom a technical standpoint, you can use Discordpy for all the Discord stuff, datetime to check the time, JSON (or SQlite3) for the database.","Q_Score":1,"Tags":"python,discord,discord.py-rewrite","A_Id":68290575,"CreationDate":"2021-01-23T14:07:00.000","Title":"Discordpy timed message or ban or role, WITH bot restart | discordpy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am making a discord bot in python. At one point in coding the bot, it stopped updating, it kept using old code. Then I realized the bot never stopped. I kicked it and reinvited it, but the problem did not go away.\nDoes anybody know why?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":121,"Q_Id":65879004,"Users Score":0,"Answer":"Kicking will not fix it, it's a problem some code compliers may have, or just the concurrent running version is still running.\nEditors like sublime can do this problem if the existing program has not been stopped.\nThis can be easily fixed by going back into Discord's developer portal and \"regenerate token\". After this, update with the same new token in your code with running the bot token. This will force terminate any builds running.","Q_Score":0,"Tags":"python,discord,discord.py","A_Id":65879050,"CreationDate":"2021-01-25T04:30:00.000","Title":"Discord.py bot stays active even after code is stopped","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am making a discord bot in python. At one point in coding the bot, it stopped updating, it kept using old code. Then I realized the bot never stopped. I kicked it and reinvited it, but the problem did not go away.\nDoes anybody know why?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":121,"Q_Id":65879004,"Users Score":0,"Answer":"It's normal, after about 30 seconds or so, the bot should stop","Q_Score":0,"Tags":"python,discord,discord.py","A_Id":65879030,"CreationDate":"2021-01-25T04:30:00.000","Title":"Discord.py bot stays active even after code is stopped","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to set my Pycharm run\/debug configuration for robot framework tests. I would like to create configuration, where I can run any robot file in any directory with run\/debug button.\n$FileName$ works when set to Parameters field\nBut the working directory works only when the path is real. I've tried $FileDir$ and $FilePath$. None of those worked.\nNote: I know about File->Settings->External Tools option, but I believe, there is also way via run\/debug configuration","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":70,"Q_Id":65903680,"Users Score":0,"Answer":"Ok, so setting it to directory of script worked. So If you select script in first field, then this folder is automatically set for you. It worked for me like this.","Q_Score":0,"Tags":"python,pycharm,robotframework","A_Id":65934187,"CreationDate":"2021-01-26T14:56:00.000","Title":"Can I set working directory in pycharm run\/debug configuration witch something like $FileDir$?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a Python script.\nA particular method takes a text file and may creates0-3 files.\nI have sample text files, and the expected output files for each.\nHow would I set up this script for testing?\nI use unittest for testing functions that do not have file i\/o currently.\n\nSampleInputFile1 -> expect 0 files generated.\nSampleInputFile2 -> expect 1 files generated with specific output.\nSampleInputFile3 -> expect 3 files generated, each with specific output.\n\nI want to ensure all three sample files, expected files are generated with expected content. Testing script question","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":69,"Q_Id":65906695,"Users Score":0,"Answer":"maybe I dont understand the question but you use a program to divide a text into different subtexts?\nWhy dont you use train_test_split from sklearn to get the test and training files,\nsklearn.model_selection.train_test_split(*arrays, test_size=None, train_size=None, random_state=None, shuffle=True, stratify=None)","Q_Score":0,"Tags":"python,testing,io","A_Id":65907109,"CreationDate":"2021-01-26T17:57:00.000","Title":"How do I test Python with test files and expected output files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a BitBucket repo which holds code for multiple lambda functions in separate folders. In two of the folders (belonging to separate lambdas), I'm using a same Python function name which has different number of arguments on different lambdas.\nThis is being identified by Sonar as a bug.\nHow do I handle my lambdas in such a scenario? Changing the name of the function in either of the lambdas is difficult to implement as I have references to this function from multiple places. Can I edit my Sonar ruleset to accomodate these cases?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":83,"Q_Id":65917883,"Users Score":0,"Answer":"Personally I would do a separate SQ project for each lambda, so that SQ does not mix up code belonging to different projects. My own best practice is that SQ should reflect the code that you build, not the code that you store (i.e. create SQ projects by projects outcome, not by Git repositories).","Q_Score":0,"Tags":"python,python-3.x,aws-lambda,sonarqube,sonarqube-scan","A_Id":65918693,"CreationDate":"2021-01-27T11:08:00.000","Title":"Handling same function names in multiple AWS Lambdas","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Raspberry Pi 4 running a NodeRed server.\nThis Pi has no mouse or keyboard, but it does have a regular HDMI display.\nIt runs a minimal Xorg setup and a Midori browser connects as a client to the NodeRed server itself.\nThe user can interact with NodeRed through some buttons wired to the GPIO.\nSo far so good.\nI set up a little python script which starts a screensaver (feh) when the user is idle for a while (xprintidle).\nNow I would like to stop the screensaver when the user presses a button.\nI tried to bind those GPIO pins with the RPi.GPIO library, but it says that they're already bound to something else (NodeRed) and the even won't fire when the button is pressed.\nI tried to look at \/sys\/class\/gpio\/ but I don't see those exports changing when I click the button, and besides, I would have to use a bash script which constantly poll those sys-files. I'd rather use events\/interrupts.\nHow would you go about achieving this?\nIs there some lower system way of getting interrupts from the GPIO?\nMaybe is it possible to have NodeRed kill Feh (or feed a fake user input to xorg), somehow?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":65969177,"Users Score":0,"Answer":"maybe I gave up too soon. I later realized that it's not that difficult to manage the host system processes with NodeRed.\nThat way I was also able to intercept all the button pushes and make sure that the screensaver is not running, before performing the required action.","Q_Score":0,"Tags":"python,interrupt,node-red,gpio,xorg","A_Id":65971138,"CreationDate":"2021-01-30T14:36:00.000","Title":"Reset Xorg idle time upon RPi GPIO event, maybe through NodeRed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to implement a simple source code that DROPs all RST packets that come into the computer using Python. What should I do?\nLinux 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.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":31,"Q_Id":65970822,"Users Score":0,"Answer":"Dropping RST packets is a function of the networking firewall built into your operating system.\nThere is only one way to do it on Linux: with iptables. You could use Python to instruct iptables.\nWindows has its own way to add firewall rules. MacOS also has its own way, and each of them is different from the other.\nThere is no single common way to do this. Therefore, there is no single common way to do this with Python.","Q_Score":0,"Tags":"python,packet","A_Id":65971659,"CreationDate":"2021-01-30T17:10:00.000","Title":"how to RST packet drop using python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using a barcode reader connected to a raspberrypi with python script to read barcodes and send them to be processed in php through including the ip of file.php in python.\nmy python script is on a different physical machine than the PHP script.\nI want to start-up the python script from the php code to enable users to scan barcodes automatically.\n**I am new to python and have not used it before.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":33,"Q_Id":66009724,"Users Score":0,"Answer":"You must run your Python as daemon and contact Python via PHP using a socket or a REST call","Q_Score":0,"Tags":"python,php,raspberry-pi","A_Id":66012307,"CreationDate":"2021-02-02T12:27:00.000","Title":"Run Python script at start-up from php when python script is stored on a raspberrypi not in the same computer I have my php script on?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to use Python to monitor the complete network, if the route or link goes up\/down will get the notification.\nI found a few packages like lanscan, but I\u2019m not sure that will work fine or not.\nBasically, I want to use python same as NMS (Network management system). Please suggest to me some good frameworks or packages.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":63,"Q_Id":66022670,"Users Score":0,"Answer":"Pure python-based monitoring solutions are not really scalable as python at the core is pretty slow compared to something like c and multiprocessing is not native. Your best bet would be to use an opensource solution like Zabbix or cacti and use python API to interact with the data","Q_Score":0,"Tags":"python,python-3.x,network-programming,nms,opennms","A_Id":68525850,"CreationDate":"2021-02-03T07:01:00.000","Title":"How to monitor the complete network through Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Sorry to my bad english.\nSo 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).\nSo 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++.\nBut 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.\nSo 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.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":55,"Q_Id":66029193,"Users Score":0,"Answer":"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.\nOtherwise 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.","Q_Score":0,"Tags":"python,c++,client,bacnet,human-interface","A_Id":67459182,"CreationDate":"2021-02-03T14:09:00.000","Title":"Create Bacnet client variable automate","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Is there anywhere in Firebase Auth where you can access public and private RSA keys for users? This would be really helpful for my project instead of having to generate some and store them securely","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":372,"Q_Id":66043713,"Users Score":1,"Answer":"There is nothing built into Firebase Authentication for storing key pairs for the user. You'll typically want to use a secondary data store (like Firebase's Realtime Database, or Cloud Firestore) for that and associate the keys with the user's UID.","Q_Score":0,"Tags":"python,ios,swift,firebase-authentication,rsa","A_Id":66049160,"CreationDate":"2021-02-04T10:25:00.000","Title":"Getting Public \/ Private Keys from Firebase Auth","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"From Python script I'd like to login to Azure account and check if I have assigned a given role in a given subscription.\nThe important thing is that the MFA is configured (with Authenticator app but also with TOTP codes).\nI will have username, password and TOTP code in the script.\nI found Microsoft Authentication Library (MSAL) for Python but so far I don't see a way to use it in this scenario.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":158,"Q_Id":66049189,"Users Score":1,"Answer":"As far as I know this is not a supported scenario with MSAL, as MFA is meant as user interaction (not machine interaction).\nI would recommend not using a personal account for this kind of activity but to use a Service Principal that has the permissions to view roles.","Q_Score":0,"Tags":"python,azure,oauth-2.0,azure-active-directory","A_Id":66049486,"CreationDate":"2021-02-04T15:57:00.000","Title":"Programmatically authenticate in Azure with MFA","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"On the advice of TheZadok42 I installed PyCharm 2020.3.3 on both my Windows machine and my Raspberry PI 4. I have also bought and installed the FreeNove Ultimate Starter Kit for Raspberry on both. The first tutorial lesson is Blink.py, which just blinks an LED. It works fine if I just run \"python Blink.py\". However, when trying to run it from PyCharm it complains: \"No module named 'RPI'\" in reference to the line that says \"import RPi.GPIO as GPIO\". How do I get PyCharm to find it?\nPlease note that I am not well-versed in Linux, having grown up in the MS-DOS then Windows world, so please make installation instructions or configuration file edit instructions complete.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1327,"Q_Id":66052931,"Users Score":0,"Answer":"I had the same problem. Solution by Arseniy seems to be broken now, but the RPI.GPIO-def package seems to have exactly the purpose of enabling IntelliSense on PyCharm, without needing to install the full package.","Q_Score":2,"Tags":"python,pycharm,gpio,raspberry-pi4","A_Id":67810347,"CreationDate":"2021-02-04T19:56:00.000","Title":"PyCharm IDE can't find RPI.GPIO module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to Micropython and microcontrollers in general. I'm trying to create a script to run on a Raspberry Pi Pico that takes two time variables time1 = utime.time_ns() and time2 = utime.time_ns() and then subtracts time2 from time1 to give me the difference between the two times with nanosecond precision. When attempting to do this it prints out the value in nanoseconds rounded up to the second... for example, If there is 5 seconds between the two times the value returned is 5000000000... Is there a way that I can get a more accurate time? Am I going about this the wrong way? Thank you!!!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3515,"Q_Id":66083913,"Users Score":1,"Answer":"The processor crystal is not going to be accurate enough to get nanosecond precision. You would have to replace it with a TCXO\/OCXO crystal to get microsecond precision. Another problem is crystal drift with temperatures. The OCXO is a heated crystal. A TCXO is a temperature compensated crystal. As long as the temperature change a small a TCXO will likely get you in the microsecond ballpark. Then comes the firmware issues. Python is too slow for precise timing. you would have to pick a compiled language to minimize the jitter issues. I hope this helped.","Q_Score":0,"Tags":"time,microcontroller,micropython,raspberry-pi-pico","A_Id":68249989,"CreationDate":"2021-02-07T02:08:00.000","Title":"Raspberry Pi Pico - Nanosecond Timer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"The Current problem I am looking into is described below:\nMy computer is Win10, I installed only one anaconda 3.5.3 on it. Using where python there is only one python in my computer.\nI downloaded a rpy2python wheel file from the uefi website, and install that using pip install.\nWhen I import rpy2 in C disk, it is already fine, import rpy2,import rpy2.robjects are all OK.\nBut when I import rpy2 in my own project, I can only first import rpy2, when I import rpy2.robjects,the program says can not find rpy2 module.\nFinally I found the problem is that in my project, I occasionaly established an rpy2.py file, when I first import rpy2, it where automatically create an rpy2.pycache folder, secondly when I import rpy2.robjects, Of Course the computer can not find an rpy2.robjects.\nJust Keep a track of my problem.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":55,"Q_Id":66084811,"Users Score":0,"Answer":"You'll want to check the Python documentation about import rules for modules. By default, having a file called rpy2.py in the working directory for your Python code will cause import rpy2 to find this one rather that the rpy2 package.\nThe easiest fix is probably to rename your module rpy2.py into something else.","Q_Score":0,"Tags":"python,import,anaconda,rpy2","A_Id":66410958,"CreationDate":"2021-02-07T05:18:00.000","Title":"import rpy2 but can not import rpy2.robjects when changing start folders","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Error : pytesseract.pytesseract.TesseractError: (127, 'tesseract: error while loading shared libraries: libarchive.so.13: cannot open shared object file: No such\nMy apt file looks like this :\nlibgl1 libsm6 libxrender1 libfontconfig1 libarchive-dev libtesseract-dev tesseract-ocr tesseract-ocr-eng\nMy requirements file has pytesseract mentioned.\nI added a buildpack, set the TESSDATA_PREFIX config variable path.\nThe issue persists.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":1329,"Q_Id":66087588,"Users Score":3,"Answer":"I have faced same issue recently. But i fixed by adding the following library in Aptfile\n\n*libarchive13*\n\nand then redeployed my app and everything works fine...","Q_Score":1,"Tags":"heroku,deployment,tesseract,python-tesseract","A_Id":70569434,"CreationDate":"2021-02-07T11:53:00.000","Title":"'tesseract: error while loading shared libraries: libarchive.so.13: python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So, I'm working on a project where I'm storing passwords in a mongoDB and using Python. Python do has bcrypt build-in module which allows us to hash a plaintext. Now, I can hash a password and store the hashed password in database. Cool. And If I want to know if saved (hashed password saved in database) is same as a given password or not. (i.e. If I hashed a password 'Password' and saved it in database, bcrypt allows us to compare this hashed password and a plain password to check if they are same or not) I can check it with some built in functions.\nBut, what I really want is, I want to take that hashed password and want to print original plaintext.\n(e.g. If I hashed a password (say Plain password is 'Password' and hashed password is 'Hashed_Password' ) and saved it in database along with UserID and email for a specific website, now at some point I want to know what was the UserID and Password. So I can get UserID (since I'm not gonna hash it) but I'll only be able to get hashed password (i.e. 'Hashed_Password) and not the real one (i.e. 'Password') I saved.)\nI hope you can Understand my problem and give me a solution. In summary, is there a way to get plaintext (i.e. original text) from hashed text or Should I used any other method to do so (like encryption or something).","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":2671,"Q_Id":66091635,"Users Score":1,"Answer":"The whole purpose of hashing passwords before saving them in a databse is, others should not be able to see(calculate) the oraginal password from database.\nSimply you cannot get oraginal value from a hashed value.","Q_Score":0,"Tags":"python,hash,bcrypt","A_Id":66091779,"CreationDate":"2021-02-07T18:33:00.000","Title":"How to get plaintext from hashed text?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So, I'm working on a project where I'm storing passwords in a mongoDB and using Python. Python do has bcrypt build-in module which allows us to hash a plaintext. Now, I can hash a password and store the hashed password in database. Cool. And If I want to know if saved (hashed password saved in database) is same as a given password or not. (i.e. If I hashed a password 'Password' and saved it in database, bcrypt allows us to compare this hashed password and a plain password to check if they are same or not) I can check it with some built in functions.\nBut, what I really want is, I want to take that hashed password and want to print original plaintext.\n(e.g. If I hashed a password (say Plain password is 'Password' and hashed password is 'Hashed_Password' ) and saved it in database along with UserID and email for a specific website, now at some point I want to know what was the UserID and Password. So I can get UserID (since I'm not gonna hash it) but I'll only be able to get hashed password (i.e. 'Hashed_Password) and not the real one (i.e. 'Password') I saved.)\nI hope you can Understand my problem and give me a solution. In summary, is there a way to get plaintext (i.e. original text) from hashed text or Should I used any other method to do so (like encryption or something).","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2671,"Q_Id":66091635,"Users Score":0,"Answer":"From what I know,\nWe hash passwords so that even if the attacker gets access to the database the attacker will not be able to have the passwords without using a technique like brute force to get the password. I.E. assuming the attacker know how you hash the password a dictionary of passwords can be hashed and compared with the database to see which passwords match.\nNow if you want to reverse the hash I am pretty sure that can't be done other than you trying the brute force method explained above. We can't reverse the hash but only guess by giving passwords.\nIn terms of encryption which is often used as another layer. For example you could use encryption before the hash and then hash the encrypted password. This way even if the attacker inputs the correct password and only hashes that password the attacker will simply not get it right when compaing the hashes.","Q_Score":0,"Tags":"python,hash,bcrypt","A_Id":66091801,"CreationDate":"2021-02-07T18:33:00.000","Title":"How to get plaintext from hashed text?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to import paramiko library to AWS Lambda. I have tried to do so on lambda using Python version 2.7, 3.6, 3.8. I upload the zip file (created on ec2 machine using cmd, containing all dependencies) by creating a layer on Lambda function, however it keeps giving me the error-No module named Paramiko. Could you please suggest me how to successfully import paramiko to establish an sftp connection.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":358,"Q_Id":66124600,"Users Score":1,"Answer":"I have imported paramiko to Lambda Python 3.8 runtime as a layer. The point is you have to pip install it and pack it into a zip file in amznlinux2 x86 EC2 instance with Python3.8 installed. And make sure all content in the zip file is in a folder named python.","Q_Score":0,"Tags":"python,amazon-web-services,aws-lambda,paramiko,pysftp","A_Id":68801883,"CreationDate":"2021-02-09T18:07:00.000","Title":"Problem in importing Paramiko in AWS Lambda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to fetch Cloud watch logs for different lambda fucntions and trace for a pertucular string just like insights becasue we have some set of lambda functions and applications which need to run for a perticular job. Many time some of the services stop runnig due to some issues so i want to trace them with perticulart string and get error report where it got errored.\nEg : Lambda1 will call Lambda2 and Lambda2 will add entry in DynamoDB.\nNow i want to create a lambda function which will trace lambda 1 and lambda 2 give me report if both lambdas run succesfully for a perticular JOBID.\nSo far i have tryed to use AWS Cloud watch as a trigger but it is giving log only for 1 perticular function but not for all functions.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":38,"Q_Id":66151320,"Users Score":0,"Answer":"There is a Python library called Boto3 which helped me to resolve this issue.The Lambda function should have a peoper read access to fetch the logs or the corrosponding lambda fucntions we are tracking.","Q_Score":0,"Tags":"java,python,amazon-web-services,aws-lambda","A_Id":71016126,"CreationDate":"2021-02-11T08:40:00.000","Title":"Get Cloud Watch logs from differnet lambda functions or applications","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am planning to acquire position in 3D cartesian coordinates from an IMU (Inertial Sensor) containing Accelerometer and Gyroscope. I'm using this to track the objects position and trajectory in 3D.\n1- From my limited knowledge I was under the assumption that Accelerometer alone would be enough, resulting in acceleration in xyz axis A(Ax,Ay,Az) and would need to be integrated twice to get velocity and then position, but integrating would add an unknown constant value, this error called drift increases with time. How to remove this error?\n2- Furthermore, why is there a need for gyroscope in the first place, cant we just translate the x-y-z axis acceleration to displacement, if accelerometer tells the axis of motion then why check orientation from Gyroscopes. Sorry this is a very basic question, everywhere I checked both Gyro+Accel were used but don't know why.\n3- Even when stationary and not in any motion there is earth's gravitation force acting on the sensor which will always give values more than that attributed by the motion of sensor. How do you remove the gravity?\nOnce this has been done ill apply Kalman Filters to them to fuse them and to smooth the values. How accurate is this method for trajectory estimation of an object for environments where GPS is not an option. I'm getting the Accelerometer and Gyroscope values from arduino and then importing to Python where it will be plotted on a 3D graph updating in real time. Any help would be highly appreciated, especially links to similar codes.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3421,"Q_Id":66167733,"Users Score":3,"Answer":"1 - An accelerometer can be calibrated to account for some of this drift but in the end no sensor is perfect and inaccuracy will inevitably cause drift. To fix this you would need some filter such as the Kalman filter to use the accelerometer for short high frequency data, and a secondary sensor such as a camera to periodically get the absolute position and update the internal position. This is the fundamental idea behind the Kalman filter.\n2 - Accelerometers aren't very good for high frequency rotational data. Just using the accelerometers data would mean the system could not differentiate between a horizontal linear acceleration and rotational position. The gyroscope is used for the high frequency data while the accelerometer is used for low frequency data to adjust and counteract the rotational drift. A Kalman filter is one possible solution to this problem and there are many great online resources explaining this.\n3 - You would have to use the methods including gyro \/ accel sensor fusion to get the 3d orientation of the sensor and then use vector math to subtract 1g from that orientation.\nYou would most likely be better off looking at some online resources to get the gist of it and then using a pre-built sensor fusion system whether it be a library or an fusion system on the accelerometer (on most accelerometers today including the mpu6050). These onboard systems typically do a better job then a simple Kalman filter and can combine other sensors such as magnetometers to gain even more accuracy.","Q_Score":4,"Tags":"python,position,accelerometer,imu,pykalman","A_Id":66168101,"CreationDate":"2021-02-12T07:20:00.000","Title":"Getting 3D Position Coordinates from an IMU Sensor on Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have used the software Thonny to send programs to my raspberry pi pico. I am trying to make a specific program auto run when my pico is plugged in. At the moment another program which is on the pico auto runs but I want another program to run instead.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":846,"Q_Id":66183596,"Users Score":3,"Answer":"Name the program you want to run main.py","Q_Score":3,"Tags":"micropython,thonny,raspberry-pi-pico","A_Id":67217062,"CreationDate":"2021-02-13T09:27:00.000","Title":"How can you make a micropython program on a raspberry pi pico autorun?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"After running pip install python-telegram-bot, I'm getting this error that the 'telegram' module is not found.\nUnder pip list I see that my python-telegram-bot package is installed version 13.2\nIs anyone else getting this error?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1597,"Q_Id":66236885,"Users Score":0,"Answer":"pip3 install python-telegram-bot\nInstall it in outside of virutal environment in terminal. Also unintall telegram. python-telegram-bot is sufficient for Telegram bot. In my case it resolved my issue.","Q_Score":3,"Tags":"installation,pip,python-telegram-bot","A_Id":72194900,"CreationDate":"2021-02-17T06:41:00.000","Title":"ModuleNotFoundError: No module named 'telegram' after pip install","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"After running pip install python-telegram-bot, I'm getting this error that the 'telegram' module is not found.\nUnder pip list I see that my python-telegram-bot package is installed version 13.2\nIs anyone else getting this error?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1597,"Q_Id":66236885,"Users Score":0,"Answer":"I also had this problem - for me the issue was that I was trying to run my code from a module called telegram.py. Newbie mistake I know...","Q_Score":3,"Tags":"installation,pip,python-telegram-bot","A_Id":71301249,"CreationDate":"2021-02-17T06:41:00.000","Title":"ModuleNotFoundError: No module named 'telegram' after pip install","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'd like to use the Google Error Reporting Client library (from google.cloud import error_reporting).\nBasically, you instantiate a client:\nclient = error_reporting.Client(service=\"my_script\", version=\"my_version\")\nand then you can raise error using:\n\nclient.report(\"my message\") or\nclient.report_exception() when an exception is caught\n\nI have 3 environments (prod, staging and dev). They are each setup on their own Kubernetes cluster (with their own namespace). When I look at Google Cloud Error Reporting dashboard, I would to quickly locate on which environment and which class\/script the error was raised.\nUsing service is a natural choice to describe the class\/script but what about the environment?\nWhat is the best practice? Should I use the version to store that, e.g. version=\"staging_0.0.2\"?\nMany thanks in advance\nCheers,\nLamp'","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":123,"Q_Id":66238791,"Users Score":0,"Answer":"I think the Error Reporting service is deficient (see comment above).\nSince you're using Kubernetes, how about naming your Error Reporting services to reflect Kubernetes Service names: ${service}.${namespace}.svc.cluster.local?\nYou could|should replace the internal cluster.local domain part with some unique external specifier (FQDN) to your cluster: $[service}.${namespace}.${cluster}\n\nNOTE These needn't be actual Kubernetes Services but some way for you to uniquely identify the thing within a Kubernetes cluster my_script.errorreporting.${namespace}.${cluster}","Q_Score":0,"Tags":"python,kubernetes,error-reporting,google-cloud-logging,google-cloud-error-reporting","A_Id":66374446,"CreationDate":"2021-02-17T09:06:00.000","Title":"Google Cloud - Error Reporting Client Libraries","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I'm trying to install python 3.7 env for miniconda on my raspberry pi 4 model B.\n\nBut when I'm doing conda install python 3.7\nI get Error: No packages found in current Linux-armv7l channels matching: 3.7.\nhow can I install python 3.7 in some way on that miniconda?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2058,"Q_Id":66261176,"Users Score":0,"Answer":"You might want to try with this command : conda install -c anaconda python=3.7\nTell us if this works","Q_Score":4,"Tags":"python,raspberry-pi,anaconda,python-3.7,miniconda","A_Id":66261381,"CreationDate":"2021-02-18T13:41:00.000","Title":"How to install python 3.7 on miniconda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to create a chatbot using gupshup, but I don't have much experience with JS, and for my implementation, it will be easier to code in python, but I'm not finding any material about it.\nIs it possible to develop a ChatBot with python using GupShup?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":199,"Q_Id":66264967,"Users Score":0,"Answer":"Right Now Gupshup Only Provides JS Language Support, but we are looking to have python as a development language also for chatbots.","Q_Score":1,"Tags":"python,gupshup","A_Id":67054515,"CreationDate":"2021-02-18T17:22:00.000","Title":"Using python to create a ChatBot in GupShup Bot Builder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"So I am using AWS SAM to build and deploy some function to AWS Lambda.\nBecause of my slow connection speed uploading functions is very slow, so I decided to create a Layer with requirements in it. So the next time when I try to deploy function I will not have to upload all 50 mb of requirements, and I can just use already uploaded layer.\nProblem is that I could not find any parameter which lets me to just ignore requirements file and just deploy the source code.\nIs it even possible?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":746,"Q_Id":66280432,"Users Score":0,"Answer":"I hope I understand your question correctly, but if you'd like to deploy a lambda without any dependencies you can try two things:\n\nnot running sam build before running sam deploy\nhaving an empty requirements.txt file. Then sam build simply does not include any dependencies for that lambda function.\n\nOf course here I assume the layer is already present in AWS and is not included in the same template. If they are defined in the same template, you'd have to split them into two stacks. One with the layer which can be deployed once and one with the lambda referencing that layer.\nUnfortunately sam build has no flag to ignore requirements.txt as far as I know, since the core purpose of the command is to build dependencies.","Q_Score":0,"Tags":"python,amazon-web-services,aws-lambda,requirements.txt,sam","A_Id":66290011,"CreationDate":"2021-02-19T15:30:00.000","Title":"make sam to IGNORE requirements.txt","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using the discord.ext.commands Bot class. I need to get user info from id's I have in a dictionary, so that I can send them direct messages. I know there is a method to get user info from id using the client class (the .get_user_info() ) function, however I am not using the client class, only the Bot class. Is there a way to get user info using the bot class?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":81,"Q_Id":66286627,"Users Score":0,"Answer":"Use user = bot.fetch_user(id). After this, you can access all the user's attributes through user, such as user.display_name.","Q_Score":0,"Tags":"python,discord,discord.py","A_Id":66286810,"CreationDate":"2021-02-20T00:13:00.000","Title":"How to get user info given discord id using the discord Bot class?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I can't get my Python program (which runs in Terminal with no problem) to run through cron.\nHere's the crontab command I use:\n38 11 * * * \/usr\/bin\/python3 \/home\/pi\/Cascades2\/03_face_recognition.py >> \/home\/pi\/Cascades2\/cron.log 2>&1\nThe error message that appears in the cron.log file is:\n\n: cannot connect to X server\n\nWhat's the problem?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":160,"Q_Id":66290650,"Users Score":0,"Answer":"Like tocode suggested, adding export DISPLAY=:0.0 && to the script works perfectly.\n38 11 * * * export DISPLAY=:0.0 && \/usr\/bin\/python3 \/home\/pi\/Cascades2\/03_face_recognition.py >> \/home\/pi\/Cascades2\/cron.log 2>&1","Q_Score":0,"Tags":"python,cron","A_Id":66292030,"CreationDate":"2021-02-20T10:47:00.000","Title":"Unable to run a Python program with cron: cannot connect to X server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am currently writing a Python server to deploy on AWS Lambda. I want to use the firebase-admin package to send notifications with FCM and read data from cloud firestore. however when I try deploying my function to AWS Lambda with the .zip file archives, I get this error on execution:\n[ERROR] Runtime.ImportModuleError: Unable to import module 'lambda_function': Failed to import the Cloud Firestore library for Python. Make sure to install the \"google-cloud-firestore\" module.\nI installed the module with this: pip install --target . firebase-admin into a folder, added my code files (to the root as instructed), zipped it recursively and uploaded it with the aws-cli, I can clearly see that there is a google-cloud-firestore folder inside the .zip so i'm not sure whats going on. any help is appreciated!","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1208,"Q_Id":66291208,"Users Score":0,"Answer":"From the look of it you have bundled your code correctly and deployed successfully. The error occurs because Firestore relies on a C-based implementation of GRPC. By default this does not work on AWS Lambda. I'm currently creating a work-around and will update this post with my results.","Q_Score":0,"Tags":"python,amazon-web-services,firebase,aws-lambda,firebase-admin","A_Id":66393235,"CreationDate":"2021-02-20T11:56:00.000","Title":"Firebase-Admin with AWS Lambda Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm using a Raspberry Pi to dim a light, using python to get 0%....50%...100% and various % brightnesses in between.\nTaking a PWM approach in the code means a flickering light, which won't work for the lower % brightness, as the flicker will become more apparent. I can't seem to find a method to code brightness level without PWM, but there must be! Any suggestions gratefully received!\n(this is my first go at coding with python and trying to see what is possible)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":114,"Q_Id":66322118,"Users Score":0,"Answer":"If you want that many level of brightness PWM is your only option. Don't worry you won't notice the flicker anyway. If you don't want to use PWM then you will have to construct external circuit, for each brightness level you will have to calculate the voltage and add voltage divider according to it. Then Switch between them from raspberry pi code. you can do this for 100 brightness level if you want but it will be a big mess. Use this if you are okay with 3-4 levels of brightness","Q_Score":0,"Tags":"python,raspberry-pi,home-automation","A_Id":66323057,"CreationDate":"2021-02-22T19:21:00.000","Title":"Dimming Lights without PWM. Possible? Using Raspberry Pi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am building a web application that has some API calls to other services and currently I am just putting these API keys and secrets in variables which is not very secure.\nMy objective:\nTo store\/secure these API credentials either in the code or store it into the database in encrypted form maybe.\nI am currently coding in PHP and I have scripts in python to call these API services. I am planning to do up an API page where users can enter API credentials and it will be encrypted\/hashed and stored into the database. But I am not sure if this is the right way or how to go about it.\nAny help on this is welcomed. Thank you.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1902,"Q_Id":66327518,"Users Score":0,"Answer":"Actually you in some levels of security you can't be sure that key is private. First of all hashing is not suitable cause you can't reach api key form its hash so you can't use that api! If you encrypt that api key, there will be a key and an algorithem that you use for your encryption. If this information is likely to be leaked, you can do nothing to stop it! But in general, you trust on some layers of security and you can say store application key in an .env file. I think encrypting can be a good idea for storing keys in database in case of data being leaked by database attacks.","Q_Score":0,"Tags":"python,php,api","A_Id":66327651,"CreationDate":"2021-02-23T05:26:00.000","Title":"How to securely store API keys and secrets?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have C++ app where it does many calculations, but the most of time it needs to execute simple scripts by PyRun_SimpleString() so I'm curious if is there something in Python\/C API, what would do faster following tasks:\n\ndo simple assignents like x = 0.1 (changing over time)?\nexecute script storaged in string (maybe something like compile once to run faster)?\n\nFor now I do all these tasks by executing PyRun_SimpleString(). In loop performance loss is significatn.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":83,"Q_Id":66332450,"Users Score":1,"Answer":"As you suspect, there's indeed two parts to running Python code: interpretation and execution. See Py_CompileString and PyEval_EvalCode. But for simple statements like x=0.1, you might even consider modifying locals yourself via PyLong_FromDouble(0.1)","Q_Score":0,"Tags":"c++,optimization,python-c-api","A_Id":66333553,"CreationDate":"2021-02-23T11:41:00.000","Title":"Is PyRun_SimpleString() function slow?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"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.\npretty much the last step to automating my mining rigs for full self sufficiency.\nif 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","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":49,"Q_Id":66362462,"Users Score":0,"Answer":"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.","Q_Score":1,"Tags":"python,html,batch-file,helper","A_Id":66363316,"CreationDate":"2021-02-25T04:35:00.000","Title":"how to inject code with a batch into a batch that has existing code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was able to convert a .py file to and exe file,\nhowever when I try to send it via Gmail, it detects as a virus.\nAlso, when trying to transfer the file on a USB flash drive, the computer says it's a virus.\nAny ideas on how to fix this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":118,"Q_Id":66370571,"Users Score":0,"Answer":"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.\nEDIT FOR:\nI 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.","Q_Score":0,"Tags":"python,exe,converters,antivirus,virus","A_Id":66370775,"CreationDate":"2021-02-25T14:34:00.000","Title":"Created an EXE file from .py and it's detected as virus","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Can I use the discord API in python to harvest messages from a server (not my own server)? Assuming you have an invite link.\nThanks","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":661,"Q_Id":66372939,"Users Score":0,"Answer":"Well, if your using a discord bot, you need them to invite your bot to their server.\nOther than that you could theoretically listen with a bot on your own account but that would be against the discord TOS.","Q_Score":0,"Tags":"python,discord,discord.py","A_Id":66373023,"CreationDate":"2021-02-25T16:53:00.000","Title":"Is it possible to harvest messages from other peoples discord servers?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Python project where the main file has spaces in the name. I understand that this is not encouraged, but in this case, I think it's necessary. The file is being compiled into a stand alone executable using py2app--which uses the file name for the application name when building the executable (app name, menu references, etc.). This works fine because the base file is not imported anywhere within the project and py2app handles the spaces gracefully. Let's call the file Application Name.py.\nIn order to run unit tests against Application Name.py, however, I have to eliminate the spaces in order to import the file into unittest. I'm unable to use importlib or __import__ because the file is not constructed as a package, so both approaches fail. My workflow has been to refactor the file name to application_name.py, run the unit tests, and then refactor the name to Application Name.py before compiling it into Application Name.app.\nSo the options appear to be:\n\nKeep doing what I'm doing (workable, but not ideal),\nCreate a wrapper called Application Name.py that imports application_name.py where the wrapper doesn't need to be unit tested (seems silly),\nConvert Application Name into a package so I can use importlib (seems like overkill), or\nSomething else entirely.\n\nIs there some way to gracefully handle file names with spaces in unit testing that I'm not seeing or should I just suck it up?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":53,"Q_Id":66379066,"Users Score":1,"Answer":"Seems like option 2 probably works best.\nOption 1 and 2 are your best bets (yes 3 is a bit overkill), and although 2 seems excessive, it does isolate your python logic from your py2app requirements - now Application Name.py is a \"py2app wrapper file\", and application_name.py contains your actual logic.\nThis works better than Option 1 because separation of responsibilities is generally preferred. If you come up with other requirements for your application name, you'd want to have to deal with just the \"py2app wrapper file\", and not change anything related to actual logic.\nYour current workflow works too, but it does mean more manual renaming when you want to run unit tests - what if you want to automate the unit testing process?","Q_Score":0,"Tags":"python-3.x,python-unittest,py2app","A_Id":66379114,"CreationDate":"2021-02-26T01:59:00.000","Title":"Unit Testing File with Space in the Name","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When trying to use requests in my function, it only timeout without additional error. I was trying to use rapidapi for amazon. I already have the host and key, but when I test my function it always timeout. My zip file and my function were on the same directory and I knew that my code was correct.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":55,"Q_Id":66382131,"Users Score":2,"Answer":"I just figured out that my VPC configuration in Lambda was can only access within the resources of the VPC. I just removed the VPC and it now runs. But when your lambda function will connect to your database, you need to add and configure your VPC.","Q_Score":0,"Tags":"python,amazon-web-services,aws-lambda,python-requests","A_Id":66382132,"CreationDate":"2021-02-26T08:03:00.000","Title":"python requests in AWS Lambda Timeout","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a DAC which can be used with a 50MHz SPI interface.Its a 16 bit DAC with 8 bit address,hence i require to send 24 bits data. I want to use Pico to send data to DAC so as to produce a sine wave of 1 kHz with 20 sample (hence sampling rate\nnot more than 20ksps). I used Micropython to program the pico but i am unable to get more than 500 hz wave. What am i doing wrong.....Is there a way to use DMA to speed up this process? also the DAC requires chip select which is not in the machine module so i had to use gpio. whether that is slowing down the process?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1047,"Q_Id":66388451,"Users Score":1,"Answer":"Aside from any other issues, the SPI hardware implementation in the RP2040 only provides automatic control of CSn for transfers of up to 16 bits.\nFor your case, implementing a simple, 24-bit fixed-format, output-only SPI in the PIO subsystem is quite straightforward, and has the advantage of only requiring a single DMA channel for fully-DMA operation (compared to at least 2 chained DMA channels for a fully-DMA SPI\/GPIO approach). The example in the RP2040 datasheet already provides most of the implementation.","Q_Score":0,"Tags":"spi,dma,micropython,dac,raspberry-pi-pico","A_Id":68366110,"CreationDate":"2021-02-26T15:24:00.000","Title":"How to use Raspberry Pi Pico with DAC with SPI to generate sine wave of 1 kHz with 20 k samples per cycle","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am streaming certain keywords from Twitter API and I wanted to understand what percentage of the total tweets do I get from using the streaming function in Tweepy? (I am using the free developer account - Is there any benefit in terms of volume if I upgrade to a pro account?)\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":42,"Q_Id":66396291,"Users Score":0,"Answer":"Approximately 500,000,000 tweets occur every day. The software you refer to limits you to collect only 500,000 requests per month where each request can contain 120 tweets.","Q_Score":0,"Tags":"twitter,tweepy,twitterapi-python","A_Id":66450332,"CreationDate":"2021-02-27T06:43:00.000","Title":"What percentage of tweets do I get from a free twitter API?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is my first project that involves parallel programming so forgive me if I'm not using the proper terminology.\nI want to interface a RaspberryPi 4 with a peripheral board using an SPI serial interface. In order to completely understand the serial communication I want to code the SPI communication without using an external library.\nThe purpose of the program is to send data to the peripheral and to read data from it, while plotting the recived data \"in real time\".\nIn order to easily manage the communication I need to run a thread that will generate the sclk and chip select signals, and another thread that will read\/write data and plot them.\nMy question is: given that I will use a sclk frequency around 1MHz, is it a problem that I'm threading the functions instead of making them really parallel (using multiprocessing)?\nI'd say that the clock frequency of the Rpi4 is much higher than the sclk frequency, so the time delay due to the \"fake\" parallelism is not a problem (considering the fact that all the threads are made of few instructions), but I want to know if there are other factors to consider. Thank you!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":180,"Q_Id":66427892,"Users Score":1,"Answer":"You absolutely do not want separate threads generating clock and data. This is a SERIAL protocol, so those two things have to be synchronous. The 1MHz number is just a maximum limit. The clock doesn't have to be exact, nor does it have to be regular. You, as the master, are in full control of that. Everything is based on the transitions. In this order, you set the output pin, assert the clock, read the input pin, deassert the clock, rinse and repeat. One function, easy as pie. You might need to add some stalls if that process takes less than a microsecond.","Q_Score":0,"Tags":"python,raspberry-pi,spi","A_Id":66428055,"CreationDate":"2021-03-01T18:50:00.000","Title":"RaspberryPi and peripheral SPI interface using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a question regarding the usage of EFS as and additional memory location for lambda. I am using python along with pandas to perform some tests on my files. And it works great if the files are not that large, but if the files exceed 2-3 GB lambda dies because of the memory limitation (using both max memory and time of lambda). Files are originally located at S3 and I was wondering would it be possible to use EFS in this scenario? If so what would be required for this solution. Would I need to transfer files from S3 to EFS in order to open them?, or is there an better solution where I can directly load the files from S3 to EFS and open them with pandas. And also there is the timeout limitation, but I hope that wont be an issues if the lambda would be faster with EFS.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":392,"Q_Id":66428845,"Users Score":1,"Answer":"As far as I know pandas requires the whole file to fit into memory.\nIn principle you can fit larger files into memory in Lambda, since you can now configure Lambda functions with up to 10GB of RAM.\nThat's doesn't translate to you being able to read a 10GB file from S3 and create a dataframe out of it, because in order for pandas to parse the data, it needs to either be stored on disk (of which there's only 500MB available to you) or in memory.\nIf you download the file into memory, it also takes up it's size in system memory and then you can create a pandas data frame from that. Pandas data structures are probably larger than the raw bytes of the file, so my guess is that you can load a file from S3 into memory and turn that into a data frame that is about 30-40% of the memory capacity of the lambda function.\nIf you store that file on EFS, you'll be able to fit more into memory, because pandas can read the bytes from disk, so you could probably squeeze out a few more gigabytes. These I\/O operations take time however and Lambda is limited to at most 15 minutes of runtime. You probably also need to write that data somewhere which takes time as well.\nBottom line: Loading larger files than that into Lambda is probably not a good idea. If you can, break up the dataset into smaller chunks and have lambda functions work on them in parallel or choose a service like Athena or EMR or Glue ETL, which are built to handle that stuff.","Q_Score":2,"Tags":"python,pandas,amazon-web-services,aws-lambda,amazon-efs","A_Id":66429091,"CreationDate":"2021-03-01T20:00:00.000","Title":"Using EFS with AWS Lambda (memory issue)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I created a twitter bot using the Tweepy module in Python. I've been looking through the documentation for Tweepy and can not seem to find anything related to this. I just need to get the tweet id of tweets that reply on any of my tweets. I think maybe you could use API.search() but there are no parameters related to replies to your own tweet.\nThanks in Advance","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":219,"Q_Id":66448191,"Users Score":1,"Answer":"Use the api to get the most recent tweets from your account. Then, get your tweet ids. Then get tweets that tag you with api.search(q='to:@yourhandle'). Now, for each tweet you searched, you can see if it has the attribute in_reply_to_status_id_str. If it does, you can get the tweet id from there and match with your current tweets.","Q_Score":0,"Tags":"python,twitter,tweepy","A_Id":66450251,"CreationDate":"2021-03-02T22:41:00.000","Title":"Tweepy get reply","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying\u00a0to connect c++(server) and python(client) using socket and want to send share data using shared memory also message sending. Data in the formate of CSV file which is created by c++.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":256,"Q_Id":66455259,"Users Score":0,"Answer":"If you are on Windows you can try Memurai. It's a really fast-data store. It works like a charm","Q_Score":0,"Tags":"python,c++,sockets,shared-memory","A_Id":66494014,"CreationDate":"2021-03-03T10:33:00.000","Title":"shared memory between c++ and python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been exploring how async works in Python. So far, I've made a few simple MQTT-based async mini-services (get a message, do something, maybe retrieve something, send a message).\nFor my next mini-project, I'm trying to tie Discord and MQTT together. The goal is to have discord messages appear over MQTT, and mqtt messages on discord. I've got an async discord-client object, and an async mqtt-client object. Both work fine, but connecting them is a bit of an issue.\nMy current approach is to have the Discord object be 'leading', while I put the MQTT object in the Discord object (discord-client.mqtt-client = mqtt-client, meaning I can do things like await self.mqtt-client.publish(). This appears to work, so far.\nMy problem is that this approach feels a bit wrong. Is this a normal approach? Are there other approaches?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":37,"Q_Id":66461157,"Users Score":0,"Answer":"Answering my own question, with help.\nHaving nested async objects works, but 'smells wrong'. It also makes for odd looking (and therefore difficult to maintain) code, and likely introduces weird bugs and such later on.\nA better approach is to make use of asyncio.Queue, where each of the two client-objects has one queue to write to, and one to read from. Like this:\ndiscord-client -> discord-to-mqtt-queue -> mqtt-client\nmqtt-client -> mqtt-to-discord-queue -> discord-client\n(Not the actual naming of the objects)\nThis works, makes sense, and the resulting code is readable.","Q_Score":1,"Tags":"python,asynchronous,python-asyncio","A_Id":66478637,"CreationDate":"2021-03-03T16:31:00.000","Title":"Two async objects interacting","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python code that I want to run on a GPU server. Running it is time-consuming and sometimes, I get disconnected from the Internet or server and I have to re-run it. So, I need to let it run and shut down my computer. Is there any way?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":270,"Q_Id":66484631,"Users Score":0,"Answer":"If it is a windows server create a bat file.\nRun the python script and the shutdown command. You will have to be an admin to shutdown the computer from a script.\nbat file\nc:\\python27\\python.exe c:\\somescript.py %*\nshutdown \/s \/f \/t 0","Q_Score":0,"Tags":"python,server,gpu,taskscheduler","A_Id":66484766,"CreationDate":"2021-03-04T23:37:00.000","Title":"Executing a code on server while shutdown the computer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to create a Twitter bot but when I install the tweepy package it gives me the following error:\nModuleNotFoundError: No module named 'tweepy'\nI've tried uninstalling and installing tweepy and it still doesn't work. i'm running python 3.9.2","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":55,"Q_Id":66492918,"Users Score":0,"Answer":"Found a solution: just type pip install tweepy in to the terminal next to the console","Q_Score":0,"Tags":"python-3.x","A_Id":66495391,"CreationDate":"2021-03-05T12:50:00.000","Title":"No module named 'tweepy'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I want to get all the messages from the telegram servers I'm in and want to display the messages in the terminal.\nI used the telethon python library but the delay is too much takes like 2 to 3 seconds to fetch the message after it has already appeared in the browser.\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":337,"Q_Id":66505327,"Users Score":1,"Answer":"The best way I found is to use the pyrogram library, it displays messages faster than the Telegram App itself which is what I wanted.","Q_Score":1,"Tags":"python,api,python-requests,telegram","A_Id":71085998,"CreationDate":"2021-03-06T11:50:00.000","Title":"How to get telegram messages without any delay from any server using the API or is there a get request that I can use?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"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.\nI 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).\nDo 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.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":388,"Q_Id":66505663,"Users Score":0,"Answer":"Try a library called:\nGetOldTweets or GetOldTweets3\nTwitter 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.","Q_Score":0,"Tags":"python,web-scraping,twitter,tweepy","A_Id":66505759,"CreationDate":"2021-03-06T12:33:00.000","Title":"Tweets scraping - how to measure tweeting intensity?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"There is a class named State that has several attributes, which I need to write unit tests for. The test will need to have certain actions that change attribute values of the State instance. Expected parameters are located inside of the dictionary. The unit test will compare the attributes of the State instance with the values of the dictionary for equality.\nThe question is what is the best place to keep the comparison logic at? I\nwas thinking about 2 options:\n\nAdd __eq__ method to the State class that contains comparison logic.\nAdd helper function inside of the test module that contains comparison logic.\n\nWhich one of the options is better and why?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":279,"Q_Id":66522130,"Users Score":0,"Answer":"You should probably take the __eq__ approach. This way you can also test for equality in the actual code in the future if necessary, while also being able to avoid a potentially messy situation with importing the helper function if you plan or might use type annotations in the future.\nGenerally you do not want your testing code to contain much logic at all, since test are meant to test code not implement more logic which may need to be tested itself. Beyond the actual test functions you test suites should be really very simple.\nThe only reason I can think to not take this approach is if the class you are testing has some unique use case where a __eq__ is not applicable and you want to avoid implementing one and potentially confusing yourself or future developers later on.","Q_Score":4,"Tags":"python,python-3.x,unit-testing,testing,python-unittest","A_Id":66522206,"CreationDate":"2021-03-07T22:25:00.000","Title":"What is the correct way to test classes in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"There is a class named State that has several attributes, which I need to write unit tests for. The test will need to have certain actions that change attribute values of the State instance. Expected parameters are located inside of the dictionary. The unit test will compare the attributes of the State instance with the values of the dictionary for equality.\nThe question is what is the best place to keep the comparison logic at? I\nwas thinking about 2 options:\n\nAdd __eq__ method to the State class that contains comparison logic.\nAdd helper function inside of the test module that contains comparison logic.\n\nWhich one of the options is better and why?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":279,"Q_Id":66522130,"Users Score":2,"Answer":"Outside. __eq__ should (in most cases) not be used to compare a specific object to a dict and give equality. The expected behaviour is to enable comparison between objects of the same (or inherited) type. If you're looking for a way to compare to State objects, it could be useful - but that doesn't seem to be the case here, according to your description.\nI'd also be careful about using __eq__ for specific tests if these tests do not explicitly test for equality, but for certain properties. A future change in __eq__ - i.e. the comparison requirement between objects of the same class, may not be have the same semantic meaning as what you're actually testing in your test. For example; a future change to __eq__ could introduce more similarity requirements than what your tests require (for example; are they actually the same object and not just similar). Since the expected behaviour for __eq__ is \"this represents exactly the same thing\", that may not be the same as what you're testing.\nKeep the comparison outside of your class - and if it's something you want to re-use in different contexts, either add it as a utility function in your project or add it as a specific function to your object. For now I'd just go with keeping it in your tests, and then moving it inside your project when it becomes necessary.\nThis all assumes that the comparison is simple. If there is actual logic and calculations involved - that does not belong in the test. Instead, add logic to your class that exposes the values directly in a properly testable format.\nA test should just check that the value returned matches what was expected. However, comparing a returned dict against expected values for that dict is perfectly valid.","Q_Score":4,"Tags":"python,python-3.x,unit-testing,testing,python-unittest","A_Id":66522307,"CreationDate":"2021-03-07T22:25:00.000","Title":"What is the correct way to test classes in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"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.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":206,"Q_Id":66523058,"Users Score":0,"Answer":"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.","Q_Score":0,"Tags":"python,discord,discord.py,webhooks","A_Id":66523831,"CreationDate":"2021-03-08T00:48:00.000","Title":"How to use dhooks to find the most recent message sent in a channel","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have requirement to run performance test suite, where each script will consist of set of REST APIs for one particular functionality on a given platform, like in Loadrunner or Jmeter we can run multiple scripts together or in parallel either using thread group in Jmeter or Controller in Loadrunner. Is it the same possible on Locust??","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":505,"Q_Id":66531063,"Users Score":0,"Answer":"In Locust every test is group\/scenario\/case is represented by a Locust User. You could develop several Users with all the tests scripts that you need to run and execute all of them in a single parallel Locust run configuration.","Q_Score":2,"Tags":"python,python-3.x,locust","A_Id":66533912,"CreationDate":"2021-03-08T13:49:00.000","Title":"Option in Locust to run multiple Locustfile together like in Jmeter running multiple Thread Groups in Parallel","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have requirement to run performance test suite, where each script will consist of set of REST APIs for one particular functionality on a given platform, like in Loadrunner or Jmeter we can run multiple scripts together or in parallel either using thread group in Jmeter or Controller in Loadrunner. Is it the same possible on Locust??","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":505,"Q_Id":66531063,"Users Score":0,"Answer":"No it's not. We achieved it by running pararell jenkins builds next to each other.","Q_Score":2,"Tags":"python,python-3.x,locust","A_Id":66533220,"CreationDate":"2021-03-08T13:49:00.000","Title":"Option in Locust to run multiple Locustfile together like in Jmeter running multiple Thread Groups in Parallel","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any monitor utils that can monitor the cpu usage of every code line use in python program.\nI know profile,cProfile and line_profiler. but they are only statistic the time of each line or function using the cpu.\nIf my program is io-intensive, it may be use a long time but doesn't really use the calculation of the cpu.\nSo I want to find a util which could monitor the real calculation of the cpu.\nHave anybody an idea?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":166,"Q_Id":66540808,"Users Score":0,"Answer":"cProfile and profile both accept a time base function as a parameter. Just pass time.clock instead of the default time.time.","Q_Score":1,"Tags":"python,cpu,monitor","A_Id":66541169,"CreationDate":"2021-03-09T04:27:00.000","Title":"how to monitor the cpu usage of every code line in python program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking to test embedded system product using Python scripting and I need some guidance.\nThe setup: A Raspberry pi have been connected to the embedded system PCB and I access that Raspberry pi remotely using ssh or vncserver.\nThe issue: I am using PyCharm on my laptop to access the Python scripts. Since the embedded system is connected to Raspberry pi, I am not able to debug using my laptop as I would not be able to get the values of variables etc while debugging. So I installed PyCharm on RPi but it keeps on crashing frequently which I guess is because RPi is not able to take that much load as it also connected to VNCServer while using PyCharm.\nWhat I am looking for: Some guidance how to debug in such a case so I can test whether scripts have issue or device is faulty or something else. A better and efficient method for debugging in such a scenario where there are multiple layers.\nI have limited exposure so I may be missing out something. Please feel free to correct me.\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":43,"Q_Id":66559317,"Users Score":0,"Answer":"Update: Just in case someone is looking for the answer to this question, Pycharm paid version allows remote debugging over ssh. That worked for me.","Q_Score":0,"Tags":"python,testing,raspberry-pi,automated-tests,embedded","A_Id":68292245,"CreationDate":"2021-03-10T06:14:00.000","Title":"Debugging Python scripting for testing Embedded system connected with Rasbperry pi (RPi)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I cannot open any .py file: when I run in the command prompt either \"python test.py\" or \"python3 test.py\" or \"py test.py\", it just says can't open file 'C:\\Users\\Ciela\\Desktop\\test.py': [Errno 2] No such file or directory.\n\nPython is installed, latest version\nAll other versions are uninstalled\nPython was automatically added to PATH during installation, I can see it in both User and System paths and the version is correct\nthe files can be opened in Python just by double-clicking them, although they shut off immediately (I know they work because the \"turtle module\" screen persists on the screen)\nThe OS is Windows 10 and I am a total noob trying to learn\n\nWhat could it be??","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":745,"Q_Id":66575046,"Users Score":0,"Answer":"I sorted it out. For anyone struggling with the same issue, the problem might be OneDrive. Windows10 automatically creates 2 desktops: the one in User, and the one in User\/OneDrive, where files are stored by default. Essentially I was looking for the files in the wrong desktop folder.","Q_Score":1,"Tags":"python,installation,windows-10","A_Id":66580075,"CreationDate":"2021-03-11T00:58:00.000","Title":"Cannot open .py files: \"[Errno 2] No such file or directory\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"So I'm making a discord bot, and I want it to be able to obtain the guild ID of the guild where a command was issued. How would I go about implementing this? I tried using bot.guilds, but I need a method of nailing down the exact id.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":43,"Q_Id":66575715,"Users Score":1,"Answer":"Have you tried doing message.guild.id ?\nThat should return the guild id for the guild the command was executed in.","Q_Score":0,"Tags":"python-3.x,discord.py","A_Id":66576105,"CreationDate":"2021-03-11T02:39:00.000","Title":"Getting current guild id for instance","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to know how I can send messages in discord, without creating a bot.\nLike 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 :)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":90,"Q_Id":66577819,"Users Score":0,"Answer":"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.\n(You can find such program using google)\nBUT 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","Q_Score":0,"Tags":"python,python-3.x,list,discord,bots","A_Id":66578384,"CreationDate":"2021-03-11T07:02:00.000","Title":"How to send messages in discord without using bot application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I made a telegram bot using telepot, one of the issues I have is that groups can still invite and make the bot join their channels, even with \/setjoingroups disabled. Is there a way to list these groups and leave them from the code or from @BotFather ?\nthanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":595,"Q_Id":66577829,"Users Score":0,"Answer":"You can look bot settings inline mode and group privacy","Q_Score":0,"Tags":"python,bots,telegram,telepot","A_Id":67948892,"CreationDate":"2021-03-11T07:04:00.000","Title":"Leaving group channels as a bot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"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.\nSo is there any recommend solution for either the first problem or the second.\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":59,"Q_Id":66627916,"Users Score":0,"Answer":"No it's not possible to write python code Inside Flutter code\nBut you can write your api in different framework like Django ,mongodb and use it in your Flutter app","Q_Score":0,"Tags":"python,android,api,flutter,backend","A_Id":66627972,"CreationDate":"2021-03-14T18:07:00.000","Title":"Is it possible to write python code inside Flutter using Android Studio?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have started a project and to test if it works, I used a Pi zero. It has buttons and then sends MIDI Messages to my PC, depending on what buttons are pressed. So a simple MIDI Controller.\nNow I think that a Microcontroller, like the Pico would be better suitable for such a task, but it can only run MicroPython.\nSo my question is, wether you can import most or all of the python libaries into microPython or if I should use another MicroController that can run python.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":303,"Q_Id":66629306,"Users Score":1,"Answer":"Usually \"no.\" It won't fit.","Q_Score":0,"Tags":"python,microcontroller,micropython","A_Id":66629358,"CreationDate":"2021-03-14T20:38:00.000","Title":"Can you import python libaries into microPython?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have started a project and to test if it works, I used a Pi zero. It has buttons and then sends MIDI Messages to my PC, depending on what buttons are pressed. So a simple MIDI Controller.\nNow I think that a Microcontroller, like the Pico would be better suitable for such a task, but it can only run MicroPython.\nSo my question is, wether you can import most or all of the python libaries into microPython or if I should use another MicroController that can run python.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":303,"Q_Id":66629306,"Users Score":0,"Answer":"So my question is, wether you can import most or all of the python libaries into microPython or if I should use another MicroController that can run python.\n\nWhile MicroPython shares much of the syntax of Python (3.4), it is different enough that anything but the most trivial Python code will not run under MicroPython. In general, you should only expect to run code developed explicitly for MicroPython on a MicroPython capable device.\n\nSo my question is, wether you can import most or all of the python\nlibaries into microPython or if I should use another MicroController\nthat can run python.\n\nI don't believe there are any microcontrollers available that can run standard Python. The smallest device you're going to find is probably something like the Raspberry Pi Zero.","Q_Score":0,"Tags":"python,microcontroller,micropython","A_Id":66629360,"CreationDate":"2021-03-14T20:38:00.000","Title":"Can you import python libaries into microPython?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to create Jira issues with data populated in a row in google sheet, I plan to put a button to read the contents of the row and create Jira issues, I have figured the Jira API wrote the script for it and also the Google sheets API to read the row values to put in the Jira API.\nHow do I link the button to the python script in my local machine in a simple manner, I went through other similar asks here, but they are quite old and hoping now some new way might be available.\nPlease help me achieve this in a simple way, any help is greatly appreciated.\nThank You and Stay Safe.","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":808,"Q_Id":66655415,"Users Score":4,"Answer":"Google sheets cannot run code on your local machine. That means you have a few options:\nClick the button locally\nInstead of clicking a button on the google sheet, you can run the script yourself from the command line. This is probably how you tested it, and not what you want.\nWatch the spreadsheet\nYou could have your python script setup to run every few minutes. This has the benefit of being very straightforward to setup (google for cron jobs), but does not have a button, and may be slower to update. Also, it stops working if you turn off your computer.\nMake script available for remote execution\nYou can make it so that your script can be run remotely, but it requries extra work. You could buy a website domain, and point it towards your computer (using dynamic dns), and then make the google sheet request your new url. This is a lot of work, and costs real money. This is probably not the best way\nMove the script into the cloud\nThis is probably what you want: cut your machine out of the loop. You can use Google AppScripts, and rewrite your jira code there. You can then configure the google AppScript to run on a button click.","Q_Score":3,"Tags":"python,google-sheets,google-sheets-api","A_Id":66772025,"CreationDate":"2021-03-16T12:39:00.000","Title":"Running a python script saved in local machine from google sheets on a button press","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am having trouble getting task scheduler to send an email via python. The particular python code I am using creates a monthly export, grabbing data from a SQL database, and then sends an email notifying the team where the export is located. For the email, I am using smtplib.\nHere is the issue. I can run the export from pycharm, and the export and the send email works fine. I can run the export from task scheduler and JUST the export runs. In other words, only when I run the .bat file of the code from task scheduler, the email doesn't send. Does anyone happen to know the solution? I've tried so many things from searches and nothing works. :(","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":102,"Q_Id":66664296,"Users Score":0,"Answer":"The answer really depends on how you've packaged your code and how you are choosing to execute it.\nTo me it seems like you are executing it as a script that your task scheduler is pointed to, if this script calls your system interpreter, my first suggestion would be to make sure you have all of the dependencies installed for the version of python that your script is calling. So if you are calling python 3.9.1, then make sure smtplib is installed on your system's python for 3.9.1.\nFor why it's working in pycharm, code in pycharm is run in an isolated environment, so packages that you have installed for your project will only work on that specific project. Not outside of it or on other systems.","Q_Score":1,"Tags":"python,email,smtp,smtplib,taskscheduler","A_Id":66664435,"CreationDate":"2021-03-16T22:24:00.000","Title":"Running python export that includes a send email trigger through task scheduler not working?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to create a pdf document with reportlab, one of the texts is long, and reportlab writes it in a single line, it does not generate the break, I inserted the text in part, but I need to justify it, so that it looks good.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":89,"Q_Id":66676393,"Users Score":0,"Answer":"You can wrap your text in reportlab.platypus.Paragraph to get auto wrapping","Q_Score":2,"Tags":"python,python-3.x,pdf,reportlab","A_Id":66677075,"CreationDate":"2021-03-17T15:39:00.000","Title":"How to justify text in ReportLab","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am in the process of bringing an API up from 2.7 to 3.8. It is built to communicate with an agent over a TCP socket. I am having an issue with a checksum not being calculated right. I get a message back from my agent that the Checksum is bad.\nI know it is not my agent because the CRC check on header only packets are being accepted and the commands are executed correctly on the agent side.\nThe line of code I am having an issue with is:\nbody += format(struct.pack(\"=L\", binascii.crc32(format(body).encode()) & 0xFFFFFFFF))\nPreviously on 2.7 this line of code had no encoding\/formatting.\nDoes anyone know what I am doing wrong?\nI have a strong feeling it pertains to the encoding of 'body string'. After breaking the line of code down to its components I confirmed that the int output of binascii.crc32() is different between 3.8 and 2.7 and doing a bit of reading on the variety of byte\/char types there are I have become quite lost.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":197,"Q_Id":66689493,"Users Score":0,"Answer":"so the correct line of code is to append the checksum and body to the packet buffer simultaneously rather than add the checksum to the body and then add the body to the packet buffer. this avoids a decoding stage that was causing an issue.\nbuf = buf + format(body).encode() + struct.pack(\"=L\", binascii.crc32(format(body).encode()) & 0xFFFFFFFF)\nthe original would output:\n'{\"datasetName\": \"X_train\", \"fileName\": \"\/test\/MNIST\/X_train_uint8.h5\"}b\\'y\\\\xf8D\\\\xec\\''\nthe correct solution seen in this answer outputs:\n'{\"datasetName\": \"X_train\", \"fileName\": \"\/test\/MNIST\/X_train_uint8.h5\"}y\\xf8D\\xec'","Q_Score":1,"Tags":"python,crc32,binascii","A_Id":66698964,"CreationDate":"2021-03-18T10:45:00.000","Title":"Calculating CRC32 checksum on string","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For AWS Lambda handlers, does it matter if the code is async vs sync (eg async def vs def), with respect to the concurrency performance of multiple calls to that Lambda function? That is, if I write a synchronous function, will that function be called \"asynchronously\" anyway due to the way AWS internally handles Lambda invocations from separate calls? Or will the function start processing UserA, and queue UserB's request until it has completed UserA?\nBackstory: I'm writing some Python + SQLAlchemy Lambda functions. SQLAlchemy 1.4 just released asyncio support, but there will be some re-write overhead on my part. I'm wondering if I can just write traditional synchronous Python code without concurrency consideration on Lambda (where concurrency is something I'd definitely need to consider for custom Flask \/ FastAPI code).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":417,"Q_Id":66714861,"Users Score":1,"Answer":"If you have more than one request to invoke a lambda at the same time the service will attempt to run multiple instances of the lambda. You may run into throttling due to the concurrency limits on either the lambda itself, or the account. Lambda does not queue requests to the same lambda function. A function is never processing more than one request at a time. Even in cases where the system is providing a queuing mechanism to handle the requests, they are not a thread queue, like you might have with a server. They are really just internal SQS queues that are invoking the lambda with one request at a time.","Q_Score":0,"Tags":"aws-lambda,python-asyncio","A_Id":66715034,"CreationDate":"2021-03-19T19:57:00.000","Title":"AWS Lambda: does it matter if handlers are sync vs async, w.r.t. concurrent calls?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"That's basically it.\nAll I could find was libraries that solve the problem involving ONLY inequalities and my particular problem also shield some equalities.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":26,"Q_Id":66728028,"Users Score":0,"Answer":"I figured the answer myself!\nI can't believe i didn't realized it earlier.\nBasically if you have something like:\nax + by + c*z = d\nthat's absolutely the same as:\nax + by + cz <= d\nAND\nax + by + cz >= d\nand that's all inequalities :)","Q_Score":0,"Tags":"python,linear-programming","A_Id":66728423,"CreationDate":"2021-03-21T01:23:00.000","Title":"Is there a way to use pypoman (or something equivalent) for getting the vertices of a linear problem involving inequalities AND also equalities?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"ImportError: cannot import name 'gTTS' from partially initialized module 'gtts' (most likely due to a circular import) (C:\\Users\\Gayathri Sai\\PycharmProjects\\audibook\\gtts.py)","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":421,"Q_Id":66741101,"Users Score":0,"Answer":"You want to import gtts, but the name of your file is gtts.\nSo python doesn't know which one you want to import, the solution is simple just rename file in a way that doesn't interfere with the module's name.","Q_Score":4,"Tags":"python,pypdf2,gtts","A_Id":66878667,"CreationDate":"2021-03-22T06:13:00.000","Title":"cannot import name 'gTTS' from partially initialized module 'gtts'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"ImportError: cannot import name 'gTTS' from partially initialized module 'gtts' (most likely due to a circular import) (C:\\Users\\Gayathri Sai\\PycharmProjects\\audibook\\gtts.py)","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":421,"Q_Id":66741101,"Users Score":1,"Answer":"Looks like you're testing Google's Text-to-Speech and you innocently named your python file \"gtts.py\"(happened to me too). This conflicts with the import so you should rename your file to something else(e.g. test_gtts.py)","Q_Score":4,"Tags":"python,pypdf2,gtts","A_Id":69715559,"CreationDate":"2021-03-22T06:13:00.000","Title":"cannot import name 'gTTS' from partially initialized module 'gtts'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"ImportError: cannot import name 'gTTS' from partially initialized module 'gtts' (most likely due to a circular import) (C:\\Users\\Gayathri Sai\\PycharmProjects\\audibook\\gtts.py)","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":421,"Q_Id":66741101,"Users Score":0,"Answer":"I think your python file name is gtts.py that why is error is occur. change your\nfile name.","Q_Score":4,"Tags":"python,pypdf2,gtts","A_Id":71733493,"CreationDate":"2021-03-22T06:13:00.000","Title":"cannot import name 'gTTS' from partially initialized module 'gtts'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python script (priceChange.py) which I'm trying to run using CRON from the path below.\n35 10 * * 1-5 \/home\/pi\/Desktop\/priceChange.py\nwhen I check grep CRON \/var\/log\/syslog it shows this:\nMar 23 10:35:01 AlexM CRON[16200]: (pi) CMD (\/home\/pi\/Desktop\/priceChange.py) with no error.\nWhen I run the script manually it works, the end result being an email being sent to myself.\nClearly something is missing in the crontab line, but I'm lost. Any suggestions appreciated","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":109,"Q_Id":66761644,"Users Score":0,"Answer":"The way how run your script causes the problem. add python command ahead.\n35 10 * * 1-5 python \/home\/pi\/Desktop\/priceChange.py","Q_Score":0,"Tags":"python,linux,debian,raspberry-pi4","A_Id":66761697,"CreationDate":"2021-03-23T10:48:00.000","Title":"CRON not running python script - Debian\/RPi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to write a Bot that changes the color of a Role on a server every 1 minute. What should I do?\nThe bot is supposed to do this only on one server","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":95,"Q_Id":66763781,"Users Score":0,"Answer":"i think you can do this by background task, but i think it's not good idea to do that role :\/ and maybe your bot will be get ratelimit from discord","Q_Score":0,"Tags":"python-3.x,discord,discord.py","A_Id":66766334,"CreationDate":"2021-03-23T13:07:00.000","Title":"Discord Bot RGB Role Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm a student. For my Distributed Systems project, I'm expected to create a gRPC project. I'm creating the project in Eclipse.\nTwo service implementation are to be coded in Java and the other is to be done in another coding language.\nI'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.\nIdeally, 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?\nI am able to see online searches for both Java and Python, but I'm not sure how to use both in one project.\nThank you.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":62,"Q_Id":66781091,"Users Score":0,"Answer":"So I got a lot of feedback for lecturers and classmates.\nThe server doesn't care what programming language is used.\nSo Java, Python, Node.js etc, could all be sent to the server.\nA 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.\nI 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.\nWhy did I think this? Your guess is as good as mine.","Q_Score":1,"Tags":"eclipse,grpc,grpc-java,grpc-python","A_Id":66873041,"CreationDate":"2021-03-24T12:30:00.000","Title":"gRPC - Using code other than Java to create a Service Implementation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a doubt. I've been looking for information and haven't found anything. I would like to know if it is possible to send a message with a bot which will be eliminated after a certain time. I'm working with c# but I think other examples will work for me. Thanks in advance.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":595,"Q_Id":66789927,"Users Score":0,"Answer":"I'm not sure if telegram API provides that.\nbut you can implement it in the bot to do that, maybe with \"time\" or \"schedule\" in python","Q_Score":0,"Tags":"python,c#,telegram-bot","A_Id":66790013,"CreationDate":"2021-03-24T21:52:00.000","Title":"how to send auto delete messages whit Telegram bot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a doubt. I've been looking for information and haven't found anything. I would like to know if it is possible to send a message with a bot which will be eliminated after a certain time. I'm working with c# but I think other examples will work for me. Thanks in advance.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":595,"Q_Id":66789927,"Users Score":1,"Answer":"I thought I would delete my own message after a while but I think it would not be a solution in a well active chat, since there are many messages coming in all the time and I would not know for sure what the id of the message I sent is. I would have to do another algorithm to find out what that id is, and what I was trying to see is if there was some simpler method already implemented in the api for these specific cases. Send messages using the bot with self-destruct after a while.","Q_Score":0,"Tags":"python,c#,telegram-bot","A_Id":66824462,"CreationDate":"2021-03-24T21:52:00.000","Title":"how to send auto delete messages whit Telegram bot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have tried to change the format of strings from latin1 to ascii, and most of the strings were changed well except for some characters, \u00e6 \u00f8. \u00c6, and \u00d8.\nI have checked the characters were changed correctly when using R package (stringi::stri_trans_general(loc1, \"latin-ascii) but Python's unicodedata package did not work well.\nIs there any way to convert them correctly in Python? I guess it may need an additional dictionary.\nFor information, I have applied the following function to change the format:\nunicodedata.normalize('NFKD', \"Latin strings...\").encode('latin1', 'ignore').decode('ascii')","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":175,"Q_Id":66792446,"Users Score":1,"Answer":"It's important to understand a) what encodings and decodings are; b) how text works; and c) what unicode normalization does.\nStrings do not have a \"format\" in the sense that you describe, so talking about converting from latin1 to ascii format does not make sense. The string has representations (what it looks like when you print it out; or what the code looks like when you create it directly in your code; etc.), and it can be encoded. latin1, ascii etc. are encodings - that means, rules that explain how to store your string as a raw sequence of bytes.\nSo if you have a string, it is not \"in latin1 format\" just because the source data was in latin1 encoding - it is not in any format, because that concept doesn't apply. It's just a string.\nSimilarly, we cannot ask for a string \"in ascii format\" that we convert to. We can ask for an ascii encoding of the string - which is a sequence of bytes, and not text. (That \"not\" is one of the most important \"not\"s in all of computer science, because many people, tools and programs will lie to you about this.)\nOf course, the problem here is that ascii cannot represent all possible text. There are over a million \"code points\" that can theoretically be used as elements of a string (this includes a lot of really weird things like emoji). The latin-1 and ascii encodings both use a single byte per code point in the string. Obviously, this means they can't represent everything. Latin-1 represents only the first 256 possible code points, and ascii represents only the first 128. So if we have data that comes from a latin-1 source, we can get a string with those characters like \u00c6 in it, which cause a problem in our encoding step.\nThe 'ignore' option for .encode makes the encoder skip things that can't be handled by the encoding. So if you have the string 'barents\u00f8ya', since the \u00f8 cannot be represented in ascii, it gets skipped and you get the bytes b'barentsya' (using the unfortunately misleading way that Python displays bytes objects back to you).\nWhen you normalize a string, you convert the code points into some plain format that's easier to work with, and treats distinct ways of writing a character - or distinct ways of writing very similar characters - the same way. There are a few different normalization schemes. The NFKD chooses decomposed representations for accented characters - that is, instead of using a single symbol to represent a letter with an accent, it will use two symbols, one that represents the plain letter, and one representing the \"combining\" version of the accent. That might seem useful - for example, it would turn an accented A into a plain A and an accent character. You might think that you can then just encode this as ascii, let the accent characters be ignored, and get the result you want. However, it turns out that this is not enough, because of how the normalization works.\nUnfortunately, I think the best you can do is to either use a third-party library (and please note that recommendations are off-topic for Stack Overflow) or build the look-up table yourself and just translate each character. (Have a look at the built-in string methods translate and maketrans for help with this.)","Q_Score":0,"Tags":"python,encoding,decoding","A_Id":66792824,"CreationDate":"2021-03-25T03:00:00.000","Title":"String change from Latin to ASCII","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"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.\nNow 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\/?\nI 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.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":57,"Q_Id":66804369,"Users Score":2,"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.\n\nGit 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.\nIn 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.\nGithub will do what Github will do.\nRegardless 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.\n\"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.\nThe tools work for us. Don't bend yourself for the benefit of the tools.\nIf you want to make a special shout out to your contributors, make a contributor's section to your README.md.","Q_Score":2,"Tags":"python,github","A_Id":66835236,"CreationDate":"2021-03-25T17:09:00.000","Title":"Rename folder in git without changing the contributors","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"using Sublime-Text-3\nWhen i evaluate some selected python code, in PEPL Python (with SublimeREPL), i get something like that:\n*>>> print(\"thank you\")\nthank you*\n(i already set, \"show_transferred_text\": true,)\nInstead of send and see the whole code that evaluated, i would like to see the line numbers of this evaluated code. Have you any ideas about this ?\n(for example to display sth like this: >>> evaluated lines (1:30))\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":89,"Q_Id":66823758,"Users Score":0,"Answer":"Unfortunately this is not possible with the default install of SublimeREPL. Additionally, the project is no longer being maintained, so until someone steps forward to steward the project, this feature won't get added unless you add it yourself. It's all open-source and written in Python.","Q_Score":1,"Tags":"python,sublimetext3,sublimerepl","A_Id":66834507,"CreationDate":"2021-03-26T20:15:00.000","Title":"Sublime Text 3 : How to display the line numbers of the evaluated lines in REPL Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"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","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":304,"Q_Id":66824019,"Users Score":0,"Answer":"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.","Q_Score":0,"Tags":"python,python-3.x,discord,discord.py","A_Id":66847972,"CreationDate":"2021-03-26T20:37:00.000","Title":"How to give all permissions in voice channel discord.py","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"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!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":69,"Q_Id":66828255,"Users Score":1,"Answer":"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.","Q_Score":0,"Tags":"python,html,css,flask","A_Id":66828292,"CreationDate":"2021-03-27T05:21:00.000","Title":"How the heck do I import my python chatbot into my html code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I 'm using repl.it to run my discord bot but I have encountered a problem. Sometimes, at the end of the day usually, whatever the users did does not save in the json file assigned to store the data. Does anyone know what is happening?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":376,"Q_Id":66832204,"Users Score":0,"Answer":"Hey i have had the same problem and it is because file changes do not persist if you are not in the editor.\nThe best thing you could do is use a database to store your data.\nTake a look at some databases like mongo db and PostgreSQL.","Q_Score":0,"Tags":"python,json,discord.py,repl.it","A_Id":66833705,"CreationDate":"2021-03-27T14:06:00.000","Title":"Json data doesn't save at the end of the day","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Background\nI 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.\nProblem\nI 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.\nTwo problems here are :\n\nDownloading the credentials -- insecure and my organization prohibits it.\nSharing of google sheet with service account email. organization also prohibits sharing sheet with outside organization emails.\n\nWhat I found as a solution\nI 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.\nFor the sharing of sheets thing, I guess we can use drive API, but same problems are with that.\nI tried using gcloud auth login and gcloud auth application-default login but was getting errors\n\nRequest had insufficient authentication scopes.\". Details: \"Insufficient Permission: Request had insufficient authentication scopes.\n\nusing ['https:\/\/www.googleapis.com\/auth\/spreadsheets', https:\/\/www.googleapis.com\/auth\/drive'] as scopes\nWhat I need? (Summary)\nHow to access google sheets API (or download the Sheet from google drive) without downloading any sort of credentials.json.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1394,"Q_Id":66833449,"Users Score":2,"Answer":"problem\nYour 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\n\nDownloading the credentials -- insecure and my organization prohibits it.\n\nIn 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.\n\nSharing of google sheet with service account email. organization also prohibits sharing sheet with outside organization emails.\n\nIn 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.\nservice account impersonation.\nService 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.\nThis 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.\nconclusion\nI 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.","Q_Score":3,"Tags":"python-3.x,google-sheets,google-cloud-platform,google-drive-api,google-sheets-api","A_Id":66834681,"CreationDate":"2021-03-27T16:13:00.000","Title":"How to read private Google Sheets using Google Sheets API without service account or downloading credentials","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a student working on a implementation of a signup system in Python. In order to allow you to signup, the programme will edit a .csv file (with the Username and Password as columns). In order to allow the use of that programme I need something like a server, which stores the master file and when a user runs the programme it updates the file. I thought of using git for that (as I lack the resources for a server), would that be a viable option and how would I allow the editing of that file without the need of having github account","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":45,"Q_Id":66863354,"Users Score":3,"Answer":"Git is designed as a version control system. It's designed to store and version files, especially text files, in a way such that they are easily retrievable and have a useful version history.\nWhat you are looking for is a database backend or a server hosting platform. Git is not good for that, since it keeps a history of every file, which you do not need, and which will eventually lead to your repository growing very large. Git also will not perform especially well in this situation, compared to virtually any database engine in existence.\nFurthermore, if, despite this advice, you do use one of the major Git hosting platforms for this, they will probably eventually ask you to leave, as making a large number of automated, programmatic commits of data files to a repository causes various problems for hosting repositories, the least of which is the bloat and repacking, since this leads to pathological performance when packing.\nIf you want a reasonably cheap hosting platform, there are many shared web hosting providers around that are just a few dollars a month. However, be aware that if you are dealing with transferring people's money, there are a variety of legal regulations with which you must comply based on the jurisdiction, and you will definitely want to consult an attorney before starting. If you can't afford a server, you probably can't afford to do this legally. Further discussion of this is probably off topic, though.","Q_Score":1,"Tags":"python,git,github","A_Id":66863646,"CreationDate":"2021-03-30T00:36:00.000","Title":"Using Git as a something like a server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a raspberry pi that is connected to an USB printer.\nWhen pressing a physical button a python script is executed. The script itself is very simple.\nIn the end the results should be printed using the usb printer.\nThere are no other peripherals except the printer connected to the raspberry pi. Is there an easy way to print out of the python script?\nPls note: I don\u2019t want to print a document or a file but only the value of a variable calculated by the script.\nIf there is an easy way to do it with a different programming language, that\u2019s of course also viable.\nThank you","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":82,"Q_Id":66866792,"Users Score":-1,"Answer":"there are a few packages for that purpose. the first one can only be used with espon printers, but the others should be fine with any type of printer:\n\npython-escpos\npkipplib\nwin32print","Q_Score":0,"Tags":"python,printing,raspberry-pi,printers,script","A_Id":66866954,"CreationDate":"2021-03-30T07:51:00.000","Title":"How do I Hard print out of my python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to use telethon and telebot to send notification from my code in python.\nI have configureted everythings, but the code ask me the following:\nreceiver = InputPeerUser('user_id', 'user_hash')\nI fund user_id, but I don't understand where I could catch my user_hash.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1334,"Q_Id":66873563,"Users Score":0,"Answer":"You must have an open dialogue with that user. Or you received a message from him. When all the dialogs are loaded, the information of that user comes with it.","Q_Score":4,"Tags":"python,telegram,telegram-bot,telethon","A_Id":66911440,"CreationDate":"2021-03-30T15:05:00.000","Title":"How to find 'user_hash' on telegram?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"HI I am using PHP to execute python script:\npdf.py\nimport pdfkit\npdfkit.from_url('https:\/\/www.google.co.in\/','google.pdf');\ndata.php\nini_set('display_errors', 1);\nerror_reporting(E_ALL ^ E_DEPRECATED);\nexec(\"python pdf.py\");\nI tried executing ython file using php with above data, But script not run .","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":35,"Q_Id":66874231,"Users Score":0,"Answer":"Maybe try exec(\"python pdf.py\", $response, $error_code); and see if anything useful is returned in $response or $error_code?","Q_Score":0,"Tags":"python,php,exec,python-pdfkit","A_Id":66874749,"CreationDate":"2021-03-30T15:48:00.000","Title":"Running Python script from PHP but its not working","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"It would make handling of timeouts much cleaner if FutureTimeoutError had methods like code() and details() etc, the same as, say, _InactiveRpcError does.\nIs this a design decision? Would the grpc community be open to a pull request that changes the implementation of FutureTimeoutError in this way?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":677,"Q_Id":66877355,"Users Score":1,"Answer":"grpc.FutureTimeoutError is the exception raised when a grpc.Future.result or grpc.Future.exception exceeds deadline but haven't got any result. For example, the RPC takes 10 seconds to finish, but we got result(timeout=2). Then the grpc.FutureTimeoutError will be raised to indicate time's up after 2 seconds. And the RPC isn't near finishing at that time, so we can't access code() and details().\nThis is not a RPC issue on either the client or the server, which means grpc.RpcError may not be a good fit for grpc.FutureTimeoutError.","Q_Score":0,"Tags":"python,grpc,grpc-python","A_Id":66892963,"CreationDate":"2021-03-30T19:30:00.000","Title":"why is grpc.FutureTimeoutError not an instance of grpc.RpcError and grpc.Call?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Robot Framework supports two ways to interact with the tests and modify the test structure:\n\nthe visitor internal API\nthe listener API\n\nI 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?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":582,"Q_Id":66890396,"Users Score":1,"Answer":"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.","Q_Score":2,"Tags":"python,robotframework","A_Id":66894693,"CreationDate":"2021-03-31T15:04:00.000","Title":"Wrapping a test case in Robot Framework in keyword based on the tag of a test","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am a PHP developer, tasked to write Python scripts.\nThe script uses requests, which I found to be the easiest Python equivalent to PHP cURL.\nIf you use cURL in PHP, cURL must be enabled on the server, otherwise, the script won't work.\nIs there likewise any activation or enabling necessary in Python to use requests other than import requests?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":424,"Q_Id":66902684,"Users Score":0,"Answer":"Install requests on machine you are going to use it: pip install requests.\nNote if you are on linux you might have 2 versions of python installed: python 2.* and python 3.*\nIf this is the case using pip install will install it for python 2.*, so you should use pip3 install to install it for python 3.\n(I would also suggest using virtualenv, but this is another topic).\nIf package is installed then you can use it in your scripts by simply importing it: import requests\n\nNothing more is needed to enable\/activate libraries(packages). It is the case for all packages in python. (install -> import)","Q_Score":0,"Tags":"python,python-requests","A_Id":66903023,"CreationDate":"2021-04-01T10:18:00.000","Title":"How do I enable Python requests?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a PHP developer, tasked to write Python scripts.\nThe script uses requests, which I found to be the easiest Python equivalent to PHP cURL.\nIf you use cURL in PHP, cURL must be enabled on the server, otherwise, the script won't work.\nIs there likewise any activation or enabling necessary in Python to use requests other than import requests?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":424,"Q_Id":66902684,"Users Score":0,"Answer":"You must also have pip installed on your computer to install the requests module, pip comes installed with python 3.4 and above so you could do something like \"pip install requests\"","Q_Score":0,"Tags":"python,python-requests","A_Id":66902763,"CreationDate":"2021-04-01T10:18:00.000","Title":"How do I enable Python requests?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So, on a Raspberry Pi I'm using a camera app with a web interface, I wanted to add LED lighting by adding a neopixel. I have successfully done this and can now turn it on and off running two python scripts.\nExplanation and question:\nI have a python script in \/usr\/local\/bin that is executable.\nIt is owned by 'root root'.\nI have a shell script in \/var\/www\/html\/macros that is executable and has to run the python script in \/usr\/local\/bin.\nThe shell script is owned by 'www-data'\nWhen I manually run the python file, it executes the script.\nWhen I manually run the shell script, it executes the python script.\nWhen I run the shell script by clicking on a button on my webpage, it seems to execute the shell script correctly, however, it looks like it doesn't execute the python script.\nWhat can I do to fix this?\nI'm not that experienced with permissions, but I wanted to emphasize on the fact that this is a closed system that does not contain any sensitive information. So safety\/best practice is not a concern. I just want to make this work.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":177,"Q_Id":66921554,"Users Score":0,"Answer":"Now, after 11 hours and a group of people thinking along we found a solution to the problem.\nThe problem turned out to be that the Web interface can only execute as 'www-data', and the NeoPixel library that the python script depends on needs to be executed as sudo\/root.\nThese two factors make it so that there will never be a direct way of getting the scripts to work together.\nHowever, the idea emerged to use some sort of pipe.\nA brilliant user suggested to me to use sshpass. This would allow to pass data to ssh and have it essentially be executed as a root user.\nThe data from the web interface would be relayed to the sshpass and this would successfully run the needed scripts with the needed privileges.\nSpecial thanks to Minty Trebor and Falcounet from the RRF for LPC\/STM Discord!","Q_Score":0,"Tags":"python,apache,shell,raspberry-pi,raspbian","A_Id":66925377,"CreationDate":"2021-04-02T15:23:00.000","Title":"How to run a Python script from Apache on Raspberry Pi?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to get a simple script to run on start-up of debian Raspberry Pi where\nstartupTest.py writes the time of run to a .txt file\n$python3 \/home\/pi\/startupTest.py \nruns successfully in command line\n$ python \/home\/pi\/startupTest.py \nruns successfully in command line\nHowever using\n$ sudo crontab -e to write\n@reboot python3 \/home\/pi\/startupTest.py &\nYields\nbash: alias: python: not found\nbash: alias: \/usr\/local\/bin\/python3.8: not found\nbash: alias: python: not found\nbash: alias: \/usr\/local\/bin\/python3.8: not found\nbash: alias: python: not found\nbash: alias: \/usr\/local\/bin\/python3.8: not found\nOkay, am I missing python3.8 in that directory? no\n$ ls \/usr\/local\/bin shows python3.8\nI am a Mechanical Engineering student trying to get a testing system working for my senior design project.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":300,"Q_Id":66935705,"Users Score":2,"Answer":"The problems is when running sudo crontab -e actually that root user runs the script. If in your startupTest.py you do not have any special code that might need sudo privilege, just remove sudo and add your command in crontab -e startup list.","Q_Score":1,"Tags":"python,bash,cron,alias","A_Id":66935786,"CreationDate":"2021-04-03T20:42:00.000","Title":"Bash alias not found during start-up on raspberry pi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have written a Python REST API using FastAPI. It connects to Janus Graph on a remote machine and runs some Gremlin Queries using the GremlinPython API. While writing my unit tests using FastAPI's built in test client, I cannot mock Janus Graph and test my APIs. In the worst case I need to run Janus on docker in my local setup and test there. However, I would like to do a pure unit test. I've not come across any useful documentation so far. Can anyone please help?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":152,"Q_Id":66947065,"Users Score":0,"Answer":"I think running Gremlin Server locally is how a lot of people do local testing. If you do not need to test data persistence you could configure JanusGraph to use the \"inmemory\" backend and avoid the need to provision any storage nodes.","Q_Score":0,"Tags":"python-3.x,gremlin,fastapi,janusgraph,gremlinpython","A_Id":67140525,"CreationDate":"2021-04-05T00:40:00.000","Title":"How to unit test Gremlin Queries on JanusGraph using FastAPI and GremlinPython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Exactly what the title says. I have someone abusing a certain command that I would like to restrict a role that they have from using said command. Is there a ay to do that? and if so, can someone please write the example code?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":178,"Q_Id":66978526,"Users Score":0,"Answer":"under the decorator for your command (@bot.command()) use @commands.has_role(\"roleName\") to limit the command to only that role.","Q_Score":0,"Tags":"python,discord.py","A_Id":66983699,"CreationDate":"2021-04-07T01:47:00.000","Title":"Is there a way for me to disable a command for a certain role in discord.py?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a system that locks several parts in my computer and opens them ONLY using my voice saying specific\nwords (in python). I've already made the system that locks parts in my computer until you give it password but I want to change it to voice.\nI did find some voice processing on the web but its really complicated and without explanation\nin python.\nI know python might not be the right language to do so, but I want to try!\nthanks for any help!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":160,"Q_Id":67006703,"Users Score":0,"Answer":"Python is a good point to start!\nSearch Python Speech recognition in google in you will have a lot of examples for doing that.\nEnjoy!","Q_Score":0,"Tags":"python,voice-recognition,voice,voice-recording","A_Id":69259437,"CreationDate":"2021-04-08T15:00:00.000","Title":"python voice signature identification?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a server. Client can send a path and server should cd to that path. But here is the thing. Imagine I have a test2 directory in test1 directory and the path to test1 directory is C:\\test1. The client can access test2 by cd test2 and \\test1\\test2 and if he wants to go back he can use \\test1 (I searched and found os.chdir but it needs the full path and I don't have it) and he shouldn't be free to send E:\\something or anything like that. Just the directories that are in test1. what do you suggest? what can I use to achieve this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":82,"Q_Id":67012663,"Users Score":0,"Answer":"You can store the default path as a kind of root path and path.join(root, client_path) this way you have a complete path that has to start with C:\\test1\nThe issue you have to overcome is deciding if you have to join the current path or the root path with the client's command. I would first check if the directory exists in the current working directory if not I would try finding it in the \"root\" path","Q_Score":0,"Tags":"python,sockets,directory,cd","A_Id":67012716,"CreationDate":"2021-04-08T22:25:00.000","Title":"Change directory in a server without leaving the working directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"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.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":427,"Q_Id":67041693,"Users Score":0,"Answer":"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\nUsually bots simulate a browser via Sellenium and then create a \"browse like a human\" bot to create likes, follow, unfollow, etc.","Q_Score":0,"Tags":"python,api,instagram-api,facebook-access-token,instagram-graph-api","A_Id":67127196,"CreationDate":"2021-04-11T05:16:00.000","Title":"Is instabot.py safe to use?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"do someone know if there is a way to open a URL when someone write \/start or some command.\nI already tried with requests, but it hasnt worked.\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":455,"Q_Id":67126382,"Users Score":0,"Answer":"You can redirect users to other groups\/chats by providing them with an invite link or the username of the group\/channel in the @username format. If you want that to happen on the press of a button, you can use InlineKeyboardButton by passing the invite link directly to the button, i.e. InlineKeyboardButton(text='some_text', url='http:\/\/t.me\/\u2026'). The URL will open (i.e. redirect the user to the target chat), when the button is clicked.","Q_Score":0,"Tags":"python,telegram,telegram-bot,python-telegram-bot,py-telegram-bot-api","A_Id":67128157,"CreationDate":"2021-04-16T13:45:00.000","Title":"Python Telegram Bot open URL\/join another Telegram Group after pressing telegram.KeyoardButton","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a cpanel host and I want to run my Python script even if close or logout from cpanel.\nMy Python script has get different inputs in at the beginning of the run.\nSo far I've tried nohup and screen, but they neither fixed this.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":119,"Q_Id":67139738,"Users Score":0,"Answer":"So I've been using screen from long and i'm able to run my script even if i close my terminal without terminating process unless until you power off your machine your screen will be running in the background. and you can see the status of your script execution using \"screen -r\"","Q_Score":0,"Tags":"python-3.x,linux,terminal,cpanel,host","A_Id":67142008,"CreationDate":"2021-04-17T15:17:00.000","Title":"Run python file in cpanel terminal after closing terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've write an application in python that saves informations on a txt file, but this is pretty slow, what type of file should I use for saving informations? And can I use the open function or I have to use another to make an high-efficiency transfer of data?\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":21,"Q_Id":67140050,"Users Score":0,"Answer":"I write this answer to mark the question as SOLVED, see the first comment to get the real answer.","Q_Score":1,"Tags":"python,file,bots","A_Id":67150911,"CreationDate":"2021-04-17T15:49:00.000","Title":"What type of file should I use for saving informations for my applications?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is more of a general question but for reference, I read statements like: \"Most of the shared hosting providers do not compile imagick extension with PHP, but imagick binaries will be available\". I don't know what is meant by \"imagick extension\" and \"imagick binaries\"? To me, any non-txt file is a binary. Also, when we install a library like \"imagick\", are both these kinds of version installed? And what is the difference between them?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":48,"Q_Id":67140895,"Users Score":1,"Answer":"\"Imagick extension\" is the optional component of PHP that adds Imagick-related functions to the language.\n\"binaries\" means programs that are compiled to machine code, as opposed to source code or scripts.\nSo they're saying that you won't be able to use the built-in Imagic functions in PHP, but you could execute the external programs using methods like shell_exec().","Q_Score":0,"Tags":"php,webserver,python-imaging-library,imagick","A_Id":67140927,"CreationDate":"2021-04-17T17:14:00.000","Title":"what is meant by extension and binary file of a library?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I\u2019m relatively knew to the selenium package and have been using it for a couple weeks. My current script uses selenium to scrape data, I analyze the data by running a few tests, and if there is a datastring that passes said tests python texts me using Twilio. I\u2019m currently using my mac to run all of this but I was looking to run this script every 5 minutes, headless, and on a platform such that I dont need to keep my computer on. I have been looking at some potential solutions and it seems as though running this on a headless raspberry pie is the right option. I was wondering if anyone see\u2019s any potential problems with doing so as I haven\u2019t seen a thread with someone using Twilio? And, I\u2019ve encountered problems trying to set up a cron task to automate it on my mac because of selenium and was wondering if this will be possible on the pi (looking at the raspberry pi 4)? Sorry, if this is a little long winded, appreciate the help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":80,"Q_Id":67143080,"Users Score":0,"Answer":"Run the script though any CI CD tools like Jenkins ,GoCD,Gitlab in a scheduled job so that the script would run in every 5 minutes in Agent node specified and you don't have to keep your computer on.","Q_Score":1,"Tags":"python,selenium,raspberry-pi,scheduled-tasks","A_Id":67144465,"CreationDate":"2021-04-17T21:23:00.000","Title":"Running Selenium Automated Scrips on Raspberry Pi 4","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to know how to get the first message in a channel.\nBut more preferably could you point me to the part of the documentation that explains this, please?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":511,"Q_Id":67154885,"Users Score":2,"Answer":"TextChannel has a history method.\nIf 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.","Q_Score":0,"Tags":"python,python-3.x,discord,discord.py","A_Id":67155078,"CreationDate":"2021-04-19T01:17:00.000","Title":"How to get the first message in a channel","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In my project, I need to use two telegram bots, which are linked by one database. I faced the following difficulty: having received a photo_id from one bot, I can only use it in this bot, the other bot does not have access to the files.\nApiTelegramException: A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: wrong file identifier\/HTTP URL specified\nAt the same time, exactly the same line of code in the first bot successfully sends a photo\nIf I try to make an URL with this file, then it is downloaded, therefore, you will not be able to send a photo via the link.\nIs it possible to use documents received from another bot without saving them to the database?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":335,"Q_Id":67164791,"Users Score":-1,"Answer":"Yes... well maybe. Are you trying to avoid writing to the database to avoid writing to the database specifically or are you trying to avoid any further file handling?\nIf you are trying to avoid the database because its a database - my proposal would need you to create a shared memory space to do so. Maybe others know of easier ways.\nTry memcache or redis. Both have python libraries, I'd personally go with redis due to my own experiences.\nI don't know what your architecture is like for checking for updates - I assume you have some kind of scheduler ongoing? In which case you check redis\/memcache for updates periodically, download\/retransmit the data if it exists, then clear it.","Q_Score":1,"Tags":"python,telegram","A_Id":67165602,"CreationDate":"2021-04-19T15:21:00.000","Title":"How to connect two or more telegram bots for file exchange","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I connect to outlook.office365.com for synchronizing emails by library IMAPClient (Python). By IDLE mechanizm I receive changes on server for example new email in folder INBOX. After that I fetch for mails with UID {last_synced_uid}:* - this should give me all mails after last sync (UID are always incremented).\nThis flow works but from time to time IMAP server (outlook.office365.com) does not return new mail but already synchronised. Running full synchronization sometimes work but not always - I mean search mails after date and fetching by UID.\nIn this situation I manually move mail from INBOX to other folder and move again to INBOX and this always works - after that my script detects new mail in INBOX and fetch with UID {last_synced_uid}:*\nIt looks like Office365 sometimes has problem with fetching by UID.\nThe same mail is visible in other mail client like thunderbird so maybe there is some workaround or it is a bug in IMAPClient\/imaplib\nBelow logs for monitoring folder where last_synced_uid is 1619:\n\nIDLE RESPONSE: [(10, b'RECENT'), (618, b'EXISTS')]\nstart FETCH UIDs 1620:*\nFETCH returns mail with UID 1619, SEQ 617\nlast_synced_uid 1619 did not changed","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":335,"Q_Id":67166529,"Users Score":0,"Answer":"I will answer my own question - selecting the same folder on IMAP connection many times could generate this problem.","Q_Score":0,"Tags":"python,office365,imap,imapclient","A_Id":67602332,"CreationDate":"2021-04-19T17:18:00.000","Title":"Office365 IMAP sometimes fetching new emails not working","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed Python38 on aws EC2 linux, and set it as default by running sudo alternatives --set python \/usr\/bin\/python3.8, but still not working. Python2.7 still the default.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":86,"Q_Id":67166945,"Users Score":0,"Answer":"Python is preinstalled on Linux as python 2.7. To run python 3 use the command python3 script.py. This calls upon the python 3 interpreter while python script.py calls upon the python 2.7 interpreter.","Q_Score":0,"Tags":"python-3.x","A_Id":67167990,"CreationDate":"2021-04-19T17:51:00.000","Title":"Python3 not set as default on AWS EC2 linux","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"This problem is making me crazy! I need to send a CSV file from one raspberry pi to another raspberry pi via bluetooth,\nThe CSV file will be about max 4MB, I have no problem with changing the language if anyone have a better solution.\nBy the way, I can't read the csv and send it line by line, I don't need that, I need to send just one file, like a compress file, to process it in the other raspberry.\nThank you very much! I will appreciate any help!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":69,"Q_Id":67187828,"Users Score":0,"Answer":"Could you use SCP to copy it over on the command line?","Q_Score":0,"Tags":"python,bluetooth,raspberry-pi,communication","A_Id":67196447,"CreationDate":"2021-04-21T00:22:00.000","Title":"Send CSV from raspberry pi3 to raspberry pi 3 with python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently implementing redis PUB\/SUB in one of my project, and it raises a concern to me, what's the size limitation of a message when PUB\/SUB in Redis channel. Was the limit equal to the available memory of the computer? or there will be a threshold in somewhere of config file. Thanks!","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":636,"Q_Id":67202021,"Users Score":2,"Answer":"Just for your information, I experimented myself, the approximate ceiling size is around 21MB to 22MB on my machine (Debian 5.4.8-1) (it may vary depends on the OS and redis version), it will cause a redis ConnectionError: Connection closed by server.","Q_Score":2,"Tags":"python,redis,publish-subscribe","A_Id":67219703,"CreationDate":"2021-04-21T19:04:00.000","Title":"What's the size limitation of a message when PUB\/SUB in Redis channel","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I created a py and compiled it to exe by auto-py-to-exe and later my antivirus (Avira)\ndetected it as a virus which is not, to be cleared I know I can send false positive and that stuff to Avira lab but I just want to know for my future programs how should I encode or obfuscate (which software, package, or any suggestion) my program so after compiling to exe doesn't encounter this problem","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":355,"Q_Id":67211821,"Users Score":0,"Answer":"I agree with Neo's response (May 3, 2021). Most info out there nowadays tries to offer workarounds but I find they don't work. And it doesn't matter if you are able to reduce the false flag count down a bit as it just takes one or two counts to create a major headache for you... This needs to be addressed by the python community. If the py script file comes up clean and then you convert to exe and it is flagged, there is something with the compile\/wrap that is the issue. That exe conversion process needs to be fixed\/addressed.","Q_Score":1,"Tags":"python,encoding,pyinstaller,virus","A_Id":71443199,"CreationDate":"2021-04-22T10:52:00.000","Title":"How to encode py program to not detected as a virus after compiling to exe?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When waiting for an event with discord.py you can use commands.Bot.wait_for('message', timeout=30, check=check) or something similar with 'reaction_add'.\nIs there a way to wait for a message OR reaction? The only way I can think of is starting another thread and running two commands.Bot.wait_for() at the same time, but that seems really scuffed.\nIf there is a method that allows you to wait for multiple types of events that'd be great to know. If anyone has any ideas please let me know.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":636,"Q_Id":67221036,"Users Score":0,"Answer":"Use commands.Bot.add_listener(function, 'on_message') to create a listener, and when the commands.Bot.wait_for passes or times out, remove the listener.","Q_Score":0,"Tags":"python,discord,discord.py","A_Id":67221239,"CreationDate":"2021-04-22T21:32:00.000","Title":"How do you wait for multiple types of events in discord.py?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was wondering for my project if Telegram could send me a delay or ban if I'm using two Telethon scripts each of them connecting to a different Telegram account in the same machine?\nThey will just be reading messages, nothing too fancy. At the moment one has been running without any issues.\nThank you","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":147,"Q_Id":67234344,"Users Score":1,"Answer":"There is no limit on the number of different accounts you can have on the same IP\/machine. Telegram uses sockets to connect so if a limit existed it would be related to the number of active connections your machine can handle.","Q_Score":1,"Tags":"python,telegram,telethon","A_Id":67234479,"CreationDate":"2021-04-23T17:17:00.000","Title":"Is there any potential problem when using two Telethon scripts for two different Telegram accounts in the same IP?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a project that just scrapes data from 3 devices (2xserial and 1xssh). I have this part implemented no problem.\nI 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.\nThe customer has provided examples of their GRPC servers, and it's written in C#.\nCurrently, 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.\n\nHere are my main questions, and I apologize if I got nowhere.\n1.) 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.\n2.) 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.\n3.) 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?).\nAny advice would be appreciated. I am looking to seek more knowledge outside my realm.\nCheers,\nZ","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":332,"Q_Id":67237330,"Users Score":0,"Answer":"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.\nThat said: if you want to learn some new bits, option 1 (using C# in your system) is also very viable.\nIMO option 2 is the worst of all worlds.","Q_Score":1,"Tags":"python,c#,protocol-buffers,grpc,redhat","A_Id":67240519,"CreationDate":"2021-04-23T22:05:00.000","Title":"GRPC: Sending messages from Python to C#, best method?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am already using robot framework to automate my tests using cygwin installed on windows ( i am not the admin).\nWindow 7\nPython 3.8\nI have succefully installed eclipse red editor howevet when i tried to add the path of my cygwin python interpreter in eclipse red editor preferences I failed,\nit shows only the entry Path and a \"unkown type\" , while it is supposed to recognize python and robot version.\nI tried to double check the path, i have tested the python robot command in the cygdrive bin and it is working.\nThe only thing that works in RED is when i have added an external tool config that points to python command in cygwin bin.\nBut this solution is not optimal becausei could not run an individual test, while in Red it is possible to selec and run it in the GUI.\ndid someone managed to make red work with python interpreter of cygwin?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":67,"Q_Id":67239922,"Users Score":0,"Answer":"Finally I manged to run robot from red gui by changing the name of the executable to python.exe","Q_Score":0,"Tags":"python,eclipse,cygwin,robotframework","A_Id":67269004,"CreationDate":"2021-04-24T06:28:00.000","Title":"red editor eclipse with python interpreter incygwin","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm not sure what to search for this.\nI am writing a piece of code using python fire to create a command line interface.\npython test.py function argument\nis there a way to make the shell interpret the following like the command above:\ntest function argument\nSimilar to how I can just call jupyter lab and it will open a notebook etc.\nI have a feeling this is more to do with setting up my bashrc or similar instead of something I can do in Python.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":52,"Q_Id":67258005,"Users Score":0,"Answer":"Add the hashbang (at the start of the file, in case you don't know) \n#!\/usr\/bin\/env python \nor\n#!\/usr\/bin\/env python3\nReplace the 3 with whatever version you have installed and want that file to run\nSave the file to an already existing PATH or add the file location to PATH\nNow you can hopefully run it by typing test.py function argument\nRename test.py to test \nNow you should be able to run it as test function argument\nAlso make sure your file is set as executable","Q_Score":1,"Tags":"python,linux,python-fire","A_Id":67258132,"CreationDate":"2021-04-25T20:32:00.000","Title":"Command line interface for python module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm not sure what to search for this.\nI am writing a piece of code using python fire to create a command line interface.\npython test.py function argument\nis there a way to make the shell interpret the following like the command above:\ntest function argument\nSimilar to how I can just call jupyter lab and it will open a notebook etc.\nI have a feeling this is more to do with setting up my bashrc or similar instead of something I can do in Python.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":52,"Q_Id":67258005,"Users Score":0,"Answer":"You're correct that it has to do with adding to your .bashrc. You want to set an alias.\n\nMake sure your code has an appropriate shebang line at the top, ex. #!\/usr\/bin\/python3\nAdd the following to .bashrc, ex. alias test=python3 \/path\/to\/test.py\n\nFrom there, you can use sys.argv in your code to handle arguments within the program.","Q_Score":1,"Tags":"python,linux,python-fire","A_Id":67258041,"CreationDate":"2021-04-25T20:32:00.000","Title":"Command line interface for python module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"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)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":104,"Q_Id":67286450,"Users Score":0,"Answer":"At the moment it isn't possible, you can only stream audio.","Q_Score":1,"Tags":"python,discord.py","A_Id":67286558,"CreationDate":"2021-04-27T15:50:00.000","Title":"how to make a video stream bot for discord.py?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"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?\nI tried to find out how to do it but I have not managed to find something similar on internet, even on stack overflow.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":100,"Q_Id":67299823,"Users Score":0,"Answer":"It happens that zoom will share a video in the way that you want.","Q_Score":0,"Tags":"python,api,youtube","A_Id":67604712,"CreationDate":"2021-04-28T11:58:00.000","Title":"how to make a discord bot in python that can show a youtube video?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have two USB to CAN devices (can0 and can1), they both are connected to a Linux machine which has socketcan installed in it. I have read the basics of CANopen protocol, i have not seen any example that can establish communication between two CANopen devices using Python CANopen library.\nI read in the documentation that each devices must have a .eds file, so I took a sample .eds file from the Python CANopen library from christiansandberg github and trying to establish communication and make them talk to each other using PDO's, but I could not able to do that.\nWe have a battery and wanted to communicate with it, the battery works on can-open protocol and they have provided the .eds file for the battery. I guess a usb2can device with the CANopen Python library can do the work. But I just don't know how to establish communication between the usb2can device and the battery. It would be helpful with any insights in framing the packets.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":760,"Q_Id":67318027,"Users Score":1,"Answer":"This is what you need to do:\n\nGet the necessary tools for CAN bus development. This means some manner of CAN listener in addition to your own application. It also means cables + terminating resistors. The easiest is to use DB9 dsub connectors. An oscilloscope is also highly recommended.\nRead the documentation about the device to figure out how to set node id and baudrate, or at least which default settings it uses.\nFind out which Device Profile the device uses, if any. The most common one is CiA 401 \"generic I\/O module\". In which case the default settings will be node id 1, baudrate 125kbps.\nYour application will need to act as NMT Master - network managing master - on this bus. That is, the node responsible for keeping track of all other nodes.\nIf the device is CANopen compliant and you've established which baudrate and node id it uses, you'll get a \"NMT bootup\" message at power up. Likely from node 1 unless you've changed the node id of the device.\nYou'll need to send a \"NMT start remote node\" message to the device to bring it from pre-operational to operational.\nDepending on what Device Profile the device uses, it may now respond with sending out all its enabled PDO data once, typically with everything set to zero.\nNow check the documentation of the device to find out which data that resides in which PDO. You'll need to match TPDO from the device with RPDO in your application and vice versa. They need to have the same COBID - CAN identifiers, but also the same size etc.\nCOBID is set in PDO communication settings in the Object Dictionary. If you need to change settings of the device, it needs to be done with SDO access of the device Object Dictionary.\nMore advanced options involve PDO mapping, where you can decide which parts of the data you are interested in that goes into which PDO. Not all devices support dynamic PDO mapping - it might use static PDO mapping in which case you can't change where the data comes out.\nOther misc useful stuff is the SAVE\/LOAD features of CANopen in case the device supports them. Then you can store your configuration permanently so that your application doesn't need to send SDOs at start-up for configuration every time the system is used.\nHeartbeat might be useful to enable to ensure that the device is up and running on regular basis. Your application will then act as Heartbeat consumer.","Q_Score":0,"Tags":"pdo,can-bus,canopen,python-can","A_Id":67330251,"CreationDate":"2021-04-29T13:06:00.000","Title":"CANopen protocol communication between two nodes using python canopen package","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"1: When it says 15 requests per 15 minute window, does this really mean I can only send 15 requests per 15 minutes?\n2: Do I really need to set up a Twitter bot to send basic requests like getting a list of a user's followers? Is there a way to get the data through a URL, like in most web APIs? I'm making software that will be used by other people, so it can't have a bot auth token in the code.\nI know I'm pretty much asking if what it blatantly says is true, but I'm just having trouble believing that the Twitter API is really this bad.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":67336766,"Users Score":0,"Answer":"It sounds like you are specifically asking about the friends and followers endpoints. Yes, this is limited to 15 requests in a 15 minute window. Other endpoints \/ features have different rate limits.\n\nThe Twitter API requires authentication. You do not need to set up a \"bot\", but you will need a registered Twitter developer account, and a Twitter app, in order to use the API. If your app will be used by other people, you would need to implement Sign-in with Twitter to enable them to authenticate with your app; you can then store their access token (until or unless they revoke it) to make requests on their behalf. This is pretty standard for any multi-user web app.","Q_Score":0,"Tags":"twitter,twitterapi-python","A_Id":67337161,"CreationDate":"2021-04-30T15:42:00.000","Title":"Questions about the Twitter API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm looking for a way for a bot to wait for a reply from a user after a command. For example, you first type \"\/ask\", then the bot waits for a plain message (not a command) from the user and after the user replies is stores his\/her reply in a variable\nI'm sure this is quite simple, but all the tutorials I've seen are in Russian and the documentation for python-telegram-api is very chaotic and I'm not the most advanced\nIf I'm dumb, sorry, just please help a fellow beginner out","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":782,"Q_Id":67344301,"Users Score":1,"Answer":"Okay, this was pointless. I thought you couldn't use arguments, but the post I read was 5 years old so... I'm stupid. I just used arguments instead, thanks for the help tho, really appreciate it","Q_Score":3,"Tags":"python,telegram-bot,python-telegram-bot","A_Id":67345719,"CreationDate":"2021-05-01T08:33:00.000","Title":"Telegram bot await reply from user after command Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm getting this error: AttributeError: module 'trio.lowlevel' has no attribute 'FdStream'. FdStream isn't in the trio code on git nor in my installation. Is there an alternative to this, or is there a different version I did't find?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":74,"Q_Id":67371643,"Users Score":1,"Answer":"That attribute is only available on non-Windows platforms. If your friend made the function compatible with only Linux\/macos, you will need to run the function on a Posix platform as well.","Q_Score":0,"Tags":"python,python-trio","A_Id":67371790,"CreationDate":"2021-05-03T15:30:00.000","Title":"I got a trio input function from a friend and it's trying to use trio.lowleve.FdStream, however I can't find it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"TLDR:\nIs there a way to create a hex value between 0x20 and 0x7E with 5 volts? Is there a cheap component on the market or circuit logic that can achieve this?\nI'm not sure what the proper terminology for this is, but here's what I'm trying to do:\nI have a bluetooth module connected to my pico via UART0 TX and UART0 RX. The use for this is a bit long to explain, but essentially, I want the bluetooth module to work without my pico attached to it. I have a device that outputs a signal, the pico reads the signal, then it tells the bluetooth module to transmit to the receiver. However, since the data to transmit isn't actually important, it makes sense to cut out the pico and simply have the bluetooth module read the signal directly then transmit.\nI have the device that outputs exactly when I want, but it outputs the equivalent of 00 in hex. My computer is connected via bluetooth and can read it just fine. However, the pico, reading the input through RX, can't. I've found no way for micropython using UART to read 00 - UART.any() and UART.read() want a character, and 00 only corresponds to NULL.\nSo essentially, I need some way to transmit a hex value between 0x20 and 0x7E without using the raspberry pi pico. Is there some kind of component that is able to do this? In practice, the bluetooth module will be connected to 5V power with up to 5 amps.\nAny idea on how to get the Pico to read 00 in hex through the RX pin is welcomed too. The purpose of this is to not need multiple Picos, since the receiver and the transmitter will be a good distance from each other.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":59,"Q_Id":67394926,"Users Score":1,"Answer":"I found the issue. The pico actually can accept 0 through the UART RX pin. The issue was me having a wire misplaced. My computer saw the 0 input which made me think the pico couldn't handle it, but in fact it was never receiving it. Thanks for the help Kotzjan. Would have been interesting to fake a value into the port though!","Q_Score":0,"Tags":"bluetooth,micropython,raspberry-pi-pico","A_Id":67407788,"CreationDate":"2021-05-05T03:44:00.000","Title":"Component that can create a hex value?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I followed the official mediapipe page but without any result so can someone help to install mediapipe in raspberry pi 4 in windows it is easy to install it and use it but in arm device like raspberry pi i did not find any resources.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":7421,"Q_Id":67410495,"Users Score":0,"Answer":"I ran the command sudo pip3 install media pipe-rpi4. This worked. When I try to import the module in python I get ModuleNotFoundError: No module named \u2018mediapipe.python._framework_bindings\u2019","Q_Score":5,"Tags":"python-3.x,deep-learning,raspberry-pi4,mediapipe","A_Id":70965111,"CreationDate":"2021-05-06T00:44:00.000","Title":"how to install and use mediapipe on Raspberry Pi 4?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I followed the official mediapipe page but without any result so can someone help to install mediapipe in raspberry pi 4 in windows it is easy to install it and use it but in arm device like raspberry pi i did not find any resources.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":7421,"Q_Id":67410495,"Users Score":1,"Answer":"if you use python3 you can try sudo pip3 install mediapipe-rpi4","Q_Score":5,"Tags":"python-3.x,deep-learning,raspberry-pi4,mediapipe","A_Id":70729637,"CreationDate":"2021-05-06T00:44:00.000","Title":"how to install and use mediapipe on Raspberry Pi 4?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I created a instagram bot to search for hashtags, like the posts, comment and follow the accounts from the posts but it can't even get to the point of login into the account. I have Instapy and selenium installed but I keep running into errors concerning webdriver please help with how to solve the problem.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":37,"Q_Id":67422441,"Users Score":0,"Answer":"Post the error output; difficult to figure out otherwise.","Q_Score":0,"Tags":"python,instapy","A_Id":67422597,"CreationDate":"2021-05-06T16:37:00.000","Title":"what must be installed first for instapy to run without errors?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"from tweepy import *\nfrom tweepy.streaming import StreamListener\n------getting this error------\nUnused import api from wildcard importpylint(unused-wildcard-import)\nUnused import debug from wildcard importpylint(unused-wildcard-import)\nUnused import AppAuthHandler from wildcard importpylint(unused-wildcard-import)\nUnused import Cache from wildcard importpylint(unused-wildcard-import)\nUnused import FileCache from wildcard importpylint(unused-wildcard-import)\nUnused import MemoryCache from wildcard importpylint(unused-wildcard-import)\nUnused import Cursor from wildcard importpylint(unused-wildcard-import)\nUnused import RateLimitError from wildcard importpylint(unused-wildcard-import)\nUnused import TweepError from wildcard importpylint(unused-wildcard-import)\nUnused import DirectMessage from wildcard importpylint(unused-wildcard-import)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":63,"Q_Id":67425764,"Users Score":0,"Answer":"These are Pylint warnings, not errors.\nThe Tweepy import itself should still have been successful.","Q_Score":0,"Tags":"python,wildcard,tweepy,twitter-oauth,twitter-streaming-api","A_Id":67432558,"CreationDate":"2021-05-06T20:48:00.000","Title":"In Python during importing Tweepy library like | from tweepy import * getting error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking for an api that shows me the latest binance smart chain tokens, is there such a thing available or do I need to run the binance smart chain node for this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":176,"Q_Id":67426271,"Users Score":0,"Answer":"There is no such api, but you may want to track all new transactions in Binance Smart Chain and check if a new contract was created.","Q_Score":0,"Tags":"python,api,blockchain,binance","A_Id":70640270,"CreationDate":"2021-05-06T21:38:00.000","Title":"API showing new Binance Smart Chain Tokens","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to create bot in python with referral feature but I didn't get any method to create referral links for user in telegram docs. can you suggest any alternative approach for it. so that we can create a link and any new member can follow that link to start bot and referral got registered in referrers account.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1583,"Q_Id":67432314,"Users Score":0,"Answer":"Try to use some redirect method in your webserver code.\n\nGenerate the referral link and save in some storage\nWhen user open the link, after check method redirect to bot","Q_Score":1,"Tags":"python,telegram-bot,refer","A_Id":67433001,"CreationDate":"2021-05-07T09:27:00.000","Title":"is there any method or api available to create unique referral link for telegram bot with python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently studied that \"byte code\" is closer to machine language but it is a code that is not a machine language. Why we need to take an intermediate step between converting the programming language and then comes the binary code which is I am not getting like is it 10101?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":318,"Q_Id":67467615,"Users Score":0,"Answer":"The bytecode name is derived from an instruction set that has a one-byte opcode followed by optional parameters. Bytecode is the intermediate form between compiled machine code and text. It is created using the programming language when saved, and for easy interpretation, or to reduce hardware and operating system dependency, by allowing the same type of code to be run on platforms. different platforms. Bytecode can usually be executed directly or on a virtual machine (a \"p-code computer\" or interpreter), or it can be further compiled into machine code for better performance.","Q_Score":0,"Tags":"python,bytecode,interpreter","A_Id":67467736,"CreationDate":"2021-05-10T09:02:00.000","Title":"What is the difference between \"binary code\" and \"byte code\"?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently studied that \"byte code\" is closer to machine language but it is a code that is not a machine language. Why we need to take an intermediate step between converting the programming language and then comes the binary code which is I am not getting like is it 10101?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":318,"Q_Id":67467615,"Users Score":0,"Answer":"Byte code you can say is compiled code and its platform independent thus can run anywhere if it would be machine code which is different for each platform,this is the reason we take intermediate steps to convert convert the compiled code into the machine code at runtime","Q_Score":0,"Tags":"python,bytecode,interpreter","A_Id":67468098,"CreationDate":"2021-05-10T09:02:00.000","Title":"What is the difference between \"binary code\" and \"byte code\"?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently studied that \"byte code\" is closer to machine language but it is a code that is not a machine language. Why we need to take an intermediate step between converting the programming language and then comes the binary code which is I am not getting like is it 10101?","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":318,"Q_Id":67467615,"Users Score":1,"Answer":"Byte code is considered as the intermediate-level code between the source code and machine code. It is a low-level code that is the result of the compilation of a source code(programming language) which is written in a high-level language.It targets a virtual machine rather than a specific computer architecture. Bytecode allows a single compiled binary to run, and perform with almost native efficiency, on a diverse array of platforms.\nMachine code(binary code) is in binary (0\u2019s and 1\u2019s) format which is completely different from the byte code and source code. It is regarded as the most lowest-level representation of the source code. Machine code is obtained after compilation or interpretation. It is also called machine language.Machine code is a set of instructions in machine language.\nA virtual machine converts the bytecode into machine code.Furthermore, the main difference between machine code and bytecode is that the processor or the CPU can directly execute the machine code. On the other hand, after compiling the source code the bytecode is created. The virtual machine can execute it.","Q_Score":0,"Tags":"python,bytecode,interpreter","A_Id":67468608,"CreationDate":"2021-05-10T09:02:00.000","Title":"What is the difference between \"binary code\" and \"byte code\"?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to mimic the function that my keyboard's rgb software does using a piece of python code so I need to find what info the software sends to the keyboard.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":67470158,"Users Score":0,"Answer":"you can use the Event Viewer if you are using Windows 10.\nStart Windows Event Viewer through the graphical user interface. Use the below steps to open Event Viewer on Windows:\n\nOpen Event Viewer by clicking the Start button.\nClick Control Panel.\nClick System and Security.\nClick Administrative Tools.\nClick Event Viewer.","Q_Score":0,"Tags":"python,python-3.x,usb,libusb","A_Id":67470233,"CreationDate":"2021-05-10T12:08:00.000","Title":"how to find what information is being sent to a usb device by a software?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm making a cyberbullying detection discord bot in python, but sadly there are some people who may find their way around conventional English and spell a bad word in a different manner, like the n-word with 3 g's or the f word without the c. There are just too many variants of bad words some people may use. How can I make python find them all?\nI've tried pyenchant but it doesn't do what I want it to do. If I put suggest(\"racist slur\"), \"sucker\" is in the array. I can't seem to find anything that works.\nWill I have to consider every possibility separately and add all the possibilities into a single dictionary? (I hope not.)","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":224,"Q_Id":67471755,"Users Score":0,"Answer":"You could try looping through the string that you are moderating and putting it into an array.\nFor example, if you wanted to blacklist \"foo\"\nx=[[\"f\",\"o\",\"o\"],[\" \"], [\"f\",\"o\",\"o\",\"o\"]]\nthen count the letters in each word to count how many of each letter is in each word:\ny = [[\"f\":\"1\", \"o\":\"2\"], [\" \":\"1\"], [\"f\":\"1\", \"o\":\"3\"]]\nthen see that y[2] is very similar to y[0] (the banned word).\nWhile this method is not perfect, it is a start.\nAnother thing to look in to is using a neural language interpreter that detects if a word is being used in a derogatory way. A while back, Google designed one of these.\nThe other answer is just that no bot is perfect.\nYou might just have to put these common misspellings in the blacklist.\nHowever, the automatic approach would be awesome if you got it working with 100% accuracy.","Q_Score":2,"Tags":"python,security","A_Id":67471979,"CreationDate":"2021-05-10T13:52:00.000","Title":"how do i make python find words that look similar to a bad word, but not necessarily a proper word in english?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm making a cyberbullying detection discord bot in python, but sadly there are some people who may find their way around conventional English and spell a bad word in a different manner, like the n-word with 3 g's or the f word without the c. There are just too many variants of bad words some people may use. How can I make python find them all?\nI've tried pyenchant but it doesn't do what I want it to do. If I put suggest(\"racist slur\"), \"sucker\" is in the array. I can't seem to find anything that works.\nWill I have to consider every possibility separately and add all the possibilities into a single dictionary? (I hope not.)","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":224,"Q_Id":67471755,"Users Score":0,"Answer":"Unfortunately, spell checking (for different languages) alone is still an open problem that people do research on, so there is no perfect solution for this, let alone for the case when the user intentionally tries to insert some \"errors\".\nFortunately, there is a conceptually limited number of ways people can intentionally change the input word in order to obtain a new word that resembles the initial one enough to be understood by other people. For example, bad actors could try to:\n\nduplicate some letters multiple times\nadd some separators (e.g. \"-\", \".\") between characters\ndelete some characters (e.g. the f word without \"c\")\nreverse the word\npotentially others\n\nMy suggestion is to initially keep it simple, if you don't want to delve into machine learning. As a possible approach you could try to:\n\nmanually create a set of lower-case bad words with their duplicated letters removed (e.g. \"killer\" -> \"kiler\").\n\nmanually\/automatically add to this set variants of these words with one or multiple letters missing that can still be easily understood (e.g. \"kiler\" +-> \"kilr\").\n\nextract the words in the message (e.g. by message_str.split())\n\nfor each word and its reversed version:\na. remove possible separators (e.g. \"-\", \".\")\nb. convert it to lower case and remove consecutive, duplicate letters\nc. check if this new form of the word is present in the set, if so, censor it or the entire message\n\n\nThis solution lacks the protection against words with characters separated by one or multiple white spaces \/ newlines (e.g. \"killer\" -> \"k i l l e r\").\nDepending on how long the messages are (I believe they are generally short in chat rooms), you can try to consider each substring of the initial message with removed whitespaces, instead of each word detected by the white space separator in step 3. This will take more time, as generating each substring will take alone O(message_length^2) time.","Q_Score":2,"Tags":"python,security","A_Id":67472358,"CreationDate":"2021-05-10T13:52:00.000","Title":"how do i make python find words that look similar to a bad word, but not necessarily a proper word in english?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to check if my Discord bot has permission to join a voice channel before attempting to connect to it. I'm using the Python discord API. I tried passing in the Bot.user object to VoiceChannel.permissions_for() function but it requires a Member object.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":287,"Q_Id":67475387,"Users Score":0,"Answer":"To get member object for the bot user, you can use ctx.guild.me. It will return the member object if command is called in a guild.","Q_Score":0,"Tags":"python,discord,discord.py","A_Id":67475999,"CreationDate":"2021-05-10T17:52:00.000","Title":"How to check if my bot has permission to view a voice channel before trying to join it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I try to refactor variables using the Rename Symbol action, the variable is not refactored, and a tooltip pops up that says \"No result.\" There are no error messages, or any other indication that something is wrong.\nVS Code was recently updated to ver 1.56.1, and along with this update came a switch to Pylance. Before this update, Rename Symbol worked, but now it doesn't work on Remote-SSH, Remote-WSL, or local workspaces. On Remote-WSL in particular, pressing F2 will not even display the refactor dialogue box.\nI have tried restarting the Python Language Server, restarting VS Code, and restarting my PC, but nothing has worked. I would like to continue using Pylance if possible.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":540,"Q_Id":67495056,"Users Score":0,"Answer":"With the new update (1.56.2), the problem had been fixed.","Q_Score":2,"Tags":"python,visual-studio-code,pylance","A_Id":67538544,"CreationDate":"2021-05-11T22:21:00.000","Title":"Rename Symbol (F2) returns \"No result.\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Situation: My AWS Lambda analyze a given file and return cleaned data.\nInput: path of the file given by the user\nOuptut: data dictionnary\nActually in my lambda I:\n\nsave the file from local PC to an s3\nload it from the s3 to my lambda\nanalyze the file\ndelete it from the s3.\n\nCan I simplify the process by loading in the lambda \"cash memory\" ?\n\nload it from local PC to my lambda\nanalyze the file","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":78,"Q_Id":67500929,"Users Score":0,"Answer":"First of all, you might use the wrong pattern. Just upload file to S3 using AWS SDK and handle lambda with S3:CreateObject event.","Q_Score":0,"Tags":"python,amazon-web-services,aws-lambda","A_Id":67501770,"CreationDate":"2021-05-12T09:31:00.000","Title":"AWS Lambda Python: Can I load a file from local PC when calling my lambda?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to automate a python script using crontab and reads many tutorials but unable to get in. I'm on AWS linux instance and wants to run my py file in every 45 minutes. My crontab have following lines\n*\/45 * * * * \/usr\/bin\/python3 \/home\/ec2-user\/Project-GTF\/main.py\nand also listing of jobs by crontab -l shows above line\nLet's assume my main.py files contains a single print statement print(\"Hello World\")\nAnd I also use tmux to alive my terminal all the time.\nI suppose that my terminal prints Hello World in every 45 mins but not :( can anyone suggest what's wrong I doing. I don't know much more about cron and never automate a single cron job in my life span :[","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":170,"Q_Id":67506627,"Users Score":2,"Answer":"Traditionally, stdout and stderr from cron jobs have been emailed to their owner, though on present-day systems where email accounts are dissociated from unix accounts, this has become a bit fuzzy. Your best bet is probably to explicitly redirect output to a file.\n(It's possible that there is some AWS specific answer to this, in which case, this being the Internet, someone is sure to tell us. :-) )","Q_Score":0,"Tags":"python-3.x,amazon-ec2,cron,cron-task","A_Id":67506750,"CreationDate":"2021-05-12T15:27:00.000","Title":"How to use cron with tmux session?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've been trying to control a mg995 Servo by changing the duty Cycle with the RPi.GPIO library, but the Servo ended up shaking a lot. I've been reading a lot of Threads about this issue and I know, that using the RPi.GPIO library is causing the issue.\nI then tried to use the pigpio library but it's unfortunately not available for the RP4.\nI know that buying a specific hardware could help out but I want to try it with software first.\nIs there another way to controll a Servo without the shaking? I want to run the Servo through python code btw","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":135,"Q_Id":67510361,"Users Score":1,"Answer":"If the driving is not done at a too high PWM frequency then you can create a solution by using SYSFS driver, if you need high frequency the problem is maybe hardware and not software to control at the oscilloscope. If you are able and want to do without any lib then you can write directly the gpio registers of the SOC through memory-map with mmap","Q_Score":0,"Tags":"python,raspberry-pi,hardware,gpio,servo","A_Id":67510509,"CreationDate":"2021-05-12T20:07:00.000","Title":"Raspberry Pi 4 controlling a Servo without shaking","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been trying to control a mg995 Servo by changing the duty Cycle with the RPi.GPIO library, but the Servo ended up shaking a lot. I've been reading a lot of Threads about this issue and I know, that using the RPi.GPIO library is causing the issue.\nI then tried to use the pigpio library but it's unfortunately not available for the RP4.\nI know that buying a specific hardware could help out but I want to try it with software first.\nIs there another way to controll a Servo without the shaking? I want to run the Servo through python code btw","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":135,"Q_Id":67510361,"Users Score":0,"Answer":"As I tested before, software PWM is unstable and the servos can shake a lot, hardward PWM is quite acurrate, but the pi has only 2 hardware PWM channels.\nThe best way may be add an external PWM module (PCA9685 for example).","Q_Score":0,"Tags":"python,raspberry-pi,hardware,gpio,servo","A_Id":70225086,"CreationDate":"2021-05-12T20:07:00.000","Title":"Raspberry Pi 4 controlling a Servo without shaking","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a large list of data in a text file. I read the text file and added each line to a vector, but when I check if some string exists in that vector using contain method, the app slows down. I saw the same kine of functionality in python with pickle which it was really fast. How can make checking if something exist in a vector faster?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":755,"Q_Id":67525751,"Users Score":1,"Answer":"In order for .contains() to find an element in the Vec, it must traverse each element and compare the element to the search string to check if it's there. The easiest optimization you can make is to use a HashMap instead, where the key is the string you want to search for, and the value can be () since it's not important. You can then search for a given string with .get() and either get Some(()) if it's contained in the map or None otherwise. It's possible to iterate over all elements of a hashmap, so you can still retrieve all the stored values, but you'll gain a much faster ability to search","Q_Score":0,"Tags":"python,vector,serialization,rust,pickle","A_Id":67525884,"CreationDate":"2021-05-13T20:22:00.000","Title":"What is the fastest way to check if something exist in a vector in Rust?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to view Allure report when the tests are running ?\nRight now, I have the config\/setup to generate allure report once the tests is completed .\nI'm trying to view the allure report when the test execution is in progress. Kindly help me out with options . Thanks in advance","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":284,"Q_Id":67537059,"Users Score":0,"Answer":"I don't know if that is possible at all. For example when you run tests with maven surefire will generate files upon test phase is finished. Allure will generate report based on that files.","Q_Score":0,"Tags":"java,python,allure","A_Id":67938556,"CreationDate":"2021-05-14T15:39:00.000","Title":"How to view Allure report when the tests are running?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a legacy script that uses Python2 (which I can't modify). It imports module yaml. On older machines, this is satisfied using pip install pyyaml.\nI'm using a newly built Ubuntu laptop which has had apt install python2 done. However, there is only a python3 version of pip available. The command python2 -m pip install pyyaml says there is no module named pip. I cannot do apt install python2-pip or anything like apt install python2-pyyaml or python2-yaml or similar as there are no such packages available any more. Is there an easy way I can install module yaml for python2 now that python2 is unsupported?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":819,"Q_Id":67537167,"Users Score":1,"Answer":"Just do a curl for the following to install pip for python2:\ncurl https:\/\/bootstrap.pypa.io\/pip\/2.7\/get-pip.py --output get-pip.py\nThen run\nsudo python2 get-pip.py\nYou can then use the command pip2 --version tp check if pip is installed and for the correct version of python.","Q_Score":0,"Tags":"python,python-2.7,yaml,pyyaml","A_Id":67537253,"CreationDate":"2021-05-14T15:48:00.000","Title":"Installing python2 pyyaml","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"May be this question is so simple for many but I am looking most relevant answer from the community\nI am running My YouTube channel and after loading uploading a video and getting the video link, it's very hard and time to post manually about the video on all social media (with relevant hashtags).\nI am looking for a Python script that automate my this task, many commercial software\/websites are offering such services, but I don't want to share my information with...\nLooking for the best response.\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":261,"Q_Id":67537678,"Users Score":1,"Answer":"that's kinda hard to be done, there's some automated systems that can do this but they are not stable and ig they are forbidden in some social medias","Q_Score":0,"Tags":"python,python-3.x,automation,youtube,social-media","A_Id":67537765,"CreationDate":"2021-05-14T16:23:00.000","Title":"Automate Social Media Posts Using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am creating a bot for my server but someone is removing the reaction on my server, so I want to detect that who is removing the reaction. But I have no idea how to do that or even if it is possible or not.\nYour help is highly appreciated","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":523,"Q_Id":67545320,"Users Score":0,"Answer":"Unfortunately, The API does not give the information on who removed the reaction.","Q_Score":1,"Tags":"python,discord,discord.py","A_Id":67549401,"CreationDate":"2021-05-15T09:40:00.000","Title":"How to detect that who removed the reaction discord.py","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an app using twilio.\nI have made the twilio number public and setup call forwarding from that number to my personal number to show alerts both on the app and my phone.\nThe issue is that I am unable to identify the caller on my phone as it shows the twilio number instead of caller number on my phone.\nIs there a possible way to show the caller's number on my phone when forwarding the call.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":53,"Q_Id":67551555,"Users Score":1,"Answer":"This is possible. Just don\u2019t set the callerId attribute of the Dial verb and it will pass the callerId of the inbound call leg.","Q_Score":0,"Tags":"twilio,twilio-api,twilio-programmable-voice,twilio-python","A_Id":67551831,"CreationDate":"2021-05-15T21:58:00.000","Title":"How to show number of caller when forwarding call in twilio","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm kinda new to web security.\n\nDoes certbot automatically provide an RSA key to the server and encrypt\/decrypt the whole path(SSL) of the connection (From client to server and server to client) and make it HTTPS?\nDo I simply not bother about security while developing a web app and simply make my app in HTTP and use certbot to make it secure?\nDoes SSL protect against replication attacks?\nIf the answer to 1 is no, please suggest a python module to encrypt the Flask app.\n\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":67566716,"Users Score":0,"Answer":"Certbot provides an SSL certificate which can be used to encrypt your connection and register you with a third party (let's encrypt). When users connect to your app, they will first verify your servers identity with let's encrypt before encrypting your connection. If you're using a server like NGINX then the easiest way to use certbot will be with the nginx certbot plugin.\nHTTPS is not a security wildcard, it does provide encryption between two endpoints, preventing a host of MITM attacks but there are many threat vectors to consider. Depending on how your app works you'll still need to worry about SQL injections, malicious file uploads, remote code execution etc. HTTPS has great added security benefits absolutely, but it shouldn't replace any other security methods.","Q_Score":0,"Tags":"python,flask,certificate,ssl-certificate,certbot","A_Id":67569062,"CreationDate":"2021-05-17T08:56:00.000","Title":"Does certbot automatically provide encyption?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I noticed the ESO uses mutation and the particle are changed\/selected using the 'survival of the fittest' while in PSO mutation is not used and all the particle remains the same and follow the best particle's position. Please correct me if I'm wrong.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":40,"Q_Id":67579365,"Users Score":0,"Answer":"I infer you mentioned, \"in PSO the particles remain the same\" due to the fact that \"mutation\" is not directly used in PSO.\nNote that mutation is an exploratory operator. For example, idea behind mutation is to apply some disturbance at the chromosomes of the individual (i.e., the position in the search space) so it wilds unexplored individuals (i.e., unexplored areas). On the other hand, crossover performs exploitation by selecting fit individuals and creating offspring given their genes.\nEven though the \"mutation operator\" is not directly applied in PSO, it has its own methods of exploration and exploitation, and it is directly connected to the way the velocity vector of the particles is adjusted.","Q_Score":0,"Tags":"python-3.x,machine-learning,evolutionary-algorithm,particle-swarm","A_Id":67602350,"CreationDate":"2021-05-18T03:00:00.000","Title":"what are the main differences between Evolutionary strategy Optimization(ESO) and particle swarm Optimization(PSO)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have tried googling this and cant find much information on it.\nI simply just want to know, are there any drawbacks to accessing binance via API from two devices?\nSpecifically my situation is that I have a trading bot on a VPS that runs 24\/7. while it is running, I would like to work on updates on my computer which entails accessing the account and fetching market data.\nWill this interfere with my trade bot in any way?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":420,"Q_Id":67581122,"Users Score":0,"Answer":"Binance API keys do not have an IP address or session limitations unless you impose them yourself in the settings.\nAlso this is more of a question for Binance customer support, as Binance is private venture and they can decide how you can use your API or not.","Q_Score":0,"Tags":"python,binance,binance-api-client","A_Id":67581989,"CreationDate":"2021-05-18T06:38:00.000","Title":"Accessing Binance with API from two devices at once","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I can't find the official documentation on how the isalpha method was written (of the string module), but I imagine the algorithm used would be: 1). Convert char in question to int.2). Compare it to the larger alpha-ascii values (i.e. 90 or 122) to see if it less than or equal to these values.3). Compare it to the larger alpha-ascii values, i.e. 55 or 97 depending on the upper bound used (if only less than 90 use 55...), to see if it greater than or equal to these values.Am I correct in this assessment of the isalpha method or is it something different altogether? If so does it have a complexity of O(3)?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":375,"Q_Id":67592841,"Users Score":1,"Answer":"Python handles text as unicode. As such, what character is alphabetic and what is not depends on the character unicode category, enconpassing all characters defined on the unicode version compiled along with Python. That is tens of hundreds of characters, and hundreds of scripts, etc... each with their own alphabetic ranges. Although it all boils down to numeric ranges of the codepoints that could be compared using other algorithms, it is almost certain all characters are iterated, and the character unicode category is checked. If you want the complexity, it is then O(n) .\n(Actually, it would have been O(n) on your example as well, since all characters have to be checked. For a single character, Python uses a dict, or dict-like table to get from the character to its category infomation, and that is O(1))","Q_Score":0,"Tags":"python,string,algorithm,time-complexity","A_Id":67592929,"CreationDate":"2021-05-18T19:30:00.000","Title":"Python: Time complexity of .isAlpha","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to python (and to programming in general). I have no experience with GitLab, but I've been given a directory in GitLab that should have all the scripts I need to install all the python modules I need, but I'm not sure how to do that. I can download the directory as tar.gz or tar.bz2 or tar, but I'm not familiar with these types of files and not sure which I need or what to do with it? Any help would be greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":31,"Q_Id":67626016,"Users Score":0,"Answer":"If you have git installed, you can clone the project to your computer with the command:\ngit clone \nYou can get the URL from GitLab, there are for HTTP or ssh.\nAfter it, if the project has a requirenment.txt file, you can install all requirements with: pip install -r requirements.txt. Else, you will need to install all libraries with pip or conda.","Q_Score":0,"Tags":"python,installation,module,download,gitlab","A_Id":67626112,"CreationDate":"2021-05-20T18:22:00.000","Title":"How do you extract scripts in GitLab and install the module in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"After trying to run \"service apache2 reload\" on the raspberry terminal, I get an error\nThe error log reads:\n\"apache2.service is not active, cannot reload.\"\nHow do I activate \"apache2.service\" on the raspberry pi?\nI've already installed apache2 on my raspberry pi, but I can't reload it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":74,"Q_Id":67658607,"Users Score":0,"Answer":"Please try this one sudo service apache2 start . Make sure apache is properly installed in your system.","Q_Score":0,"Tags":"python,flask,web,server,raspberry-pi","A_Id":67658658,"CreationDate":"2021-05-23T10:19:00.000","Title":"How to activate apache2 service on Raspberry Pi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have a blog and an application that gives the number of comments and posts on my blog by using my blog's API.\nThe issue I'm having is that I want to have my application receive new comments from my application in real-time.\nMy solution:\nI can have my application calling the API every 30 seconds or so to check whether there is a response (i.e. whether there is a new comment).","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":20,"Q_Id":67660673,"Users Score":0,"Answer":"I think the best solution is to use something called Long Polling to get updates. Its a technique in programming to handle requests with less resources such as CPU being used over time. For a detailed solution for your case search for\n\nLong Polling in Flask application","Q_Score":0,"Tags":"python,api,flask","A_Id":67660767,"CreationDate":"2021-05-23T14:12:00.000","Title":"How to get new (real time) comments from my blog?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm a beginner in python and raspberry pi and for a school project we're using a raspberry pi 3 and a camera module (fixed) and the idea is when u move something in the camera frame the program gives an output of where this object is according to the camera (in 3D) and the distance this object has traveled, it would be something like ( x=2.98m, y=5.56m, z=3.87m, distance=0.677m ) and all of this using optical flow and python. Is it possible to make this and if not Is there something close or similar to this.\nAny help appreciated.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":71,"Q_Id":67671722,"Users Score":1,"Answer":"The first thing you can do is camera calibration. If you have the intrinsics of the camera you can infer the direction of the vector in 3D from your camera to your object.\nThe problem is how to find the distance, or the length of this vector.\nThere are two solutions I can think of:\n\nuse two cameras - if you have two calibrated cameras (intrinsics and extrinsics) you can triangulate the two points of the object detected in the images and get the object position in 3D.\nIf you know the size of the object, you can infer its distance from the camera using the intrinsics.\n\nhope I helped.","Q_Score":0,"Tags":"python,opencv,opticalflow","A_Id":67673155,"CreationDate":"2021-05-24T11:59:00.000","Title":"Calculate the motion of a simple object in 3D","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My web product is on my Server. It does not have GPU. I need to run few AI algorithms and display that output on my website. I want to run that code on my another system which consists of GPU . Is that possible If yes? can you please suggest?\nEdit: GPU and CPU are on the same server. Right now Algorithms are not been hosted on any server.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":61,"Q_Id":67725450,"Users Score":0,"Answer":"yes it is kinda possible and let me explain. first, you should have the python script that you wanna run on your computer with a GPU available. second, you need to code a python based server that listens for incoming connections, when a connection connects to the server, the server executes the python file, saves the output through piping and then returns the output to the connection. this can be deployed with website easily. you can use php sockets to send and receive data to your python server.\nIdea : Python Server Running On Specific Port Listening For Incoming Connections ==> A Connection Hits The Server ==> The Servers Runs The Code That contains the AI Of Yours, Saves The Outputs and sends back the output to the client.","Q_Score":0,"Tags":"python-3.x,gpu,artificial-intelligence","A_Id":67735104,"CreationDate":"2021-05-27T15:34:00.000","Title":"Accessing python file from another computer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to make a bot using discord.py which can temporarily create new sub-bots and then delete them?\nI cant find anything in the documentation. Is there something I'm overlooking, is it possible to implement with a workaround, or was discord.py not meant to be used like this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":67726234,"Users Score":0,"Answer":"No you cannot do that but you can use the webhook system to create a \"bot\" which then you can delete. It looks exactly like an unverified bot and is what bots like emoji.gg use","Q_Score":0,"Tags":"python,discord","A_Id":68867176,"CreationDate":"2021-05-27T16:23:00.000","Title":"Sub bot generation in discord.py","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have recently downloaded Bowtie2-2.3.4 via the precompiled binaries, and added the file location to my path. I have also installed strawberry perl, and added that location to my path as well.\nWhen I try to determine whether bowtie2 is correctly installed by typing bowtie2, bowtie2 -- version, bowtie1 - inspect, get the message: \"Can't open perl script \"C:\\Users\\lberd\\Documents\\Python\": No such file or directory\". If I create an empty directory called Python in my documents folder, it give me \"Can't open perl script \"C:\\Users\\lberd\\Documents\\Python\": Permission denied\".\nI have python 3.9.5 installed, and the location is in my path as well.\nWhat is bowtie2 looking for in the python folder?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":33,"Q_Id":67744165,"Users Score":0,"Answer":"Found the problem: the bowtie binaries were saved in a folder called \"python scripts\" bowtie did not know how to handle the space in the folder name, which is why it stopped at \"python\".","Q_Score":0,"Tags":"python,bowtie","A_Id":67808770,"CreationDate":"2021-05-28T18:52:00.000","Title":"Bowtie2 is expecting a Documents\/Python folder. why?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Would we use char, signed char, unsigned char or import some header for a byte type?\nMy code is going to be seen\/used by other C developers and I want to use whatever standard they're most likely used to seeing.\nAlso, I may be allocating memory for this function from python as a numpy array and calling it through ctypes. Is there a preferred way to allocate a byte array in numpy?\nIs np.zeros(size, dtype=np.byte) the normal way, if the corresponding C type is char, for example?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":97,"Q_Id":67746138,"Users Score":0,"Answer":"The most common way is using a char array.\nHowever, it really depends on the needs of the code.","Q_Score":0,"Tags":"python,arrays,c,ctypes","A_Id":67748224,"CreationDate":"2021-05-28T22:40:00.000","Title":"What is the most common way to represent a byte array in C?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have typed this code in VS code using the base interpreter 'conda' i.e., miniconda 3\nimport pywhatkit\npywhatkit.sendwhatmsg(\"xxxxxxxx\", \" good morning from python\",10,00)\nx is the phone number\nThe problem is, all it does is load the message in WhatsApp's textbox, it does not send. Is something wrong with my program or need to install something else?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":252,"Q_Id":67747753,"Users Score":0,"Answer":"You are using 00 as leading zeros in decimal integer literals are not permitted. use an 0o prefix for octal integers Or Start your time with a number other than 0","Q_Score":2,"Tags":"python,visual-studio-code,automation,anaconda,whatsapp","A_Id":67747801,"CreationDate":"2021-05-29T04:33:00.000","Title":"is there any other way to solve automation of whatsapp message?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have typed this code in VS code using the base interpreter 'conda' i.e., miniconda 3\nimport pywhatkit\npywhatkit.sendwhatmsg(\"xxxxxxxx\", \" good morning from python\",10,00)\nx is the phone number\nThe problem is, all it does is load the message in WhatsApp's textbox, it does not send. Is something wrong with my program or need to install something else?","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":252,"Q_Id":67747753,"Users Score":2,"Answer":"I had the same issue, I found that it is needed to set an enough interval of time between the executed code and the time that whatsapp web gets fully open to paste the message and send it, try with at least 30 seconds or more (wait_time = 30 or more). Otherwise \"trigger is pulled before bullet is in site\"","Q_Score":2,"Tags":"python,visual-studio-code,automation,anaconda,whatsapp","A_Id":70609697,"CreationDate":"2021-05-29T04:33:00.000","Title":"is there any other way to solve automation of whatsapp message?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Visual Studio Community Edition to make a discord bot. I am using discord.py (updated it to the last version) at the moment and whenever I use from discord.ext import commands I encounter following error:\n\nunresolved import discord.ext.tasks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":67764149,"Users Score":0,"Answer":"Check that the name of your file isn't the same as any module that you might be using. So don't name it discord.py or anything like that.","Q_Score":0,"Tags":"python,discord,discord.py,bots","A_Id":67764801,"CreationDate":"2021-05-30T17:44:00.000","Title":"'unresolved import discord.ext.tasks' issue","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"so I am trying to use javascript or python (or anything else that can do it) to get the pitch and volume of an mp3 file at every few milliseconds. Any help would be greatly appreciated, thank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":144,"Q_Id":67788534,"Users Score":2,"Answer":"Pitch is related to how fast the amplitude of a signal changes, so it needs to be calculated over a block of time, rather than at an instant.\nI'd suggest decoding your mp3 into a waveform (there are Python libraries that will put this in a numpy array for you) then take a section at a time and do the following:\n\nRun an FFT (search for numpy FFT) on the block to find the frequency content. Typically a sound at a particular pitch will have a base frequency and there will also be harmonic content i.e. frequencies at integer multiples of the base frequency. Additionally, you may have more than one contributing sound, so there will be multiple base frequencies each with their own harmonics. The FFT will work out what frequencies there are assuming that he block then repeats forever. Unfortunately the start and end amplitude of your signal won't match at the start and end of your block, so this assumption is like there's a sudden jump in amplitude. That is going to cause artifacts in your FFT result, so if it is a problem in your application you will need to look into windowing before running an FFT. This attenuates your block at the start and end, so they line up at zero.\nIdentify which FFT peak relates to the pitch you want to record. This may be the highest peak for example. The frequency of this peak is the pitch for this block.\nTake the root-mean-squared (RMS) of the block (from the original array, not the FFT) and use this as a measure of volume.\n\nYou can then move to the next block and repeat, so if your block size is 440 samples (10ms at 44kHz sampling rate) take your first block from 0 to 439, then the next from 440 to 879 etc.\nYou could also do a sliding block if you want, e.g. advance your 440 sample block by say 44 samples each time, so the first block is 0 to 439 and the next is 44 to 483.","Q_Score":0,"Tags":"javascript,python,mp3","A_Id":67789247,"CreationDate":"2021-06-01T12:01:00.000","Title":"Get pitch of mp3 files at every few ms","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've a git repo and I want to tar all the files except .git folder and its contents.\nI've found answers with param exclude=... in tar.add(...) but it seems to be depricated. Any other ways to do it?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":125,"Q_Id":67798370,"Users Score":0,"Answer":"I think you can do find files and skip files and use exec command to tar.\nfind \/dir -name \"*.gz\" ! -name .git -exec tar -rvf out.tar {} \\;","Q_Score":0,"Tags":"python,python-3.x,tar,tarfile","A_Id":67798414,"CreationDate":"2021-06-02T03:01:00.000","Title":"Python: tarfile exclude .git folder inside tar","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to start a python script on my Raspberry Pi through an SSH connection from my main machine. But obviously, as soon as I turn off my main machine the SSH terminal will close and with that my python script will be cancelled.\nI'm looking for a method where I can use SSH to open a terminal that runs on the Pi internally and does not close as soon as I turn off my main machine. This should be possible without connecting keyboard and screen to the raspberry, right?\nThank you so much for any tips","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":86,"Q_Id":67802986,"Users Score":0,"Answer":"you can use screen, tmux or nohup for this:\nscreen:\nscreen manager with VT100\/ANSI terminal emulation\ntmux:\nterminal multiplexer\nnohup:\nrun a command immune to hangups, with output to a non-tty\nscreen and tmux will start virtual session that you can connect to later, for hotkeys settings see manual pages\nnohup will just avoid to kill the process for example:\nyes nohup;\nthis will write the output from the program \"yes\" to the nohup.out file and it will not be terminated by disconnection of your ssh","Q_Score":1,"Tags":"python,ssh,terminal,raspberry-pi","A_Id":67803066,"CreationDate":"2021-06-02T10:04:00.000","Title":"Opening and running local terminal through SSH","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Can the xlrd module change the file propeties? Such as author,title,subject,etc..\nI want to change a .xls file's properties and don't know how to do that.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":30,"Q_Id":67805039,"Users Score":1,"Answer":"As far as i know that's not possible with xlrd. The rd part of the name means \"read-only\". You would need to use the xlwt library for writing or one of the newer options like XlsxWriter.","Q_Score":2,"Tags":"python,excel,properties,xls,xlrd","A_Id":67805373,"CreationDate":"2021-06-02T12:23:00.000","Title":"Can the xlrd module change the file properties?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want my RPi to open run a python webserver and open Chromium to access it.\nIt should do it automaticaly on startup.\nBUT\nWhen I run the script via command\n$ sudo python3 \/home\/sps-training\/python\/webserver.py\nand open localhost on chromium, it says that it can't access HTML file in another folder (\/deploy)\nbut when I open the dictionary first\n$ cd \/home\/sps-training\/python\/\nand then open the script\n$ python3 webserver.py\nit suddenly works!\nSo there are 2 possible solutions\nThe first one is to make it work by using:\n$ sudo python3 \/home\/sps-training\/python\/webserver.py\nThe second one is to automatically access directory and the start the script\nRight now I'm using \/etc\/profile to run it on startup (I just wrote at the last line with & on the end of the line)\nThanks a bunch for every advice!\nbtw sorry for grammar","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":117,"Q_Id":67809791,"Users Score":0,"Answer":"Like Barmar said. It sounds like the issue you're running into is a working directory vs. current directory problem. When you run sudo python3 \/home\/sps-training\/python\/webserver.py you are launching webserver.py in the directory \/ and if it looks for \"deploy\/index.html\" it's going to look in \/deploy\/index.html. However, when you cd into \/home\/sps-training\/python\/ and then run python3 webserver.py the working directory is now \/home\/sps-training\/python\/ and it will look for deploy\/index.html in \/home\/sps-training\/python\/deploy\/index.html\nThe best solution is to edit the python script to use absolute file paths.\nBarring that, you need to cd to the correct working directory every time.","Q_Score":0,"Tags":"python,linux,raspberry-pi,raspbian","A_Id":67810189,"CreationDate":"2021-06-02T17:23:00.000","Title":"RPi - accessing a folder and then running a python script on startup","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"When I try to calculate something like 599! in Matlab, the answer is inf and not useful, but I am able to do that fine in python in google collab. Even when I try using stirling approximation for these large factorials I still get inf as an answer and I can't do anything with that (I'm trying to calculate multiplicity).\nWhy is it this way, especially since google collab isn't even on my computer its in the cloud or whatever. Can someone explain how this is possible?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":48,"Q_Id":67813171,"Users Score":1,"Answer":"Very simply, MATLAB has a hard limit on the size of integers and floats, and returns inf when you pass that value. Python implements a long-integer mode, an unlimited digital mode for computation. When you pass the \"normal\" 64-bit limit, Python converts to that long integer mode and continues operation -- at a very reduced speed.","Q_Score":0,"Tags":"python,matlab","A_Id":67813196,"CreationDate":"2021-06-02T22:12:00.000","Title":"Factorials in Matlab vs Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"pip install pytest-config\n\nprompts the following error:\n\nCould not find a version that satisfies the requirement pytest-config (unavailable) (from versions: 0.0.8, 0.0.9, 0.0.10, 0.0.11)\n\nNovice Seeking Guidance\uff0c thanks.\nremarks:\n\npython version 3.9.5\n\n\npytest version 6.2.4","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":141,"Q_Id":67834310,"Users Score":0,"Answer":"Also tried the following methods to get the same prompt\uff1a\npip install git+git:\/\/github.com\/buzzfeed\/pytest_config.git@#egg=pytest_config==","Q_Score":0,"Tags":"python-3.x","A_Id":67834417,"CreationDate":"2021-06-04T08:53:00.000","Title":"Could not find a version that satisfies the requirement pytest-config (unavailable) (from versions: 0.0.8, 0.0.9, 0.0.10, 0.0.11)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've downloaded some tweets with Twython.\nI want to get\/access only the 'name' attribute from the 'user' object dictionary (e.g. {'id': 540179903, 'id_str': '540179903', 'name': 'Makis Voridis' etc.\nHow could I solve this??\nThanks!!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":33,"Q_Id":67835740,"Users Score":1,"Answer":"If it is a dictionary, you can simply acess each key by simply doing tweet['name'] and tweet being your dictionary.","Q_Score":0,"Tags":"python,dataframe,twitter,twython","A_Id":67835882,"CreationDate":"2021-06-04T10:32:00.000","Title":"How can I get\/access the 'name' attribute from the user data dictionary in twitter in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I git cloned files on my Mac, now I want to delete them, but can't find, where is the location of default store?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1305,"Q_Id":67847692,"Users Score":1,"Answer":"The clone happens in the directory from where you issued the command if not specified explicitly. If you have lost the terminal, then search for all the folders with a .git directory and you will locate it.","Q_Score":1,"Tags":"python,github","A_Id":67847703,"CreationDate":"2021-06-05T08:14:00.000","Title":"Where to find my git clone repos on my mac?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am writing some python x selenium unit tests for the login functionality of a website. I have already written a unit test for a valid login, but I want to write one for the \"Remember Me\" functionality. I could easily just copy\/paste the login unit test code into the new one, but that would make a VERY long block of code. I was wondering if there was any way to utilize another unit test's code for a separate unit test in order to save some room.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":67853737,"Users Score":0,"Answer":"It's not about utilization unit tests.\nYou should write your methods \/ classes in a way they can be utilized easily.\nSo that your login method will call similar methods that \"remember me\" method uses but with appropriate changes according to scenario flow differences.","Q_Score":1,"Tags":"python,selenium,unit-testing,selenium-webdriver","A_Id":67853938,"CreationDate":"2021-06-05T20:36:00.000","Title":"Is there a way to run a unit test inside a different unit test?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So, I have access to a server by ssh with some gpus where I can run some python code. I need to do that using a docker container, however if I try to do anything with docker in the server i get permission denied as I dont have root access (and I am not in the list of sudoers). What am I missing here?\nBtw, I am totally new to Docker (and quite new to linux itself) so it might be that I am not getting some fundamental.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":70,"Q_Id":67868374,"Users Score":0,"Answer":"I solved my problem. Turns out I simply had to ask the server administrator to add me to a group and everything worked.","Q_Score":0,"Tags":"python,docker,ssh,server","A_Id":67871954,"CreationDate":"2021-06-07T08:35:00.000","Title":"Running python code in a docker image in a server where I dont have root access","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to check if any files got uploaded in S3.\nIf there were no file uploads in the last 10 hours, I want to trigger a lambda that can be notified by SNS.\nHow can I trigger lambda when there were no uploaded file in S3 in last certain hour?\nHow could I trigger the lambda when there were no files uploaded in the last hour?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":56,"Q_Id":67872516,"Users Score":0,"Answer":"First, you need to know when the most recent object was uploaded to S3. That's not a trivial task for a bucket with lots of objects. You could configure S3 to trigger a Lambda function to run every time an object is uploaded and write a 'last-uploaded-time' timestamp to DynamoDB.\nNext, you need to schedule the checking of the 'last-uploaded-time' timestamp. You could do that with a CloudWatch\/EventBridge scheduled event. Run a Lambda function on a schedule, e.g. every hour.","Q_Score":0,"Tags":"python,boto3","A_Id":67872593,"CreationDate":"2021-06-07T13:26:00.000","Title":"How can I trigger lambda when there are no uploaded files in s3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a requirement that I need to clean up GitLab repo, and need to remove all empty subdirectories present in a specific directory inside a specific project of a specific group.\nSince, there are more than 10000 such directories that I need to remove, I was planning to do it programmatically using Gitlab python API.\nHowever, I can't seem to find any way to list subdirectories or to remove them in GitLab Python API documentation. Is it possible to implement?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":139,"Q_Id":67888612,"Users Score":1,"Answer":"So, git doesn't actually store directories themselves as objects that it manages. It stores paths in tree objects, but once that part of the tree is empty they don't remove the sub-paths.\nThe simplest way to do the cleanup you want is simply remove all the files from the sub-directories and then reclone the repository. It will not recreate the sub-folders that are empty.\n[Newer versions of git may actually clean up sub-directories by the way, but older ones won't. My git 2.31 will, eg]","Q_Score":2,"Tags":"python,python-3.x,gitlab,gitlab-api","A_Id":67888736,"CreationDate":"2021-06-08T14:03:00.000","Title":"Deleting a subdirectory present in a directory inside a project Gitlab","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"My job involves production maintenance coordination. I routinely need to distill down data from a schedule and get input from production heads as to availability of equipment.\nI have automated the distilling of raw data from a master schedule and have my\nProgram output a list of jobs that need scheduling for each production department.\nI COULD simply copy this info to an email and send it via email (using python). However, a more elegant solution would be to transfer the data to a program that I could then email to each department that would run a tkinter type GUI on the production heads computer that gives them a step by step calendar interface to return the availability dates for each job back to me via email from their computer.\nThe production heads will not have python3 installed on their computers and will be using windows 10.\nIs this possible? Or should I drop my dreams of getting so fancy and just send the information via plain text emails.\nThanks for your help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":25,"Q_Id":67903624,"Users Score":0,"Answer":"Here I am assuming you have your python program ready.\nUse Pyinstaller to convert your python program to an application.Then you can share it with others who even doesn't have python installed in their system.","Q_Score":0,"Tags":"python-3.x,windows,email-attachments","A_Id":67905392,"CreationDate":"2021-06-09T11:53:00.000","Title":"Is it possible to send an executable python program via email to be executed on 3rd party computer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to Python so please be kind. I have basic code working to know when the input state of #18 on the RPi GPIO is such that a switch closed. What I'd like is the best (easiest) method to capture the time when the switch is closed and then not closed (opened).\nMy end objective is to write to a file when the sail switch closes and then when it opens to a data file to monitor when there is air flow indicating the A\/C is running. I already have the openweathermap API working to gather the temperature and a print of a literal when the switch is closed which just keeps redisplaying in the while loop. My time.sleep will be 60 seconds. The file will eventually have all of the start\/stop times for several days as well as the temperature.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":77,"Q_Id":67909956,"Users Score":0,"Answer":"I solved this by doing a for loop (1,n) where n is a large number and then two loops: a while True if input_state == False followed by a while True: if input _state == True. Each while has a counter increment. More code to get temperature from openweathermap, get some variables, write an output file and sleep but you get the idea.\nBasically done - just waiting for more ordered hardware.","Q_Score":0,"Tags":"python,raspberry-pi,gpio","A_Id":67950434,"CreationDate":"2021-06-09T18:37:00.000","Title":"In a while True loop reading a RPi GPIO need the time a switch was closed and then when the state changed to open","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to Python so please be kind. I have basic code working to know when the input state of #18 on the RPi GPIO is such that a switch closed. What I'd like is the best (easiest) method to capture the time when the switch is closed and then not closed (opened).\nMy end objective is to write to a file when the sail switch closes and then when it opens to a data file to monitor when there is air flow indicating the A\/C is running. I already have the openweathermap API working to gather the temperature and a print of a literal when the switch is closed which just keeps redisplaying in the while loop. My time.sleep will be 60 seconds. The file will eventually have all of the start\/stop times for several days as well as the temperature.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":77,"Q_Id":67909956,"Users Score":1,"Answer":"You if you want to measure time delta between open\/close you can use time module, more specific time.time() function. If you want to record date and time of switching, use datetime module with datetime.datetime.now() function.","Q_Score":0,"Tags":"python,raspberry-pi,gpio","A_Id":67910008,"CreationDate":"2021-06-09T18:37:00.000","Title":"In a while True loop reading a RPi GPIO need the time a switch was closed and then when the state changed to open","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have two working discord bots and a test server. I want my first bot to add the second bot to the test server. How would I go about this? I have researched it and found nothing. Any help would be appreciated. Thanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":98,"Q_Id":67911378,"Users Score":1,"Answer":"This isn\u2019t possible, bots can\u2019t run other bots cmds or add other bots to a server.","Q_Score":2,"Tags":"python,discord,discord.py","A_Id":68224980,"CreationDate":"2021-06-09T20:35:00.000","Title":"Is it possible for my discord bot to add another bot to its server?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have 2 buckets on the S3 service. I have a lambda function \"create-thumbnail\" that triggered when an object is created into an original bucket, if it is an image, then resize it and upload it into the resized bucket.\nEverything is working fine, but the function doesn't trigger when I upload files more than 4MB on the original bucket.\nFunction configurations are as follow,\n\nTimeout Limit: 2mins\nMemory 10240\nTrigger Event type: ObjectCreated (that covers create, put, post, copy and multipart upload complete)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":368,"Q_Id":67917878,"Users Score":0,"Answer":"Instead of using the lambda function, I have used some packages on the server and resize the file accordingly and then upload those files on the S3 bucket.\nI know this is not a solution to this question, but that's the only solution I found\nThanks to everyone who took their time to investigate this.","Q_Score":2,"Tags":"python-3.x,amazon-web-services,amazon-s3,aws-lambda","A_Id":67985482,"CreationDate":"2021-06-10T08:53:00.000","Title":"AWS S3 lambda function doesn't trigger when upload large file","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to send messages in large amount(approx. 500k) at once in rabbitMQ using pika in python. One of the way is to iterate over all the messages and send them sequentially, but that will be slow.\nIs there any way to resolve this problem ?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":204,"Q_Id":67939842,"Users Score":1,"Answer":"AMQP by default does not provide any batch mechanism, so with pika you can't batch the messages.\nbtw you can use some tips as:\n\naggregate the messages client-side, so more messages in one\nyou can create a compressed message, like a zip\/lzo or some lib can compress\/uncompress in memory.\n\nNote: if you want to compress the messages, 500k is too high you should split them","Q_Score":0,"Tags":"python,rabbitmq,publish-subscribe,pika","A_Id":67942250,"CreationDate":"2021-06-11T15:38:00.000","Title":"Sending messages in batch in rabbitMQ using pika","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do I run my python script test.py, which I coded in Pycharm, to run on another computer, with no python and Pycharm installed?\nThe other system can have python installed but no Pycharm.\nThe script uses various excel files, does the other system need to create the same folder structure to read the file.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1303,"Q_Id":68007735,"Users Score":2,"Answer":"Convert that python file to a .exe file using auto-py-to-exe. This would convert your .py to .exe file which you can run anywhere.\nTo use auto-py-to-exe, just execute the following command on terminal pip install auto-py-to-exe.\nNow on the terminal write auto-py-to-exe and press enter. Select the python file you wanna execute anywhere and click on Convert .py to .exe and you would get the folder containing .exe file. Transfer this folder to any computer and just by clicking the .exe file that is there inside the folder, the program would start executing normally no matter if the computer does not have python or pycharm installed.","Q_Score":0,"Tags":"python,terminal,pycharm,ide,python-3.7","A_Id":68007786,"CreationDate":"2021-06-16T17:48:00.000","Title":"How do I run my python script on another computer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using a NodeJS server to catch a video stream through a WebRTC PeerConnection and I need to send it to a python script.\nI use NodeJS mainly because it's easy to use WebRTC in it and the package 'wrtc' supports RTCVideoSink and python's aiortc doesn't.\nI was thinking of using a named pipe with ffmpeg to stream the video stream but 3 questions arose :\n\nShould I use python instead of NodeJS and completely avoid the stream through a named pipe part ? (This means there is a way to extract individual frames from a MediaStreamTrack in python)\n\nIf I stick with the \"NodeJS - Python\" approach, how do I send the stream from one script to the other ? Named pipe ? Unix domain sockets ? And with FFMpeg ?\n\nFinally, for performance purpose I think that sending a stream and not each individual frames is better and simpler but is this true ?\n\n\nThanks all !","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":293,"Q_Id":68014505,"Users Score":0,"Answer":"Finally, I found that the MediaStreamTrack API of Python's aiortc has recv().\nIt's a Coroutine that returns the next frame. So I will just port my NodeJS script to python using this coroutine to replace RTCVideoSink. No piping or whatsoever !","Q_Score":0,"Tags":"python,node.js,ffmpeg,webrtc,mkfifo","A_Id":68017298,"CreationDate":"2021-06-17T07:07:00.000","Title":"Sending video stream from NodeJS to python in real time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been learning about django testing and would like to have several tests files that I would like to rename and place then in to a folder. How is the proper way to do it?\nIn a single file test.py I used to run my test with the \"python.manage.py tests appname\" command.\nI tried to organize my tests files this way.\napp\/tests\/__init__py\napp\/tests\/test_something.py\napp\/tests\/test_something_else.py\nThe problem is that when I organize them in several files I can't run a single test file. At this point all I can do is run then all with the command \"python manage.py tests app test_something_else.py\", but this it will also runs test_something.py.\nI've already try the django documentation, but it hasn't help much because I think this example is for a single test.py file.\n(for an example app named animals)\nRun just one test case\n$ .\/manage.py test animals.tests.AnimalTestCase\nRun just one test method\n$ .\/manage.py test animals.tests.AnimalTestCase.test_animals_can_speak\nWhat am I doing wrong?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":120,"Q_Id":68017261,"Users Score":0,"Answer":"You still can, modify your command to python manage.py test app.tests.test_something_else to run tests in a single file. You can also run a specific test like python manage.py test app.tests.test_something_else.TestCaseClassName.test_the_test. The problem with your last command is that you are trying to access the class before the module that contains the class test case.","Q_Score":1,"Tags":"python,django,testing","A_Id":68024211,"CreationDate":"2021-06-17T10:11:00.000","Title":"How to organize test files on django 3.x and run single file tests?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I wish to change the speed at which the Write() or writeline() functions write into a file with. Is it possible to vary the rate? If not, do you know any external modules which can help?\nFor example:\nI have to write a 500 word essay into the .txt or .rtx file. I want the rate of typing using write to be say, 100 words a minute.\nso after 5mins, the file is written completely.\nIs this possible?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":22,"Q_Id":68023514,"Users Score":0,"Answer":"Use time.sleep() between calls to write() or writeline() to slow down the rate as desired.","Q_Score":0,"Tags":"python","A_Id":68023599,"CreationDate":"2021-06-17T16:50:00.000","Title":"Can we manipulate the speed at which the WRITE\/WRITELINE functions write into the file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In the Twilio docs, there is an option to set the state of a conversation from active, inactive, or closed. It says \"Be aware that closed Conversations do not count towards the Participant-per-Conversation limit.\" However, I am not sure if a closed conversation counts towards the channels per identity limit (1000 in total). Can anyone clarify this? thank you","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":67,"Q_Id":68041712,"Users Score":1,"Answer":"Twilio developer evangelist here.\nI checked with the team and closed conversations do not count towards the channels per identity limit.\nFurther, I'll work to clarify that in the docs.","Q_Score":0,"Tags":"python,twilio,twilio-conversations","A_Id":68158059,"CreationDate":"2021-06-18T21:40:00.000","Title":"Twilio Conversations - Do closed conversations count towards the channels per identity limit","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I try to run a program that has import keyboard it gives me this error even though I installed it:\nTraceback (most recent call last):\nFile \"C:\\Users\\Diana\\Desktop\\test file.py\", line 1, in \nimport keyboard\nModuleNotFoundError: No module named 'keyboard'\nDoes anyone know why?","AnswerCount":3,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":555,"Q_Id":68042141,"Users Score":-1,"Answer":"Pls check if you installed the module 'keyboard', If done, make sure you call the function.","Q_Score":0,"Tags":"python","A_Id":68042767,"CreationDate":"2021-06-18T22:44:00.000","Title":"Why do I get the python error saying I don't have the keyboard module when I do?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to create a Discord bot that pings a certain user role when an embedded message contains a certain keyword. To avoid ping spam when multiple embedded messages with the keyword are posted, I would like the bot to ping once, then pause for X seconds and then if there's a new message, react to that and then repeat the process.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":106,"Q_Id":68048699,"Users Score":0,"Answer":"In python, you have to import the Time module, then use time.sleep().\nimport time\ntime.sleep(x amount of seconds)","Q_Score":0,"Tags":"python,discord,discord.py","A_Id":68048776,"CreationDate":"2021-06-19T16:18:00.000","Title":"How to pause on_message for a certain amount of time after it reacts to a message (Discord Py)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to be able to unit test my airflow operators without having to run airflow db init before the tests.\nIs there a way to do this ?\nThank you very much for your help !","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":729,"Q_Id":68049095,"Users Score":0,"Answer":"Not a direct answer but a different approach on this.\nWe have the same issue and still experimenting on this. For now we have decided to split the functionality of the custom airflow operator in two parts. Operator itself handling anything that has to do with the db and orchestrates the process and in another module we have the logic of the operator - that has nothing to do with the database.\nFor example, assume that you have an operator that gets a csv file from a bucket performs transformations and then inserts the file in the database. Lets call it CsvToDBOperator. For this we would have two files\/classes.\n\nCsvToDBOperator\nCsvToDBUtils\n\nThe second one will keep all the methods\/functions that are responsible for the transformations. The first one will be responsible to get the file from the bucket, pass it to the second for the transformation and then getting the result from it and finally inserting it in the DB.\nLike this you can write unit tests for CsvToDBUtils class and only create unit tests on those.","Q_Score":2,"Tags":"python,unit-testing,airflow","A_Id":68053246,"CreationDate":"2021-06-19T17:08:00.000","Title":"Airflow unit testing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a Python script, part of a test system that calls many third party tools\/processes on multiple [Windows] machines, and hence has been designed to clean up comprehensively\/carefully when aborted with CTRL-C; the clean-up can take many seconds, depending on what's going on. This clean-up process works fine from a [Windows] command prompt.\nI run that Python script from [a scripted pipeline] Jenkinsfile, using return_value = bat(\"python my_script.py params\", returnStatus: true), which also works fine.\nHowever I need to be able to perform the abort\/clean-up during a Jenkins [v2.263.4] run, i.e. when someone presses the little red X, and that bit I can't fathom. I understand that Jenkins sends SIGTERM when the abort button is pressed so I am trapping that in my_script.py:\nSAVED_SIGTERM_HANDLER = signal(SIGTERM, sigterm_handler)\n...and running the processes I would normally call from a KeyboardInterrupt in sigterm_handler() as well, but they aren't being called. I understand that the IO stream to the Jenkins console stops the moment the abort button is pressed; I can see that the clean-up functions aren't being called by looking at the behaviour of my script(s) from the \"other side\": it appears as though my_script.py is simply stopping dead, all connections from it drop the moment the abort button is pressed, there is no clean-up.\nCan anyone suggest a way of making the abort button in Jenkins give my bat()ed Python script time to clean-up? Or am I just doing something wrong? Or is there some other approach to this within Jenkins that I'm missing?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":191,"Q_Id":68051496,"Users Score":0,"Answer":"After much figuring out, and kudos to our tools people who found the critical \"cookie\" implementation detail in Jenkins, the workaround to take control of the abort process [on Windows] is as follows:\n\nhave Jenkins call a wrapper, let's call it (a), and open a socket or a named-pipe (socket would work on both Linux and Windows),\n(a) then launches (b), via \"start\" so that (b) runs as a separate process but, CRITICALLY, the environment that (a) passes to (b) MUST have JENKINS_SERVER_COOKIE=\"ignore\" added to it; Jenkins uses this flag to find the processes it has launched in order to kill them, so you must set this \"cookie\" to \"ignore\" to stop Jenkins killing (b),\n(b) connects back to (a) via the socket or pipe,\n(a) remains running for as long as (b) is connected to the socket or pipe but also lets itself be killed by CTRL-C\/SIGTERM,\n(b) then launches the thing you actually want to run,\nwhen (a) is terminated by a Jenkins abort (b) notices (because the socket or pipe will close) and performs a controlled shut-down of the thing you wanted to run before (b) exits,\nseparately, make a thing, let's call it (c), which checks whether the socket\/named-pipe is present: if it is then (b) hasn't terminated yet,\nin Jenkinsfile, wrap the calling of (a) in a try()\/catch()\/finally() and call (c) from the finally(), hence ensuring that the Jenkins pipeline only finishes when (b) has terminated (you might want to add a guard timer for safety).\n\nQuite a thing, and all for the lack of what would be a relatively simple API in Jenkins.","Q_Score":0,"Tags":"python,shell,jenkins-pipeline,jenkins-groovy,sigterm","A_Id":68213142,"CreationDate":"2021-06-19T23:29:00.000","Title":"Jenkinsfile and allowing an aborted `bat()` command time to clean up","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I'm working on an IOT project where multiple users are running a Python package I maintain on a Raspberry Pi Zero. I send the Raspberry Pis out to the users with the software preloaded, but the project is still pretty early in development and updates to the package happen frequently.\nThe problem is, many of the users are not up to the task of updating a Python package on a Raspberry Pi with a headless OS. I'd like to find a way to set the Pi to automatically upgrade the package with pip whenever I put out a new tagged version.\nMy initial thought was to use cron or systemd to run \"sudo pip3 install my-package --upgrade\" on startup. The major downside, though, is that pip takes a long time to run on a Raspberry Pi and using it this way seriously slows down boot time, even when there is no upgrade to install.\nIs there a better way I haven't thought of?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":78,"Q_Id":68059963,"Users Score":0,"Answer":"You can make an API or mount server where the Raspberry request if there's a new version to update (you have to save what's is the current version installed), if there is, apply the update.\nIt is not a pythonic solution at all, but I will work for your purpose.","Q_Score":0,"Tags":"python,pip,cron,raspberry-pi,systemd","A_Id":68060080,"CreationDate":"2021-06-20T20:56:00.000","Title":"Auto-updating python package on Raspberry Pi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a Python lambda function which gets executed as soon as a .zip file lands in a particular folder in an s3 bucket. Now there may be a situation where there is no file uploaded to the S3 within in a certain time period (for example 10 AM morning). How to get an alert for tracking no file arrival?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":193,"Q_Id":68063023,"Users Score":0,"Answer":"You may use cloudwatch alarms. You can set an alarm when no event (e.g. lambda execution) is present for metrics.\nIt has only basic options to configure, but imho it's the simplest solution","Q_Score":0,"Tags":"python-3.x,amazon-web-services,aws-lambda","A_Id":68063142,"CreationDate":"2021-06-21T06:02:00.000","Title":"Alert for no file uploaded to S3 within a particular time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to archive multiply files that exists on s3 and then upload the archive back to s3.\nI am trying to use lambda and python. As some of the files have more than 500MB, downloading in the '\/tmp' is not an option. Is there any way to stream files one by one and put them in archive?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2517,"Q_Id":68065587,"Users Score":0,"Answer":"The \/tmp\/ directory is limited to 512MB for AWS Lambda functions.\nIf you search StackOverflow, you'll see some code from people who have created Zip files on-the-fly without saving files to disk. It becomes pretty complicated.\nAn alternative would be to attach an EFS filesystem to the Lambda function. It takes a bit of effort to setup, but the cost would be practically zero if you delete the files after use and you'll have plenty of disk space so your code will be more reliable and easier to maintain.","Q_Score":1,"Tags":"python,amazon-web-services,aws-lambda","A_Id":68066323,"CreationDate":"2021-06-21T09:32:00.000","Title":"How to zip files on s3 using lambda and python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some python airflow dag code that I have inherited and I am not sure where certain module operators are now.\nThe line I am getting an error on is:\nfrom AirflowHelpers.base_utils import get_airflow_version, get_airflow_home_directory, AIRFLOW_TYPE\nThat AirflowHelpers is an unresolved reference and I cannot find a module for this to install. I'd thought it was in the airflow.utils.helpers but I do not see anything related to get_airflow_version, get_airflow_home_directory or AIRFLOW_TYPE\nWere these moved to a different module within airflow and if so which submodule are these buried in? Even a pointer to searchable documentation would help.\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":27,"Q_Id":68068472,"Users Score":0,"Answer":"This was an internally created module.","Q_Score":0,"Tags":"python-3.x,airflow","A_Id":68071678,"CreationDate":"2021-06-21T13:04:00.000","Title":"What module do I use for AirflowHelpers.base_utils what has get_airflow_version, get_airflow_home_directory changed to?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I choose heroku for use my simple python script that gets telegram messages and parses them. So when i start the script on heroku it asked for telegram number and confirmation code, but i cant to enter them because i started it by command: heroku ps:scale bot=1 and have no access to heroku terminal. Is there a solution to this problem?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":233,"Q_Id":68081378,"Users Score":0,"Answer":"I think you need to pass your session string in telethon","Q_Score":0,"Tags":"python,heroku,telegram-bot,telethon,telegram-api","A_Id":68084903,"CreationDate":"2021-06-22T09:53:00.000","Title":"Need to enter telegram code after starting python bot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I choose heroku for use my simple python script that gets telegram messages and parses them. So when i start the script on heroku it asked for telegram number and confirmation code, but i cant to enter them because i started it by command: heroku ps:scale bot=1 and have no access to heroku terminal. Is there a solution to this problem?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":233,"Q_Id":68081378,"Users Score":1,"Answer":"You don't need to enter code everytime, because once you logged in, it will create a session file. So use that session file.","Q_Score":0,"Tags":"python,heroku,telegram-bot,telethon,telegram-api","A_Id":68081468,"CreationDate":"2021-06-22T09:53:00.000","Title":"Need to enter telegram code after starting python bot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've cobbled together a small blog application in Django using Haystack with Whoosh backend for search. It runs nicely in development server (on the laptop) but search fails when site runs in nginx on a server (rpi).\nI can access search page but any search results in Server Error (500), no additional info available from either nginx or django logs. I had RealtimeSignalProcessor on but turned it off - no change. Any pointer on how to attempt to debug this would be great.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":80,"Q_Id":68083032,"Users Score":0,"Answer":"Thanks for pointing the obvious. With DEBUG=True i get: \"The path to your Whoosh index '\/path\/to\/my\/mysite\/whoosh_index' is not writable for the current user\/group.\" which is then easily remedied by changing either file permissions or ownership of the folder to allow user, in my case nginx, write access.","Q_Score":1,"Tags":"python,django,nginx,django-haystack,whoosh","A_Id":68088062,"CreationDate":"2021-06-22T11:50:00.000","Title":"nginx + django + haystack = Server Error (500)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have abc.pth file which is a feature file. I want to determine the shape\/dimension of this file through google colab. how to load it and determine its shape?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":155,"Q_Id":68101600,"Users Score":0,"Answer":"path=\"\/path\/to\/abc.pth\"\nimport torch a=torch.load(path) a.size()\n\nand it will output the tensor\n\ntorch.Size([1, 2048, 19, 29])","Q_Score":0,"Tags":"python,model,google-colaboratory,shapes,dimension","A_Id":68101945,"CreationDate":"2021-06-23T14:14:00.000","Title":"How to determine shape of .pth file in google colab","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to know which codes on github are in python 3? So far, I haven't any mentionned.\nTks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":23,"Q_Id":68104525,"Users Score":0,"Answer":"Very simply:\n\nYes, you can find Python3 code.\nNo, you cannot do so effectively.\n\nCode on GitHub is not identified by language and version -- obviously, since you would have found that in your investigations before coding. Yes, you can generally determine the language of a code file, but only with detailed examination -- you would almost need to pass the file to a Python compiler and reject any with syntax errors. This is not an effective process.\nYou can reduce the search somewhat by gleaning *.py files and then look for frequent, 3-specific features, such as all print commands using parentheses (coding style in Python 2, mandated in Python 3). This merely reduces the problem; it does not give you a good request mechanism.","Q_Score":0,"Tags":"python,github,version","A_Id":68104645,"CreationDate":"2021-06-23T17:23:00.000","Title":"how can I find python 3 codes only on github?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to run python script on google cloud using android studio\n\nex: I have an android application which contain button and google cloud VM instance which has a python script.\nI want when click button, the script is run and output send to storage.\nhow I can do that ?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":94,"Q_Id":68124052,"Users Score":-1,"Answer":"I suppose you're running a linux-based distribution as your operating system. I think that you could do that by sending a command to the VM via ssh, and by using pipes in linux you could direct the output to a specific file.\nLet's say you have your python script named script_one.py\nWith this command python3 script_one.py > output.txt you basically run the script and the output of it is stored in the file output.txt in the same directory where the python script is, now of course you could use absolute or relative path to redirect your output to another place.\nDepending on the language you're developing your application in, this can be implemented in different ways.","Q_Score":0,"Tags":"python,android,google-cloud-platform,google-compute-engine","A_Id":68124117,"CreationDate":"2021-06-25T00:22:00.000","Title":"How to run python script on google cloud using android studio?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a Python script that creates a new user and configures it, I want this to be ran anytime a user SSHs into the server but the username isn't a valid one, how could I do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":28,"Q_Id":68138743,"Users Score":0,"Answer":"That is an incredibly bad idea. How would they learn what password you assigned? Consider how easy it would be to write a denial of service attack to log in as millions of unknown users. Hackers do that EVERY DAY to any public-facing server. Much better idea to have a web site where people register for a new username.","Q_Score":0,"Tags":"python,ssh","A_Id":68139097,"CreationDate":"2021-06-26T02:34:00.000","Title":"How to run a script if a user SSHs into an non-existent user?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use Python to made a Discord bot to \"auto-fishing\"(Tatsu's fishing game) by sending \"t!fish\".\nBut when it sent the message, Tatsu didn't response. Is it possible to make a bot like a user?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":149,"Q_Id":68142414,"Users Score":0,"Answer":"The task you want your bot to do is impossible because the discord API implicitly makes sure bots dont to react to commands sent by other bots.\nSince if it could you would be able to spam other bots.\nThe only way you can get over this is by giving your bot a user TOKEN instead of a bot TOKEN but then the user TOKEN you use will get banned.","Q_Score":0,"Tags":"python,discord,discord.py","A_Id":68142630,"CreationDate":"2021-06-26T12:35:00.000","Title":"How to make a Discord bot active another bots?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I can retweet a tweet by using the tweepy library. But what I want to do is to quote a tweet. I can\u2019t find anything about it.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":209,"Q_Id":68155458,"Users Score":3,"Answer":"To post a quote Tweet, you include the link to the original Tweet in the body of the new Tweet you are posting.","Q_Score":2,"Tags":"python,twitter","A_Id":68175974,"CreationDate":"2021-06-27T21:34:00.000","Title":"Quote a tweet with Twitter API by using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using ffmpeg to read and write raw audio to\/from my python script. Both the save and load commands I use produce the warning \"Guessed Channel Layout for Input Stream #0.0 : mono\"? This is despite that fact that I am telling ffmpeg using -ac 1 before both the input and output that there is only one channel. I saw some other answers where I should set -guess_layout_max 0 but this seems like a hack since I don't want ffmpeg to guess; I am telling it exactly how many channels there are with -ac 1. It should not need to make any guess.\nMy save command is formatted as follows with r being the sample rate and f being the file I want to save the raw audio to. I am sending raw audio via stdin from python over a pipe.\nffmpeg_cmd = 'ffmpeg -hide_banner -loglevel warning -y -ar %d -ac 1 -f u16le -i pipe: -ac 1 %s' % (r, shlex.quote(f))\nLikewise my load command is the following with ffmpeg reading from f and writing raw audio to stdout.\nffmpeg_cmd = 'ffmpeg -hide_banner -loglevel warning -i %s -ar %d -ac 1 -f u16le -c:a pcm_u16le -ac 1 pipe:' % (shlex.quote(f), r)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1631,"Q_Id":68161835,"Users Score":4,"Answer":"-ac sets no. of channels, not their layout, of which there can be multiple for each value of a channel count.\nUse the option -channel_layout.\nffmpeg -hide_banner -loglevel warning -y -ar %d -ac 1 -channel_layout mono -f u16le -i pipe: ...","Q_Score":3,"Tags":"python,ffmpeg","A_Id":68172509,"CreationDate":"2021-06-28T10:34:00.000","Title":"Why is ffmpeg warning \"Guessed Channel Layout for Input Stream #0.0 : mono\"?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I would like to ask if it's possible to run a set of tests written in python (pytest)\non a running NodeJS application running in Docker?\nWhat I want to achieve:\n1.setup github action to run and build the 'test Docker container' on pull_request (done)\n2.run pytest as soon as the node container starts (pending)\n3.run another github workflow based on the test results of pytest (there is also a question how to achieve it,I saw somewhere that maybe cypress can help)\nPlease let me know if I should provide Dockerfile if it's necessary\nthanks in advance","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":744,"Q_Id":68176685,"Users Score":0,"Answer":"Solved by using ENTRYPOINT in Dockerfile, where I put my bash script which run npm start & pytest -c xxx","Q_Score":0,"Tags":"python,node.js,docker,github,pytest","A_Id":68224989,"CreationDate":"2021-06-29T10:11:00.000","Title":"How to run pytest tests after docker container starts","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"How can i open and close any programm on my raspberry pi using python?\nI want to open florence.desktop (Virtual Keyboard) and close it.\nI have tried it with:\nP = subprocess.Popen([\"\/usr\/share\/applications\/florence.desktop\"]\nbut the error message is:\nTraceback (most recent call last):\nFile \"\/usr\/lib\/python3.7\/tkinter\/init.py\", line 1705, in call\nreturn self.func(*args)\nFile \"\/home\/pi\/Desktop\/Software_1.0.2\/Software\/Software\/Hautpprogramm\/Start_Seite.py\", line 588, in \nWartungs_Button = Button(root, text=\"Wartungsfunktion\", font=bigFont, fg =\"black\", bg=\"#D3d3d3\", command=lambda: newWindow_Wartung_PW())\nFile \"\/home\/pi\/Desktop\/Software_1.0.2\/Software\/Software\/Hautpprogramm\/Start_Seite.py\", line 165, in newWindow_Wartung_PW\nP = subprocess.Popen([\"\/usr\/share\/applications\/florence.desktop\"])\nFile \"\/usr\/lib\/python3.7\/subprocess.py\", line 775, in init\nrestore_signals, start_new_session)\nFile \"\/usr\/lib\/python3.7\/subprocess.py\", line 1522, in _execute_child\nraise child_exception_type(errno_num, err_msg, err_filename)\nPermissionError: [Errno 13] Permission denied: '\/usr\/share\/applications\/florence.desktop'","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":80,"Q_Id":68190036,"Users Score":0,"Answer":"normally you should try to execute your script with sudo, but that wouldn't help here, because you're trying to run a .desktop file, that's not really a program. Try this: subprocess.Popen([\"florence\"])","Q_Score":1,"Tags":"python,raspberry-pi,raspberry-pi-zero","A_Id":68190124,"CreationDate":"2021-06-30T07:14:00.000","Title":"Open Programms on Raspberry Pi using Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I started to using the Dronekit, Dronekit-STIL and Mavlink to simulate my python scripts. Afters some days using it without problem I started to receive the error: WARNING:dronekit:Link timeout, no heartbeat in last 5 seconds.\nI had tried to reinstall all the things but nothings works.\nI had install the PIP pachages on Linux Ubutun 18. I had try the same packages on Ubutun 20 but I receive the same error.\nI had install this packages:\npymavlink>=2.3.3\nMAVProxy-1.8.39\ndronekit-2.9.2\ndronekit-sitl-3.3.0\nPython 2.7.17\nFollow my steps to receive the error:\n1 - dronekit-sitl copter --home=-25.56731,-42.61554,0,180\nos: linux, apm: copter, release: stable\nSITL already Downloaded and Extracted.\nReady to boot.\nExecute: \/home\/cesar\/.dronekit\/sitl\/copter-3.3\/apm --home=-23.56731,-46.61554,0,180 --model=quad -I 0\nStarted model quad at -23.56731,-46.61554,0,180 at speed 1.0\nbind port 5760 for 0\nStarting sketch 'ArduCopter'\nSerial port 0 on TCP port 5760\nStarting SITL input\nWaiting for connection ....\nbind port 5762 for 2\nSerial port 2 on TCP port 5762\nbind port 5763 for 3\nSerial port 3 on TCP port 5763\n2 - mavproxy.py --master tcp:127.0.0.1:5760 --out udp:127.0.0.1:14551 --out udp:10.0.2.15:14550\nConnect tcp:127.0.0.1:5760 source_system=255\nLog Directory:\nTelemetry log: mav.tlog\nMAV> Waiting for heartbeat from tcp:127.0.0.1:5760\nonline system 1\nSTABILIZE> Mode STABILIZE\nAP: Calibrating barometer\nAP: Initialising APM...\nAP: barometer calibration complete\nAP: GROUND START\nInit Gyro**\nINS\nG_off: 0.00, 0.00, 0.00\nA_off: 0.00, 0.00, 0.00\nA_scale: 1.00, 1.00, 1.00\n3 - python hello.py\nStart simulator (SITL)\nStarting copter simulator (SITL)\nSITL already Downloaded and Extracted.\nReady to boot.\nConnecting to vehicle on: tcp:127.0.0.1:5760\nWARNING:dronekit:Link timeout, no heartbeat in last 5 seconds\nafter 30s\nERROR:dronekit.mavlink:Exception in MAVLink input loop\nTraceback (most recent call last):\nFile \"\/usr\/local\/lib\/python2.7\/dist-packages\/dronekit\/mavlink.py\", line 211, in mavlink_thread_in\nfn(self)\nFile \"\/usr\/local\/lib\/python2.7\/dist-packages\/dronekit\/init.py\", line 1371, in listener\nself._heartbeat_error)\nAPIException: No heartbeat in 30 seconds, aborting.\nTraceback (most recent call last):\nFile \"hello.py\", line 11, in\nvehicle = connect(connection_string, wait_ready=True)\nFile \"\/usr\/local\/lib\/python2.7\/dist-packages\/dronekit\/init.py\", line 3166, in connect\nvehicle.initialize(rate=rate, heartbeat_timeout=heartbeat_timeout)\nFile \"\/usr\/local\/lib\/python2.7\/dist-packages\/dronekit\/init.py\", line 2275, in initialize\nraise APIException('Timeout in initializing connection.')\ndronekit.APIException: Timeout in initializing connection.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":825,"Q_Id":68213754,"Users Score":0,"Answer":"Hard to say without knowing the content of hello.py.\nTry connecting through udp:127.0.0.1:14551 in the hello.py script rather than tcp:127.0.0.1:5760.\nAlso, it looks like you're starting another SITL instance from your script, but again, hard to know without seeing the code.","Q_Score":0,"Tags":"linux,dronekit-python,dronekit","A_Id":68954285,"CreationDate":"2021-07-01T16:23:00.000","Title":"DRONEKIT - WARNING:dronekit:Link timeout, no heartbeat in last 5 seconds","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am planning stop my execution in PyTest after it encounters n failures.\nSo I have used the below command:\npytest filename.py -v --maxfail = 1\nBut it displays below error, unable to find the solution. Please throw some light.\nERROR: usage: pytest [options] [file_or_dir] [file_or_dir] [...]\npytest: error: argument --maxfail: invalid int value: '=1'","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":23,"Q_Id":68221415,"Users Score":0,"Answer":"pytest filename.py -v --maxfail=1\nRemoved the spaces near = (equal to symbol) and it worked like a charm.","Q_Score":0,"Tags":"python,pytest","A_Id":68320428,"CreationDate":"2021-07-02T07:45:00.000","Title":"Pytest stop_test_suite_after_n_test_failures - Error is displayed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a script that we wanted to run in AWS as a Lambda, written in Python. This will run once ever 24 hours. It describes all the ec2 instances in an environment and I'm checking some details for compliance. After that, we want to send all the instances details to an SNS topic that other similar compliance scripts are using, which are sent to a lambda and from there, into sumologic. I'm currently testing with just one environment, but there is over 1000 instances and so over 1000 messages to be published to SNS, one by one. The lambda times out long before it can send all of these. Once all environments and their instances are checked, it could be close to 6000 messages to publish to SNS.\nI need some advice on how to architect this to work with all environments. I was thinking maybe putting all the records into an S3 bucket from my lambda, then creating another lambda that would read each record from the bucket say, 50 at a time, and push them one by one into the SNS topic. I'm not sure though how that would work either.\nAny ideas appreciated!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":220,"Q_Id":68226123,"Users Score":0,"Answer":"I think you could you a SQS queue to solve you problem.\nFrom SNS send the message to a SQS queue. Then from the SQS you lambda can poll for messaged ( default is 10 but you can decrees it though cli ).","Q_Score":1,"Tags":"python-3.x,amazon-web-services,amazon-ec2,aws-lambda,amazon-sns","A_Id":68226854,"CreationDate":"2021-07-02T13:33:00.000","Title":"Publishing over 6000 messages to SNS from a lambda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm working on a page\/project that would allow our customers to check a webpage to see if their network is ready to plug in a cloud based device. The page should query a specific HTTPS URL, check it returns anything other than HTTP 200, then go to the next URL. At the end of the test, it should give a summary of what isn't reachable. Ideally, it should be purely HTML based but I'm struggling to find ways to do this. I also need it to check the certificate status of a URL to make sure the network isn't using behind a firewall running SSL inspection. Is this possible just by using HTML?\nI can easily do this in python\/requests and could just send them a script to run on their computer, but the goal of this project is to make this as seamless as possible. We just send them a link and a non IT person could check if the network is ready then report to us what test failed.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":16,"Q_Id":68232721,"Users Score":0,"Answer":"You can't do these things with pure html. you need to use javascript and also you should know that you cant do network layer operations with just application layer technologies. so simple answer is no you can't do it just by using html.","Q_Score":0,"Tags":"python,html,curl,get","A_Id":68235262,"CreationDate":"2021-07-03T02:11:00.000","Title":"HTML based network testing tool","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I need to run some python code on aws platform periodically(probably once a day). Program job is to connect to S3, download some files from bucket, do some calculations, upload results back to S3. This program runs for about 1 hour so I cannot make use of Lambda function as it has a maximum execution time of 900s(15mins).\nI am considering to use EC2 for this task. I am planning to setup python code into a startup and execute it as soon as the EC2 instance is powered on. It also shuts down the instance once the task is complete. The periodic restart of this EC2 will be handled by lambda function.\nThough this a not a best approach, I want to know any alternatives within aws platform(services other than EC2) that can be best of this job.\nSince","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":276,"Q_Id":68234790,"Users Score":2,"Answer":"If you are looking for other solutions other than lambda and EC2 (which depending on the scenario it fits) you could use ECS (Fargate).\nIt's a great choice for microservices or small tasks. You build a Docker image with your code (Python, node, etc...), tag it and then you push the image to AWS ECR. Then you build a cluster for that and use the cloudwatch to schedule the task with Cloudwatch or you can call a task directly either using the CLI or another AWS resource.\n\nYou don't have time limitations like lambda\nYou don\u2019t also have to setup the instance, because your dependencies are managed by Dockerfile\nAnd, if needed, you can take advantage of the EBS volume attached to ECS (20-30GB root) and increase from that, with the possibility of working with EFS for tasks as well.\n\nI could point to other solutions, but they are way too complex for the task that you are planning and the goal is always to use the right service for the job\nHopefully this could help!","Q_Score":1,"Tags":"python,amazon-web-services,amazon-ec2,aws-lambda,job-scheduling","A_Id":68308309,"CreationDate":"2021-07-03T09:08:00.000","Title":"Run python code on AWS service periodically","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have been scraping emails from a shared mailbox using imap_tools. The script checks the mailbox as frequently as possible and I use msgs = client.fetch(AND(seen=False)) to check only unread emails.\nEven though I check frequently sometimes emails are not scraped because another user has already opened the email.\nIs there another way of checking for new emails, eg using UIDs?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":75,"Q_Id":68247797,"Users Score":0,"Answer":"Emails has message-id header, it is constant.","Q_Score":0,"Tags":"python,imap-tools","A_Id":68264227,"CreationDate":"2021-07-04T18:41:00.000","Title":"Reading New Email Using UIDs with imap_tools","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to game development. I am trying to start high and make a 3D RPG. I know the road is not gonna be easy. That is why i decided to use Ursina and python to make my game.\nHowever i wanna add a cutscene showing a Backstory. I have the video in mp4 format but i cannot seem to know how to play it inside the game with Ursina.\nAnyhelp will be much appreciated.\n(Side question : do you think Ursina is good for a beginner in 3D gaming? If i want to publish my game on my website, isn't it better for me to learn javascript ? I read about Unity but it is too big to download for a little side project)","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":356,"Q_Id":68248623,"Users Score":0,"Answer":"From Entity Basics in the documentation:\ne4 = Entity(model='cube', texture='movie_name.mp4') # set video texture","Q_Score":0,"Tags":"python,python-3.x,video,game-engine,ursina","A_Id":69452775,"CreationDate":"2021-07-04T20:35:00.000","Title":"How to play MP4 with Ursina in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am new to game development. I am trying to start high and make a 3D RPG. I know the road is not gonna be easy. That is why i decided to use Ursina and python to make my game.\nHowever i wanna add a cutscene showing a Backstory. I have the video in mp4 format but i cannot seem to know how to play it inside the game with Ursina.\nAnyhelp will be much appreciated.\n(Side question : do you think Ursina is good for a beginner in 3D gaming? If i want to publish my game on my website, isn't it better for me to learn javascript ? I read about Unity but it is too big to download for a little side project)","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":356,"Q_Id":68248623,"Users Score":0,"Answer":"Well, I don't think there is a way to do that. the closest thing you can do to that is having a folder filled with all the frames of your video in .png or .jpg files, then adding a quad to the world and changing the texture of it to the next frame every fraction of a second depending on the framerate. this, however would make your computer l a g. trust me, I've tried it. it would probably be better to have a separate window with some sort of module that plays .mp4 files for playing the file.\nIn other words, there is no feasible way to do that.","Q_Score":0,"Tags":"python,python-3.x,video,game-engine,ursina","A_Id":69451218,"CreationDate":"2021-07-04T20:35:00.000","Title":"How to play MP4 with Ursina in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to have a PHP program call a python program and have it run the background. When I call this from the shell nohup python3 automation.py args >\/dev\/null 2>&1 & , everything runs fine. I run top and jobs and I can see that it is executing. The script finishes successfully.\nNow I would like this script to be called from a PHP program and then run in the background, so I am using this command, which is the same above. For the program not to hang, I output it to null.\nexec('nohup python3 automation.py args >\/dev\/null 2>&1 &')\nEverything runs fine for awhile when I administer a top but then it dies after a few seconds and I am left scratching my head to figure out why. How do I troubleshoot this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":68248674,"Users Score":0,"Answer":"Problem solved. The linux user that PHP is used when commands are executed is www-data. That user didn't have write permissions for the file. To log in as www-data for testing, run this su -s \/bin\/bash www-data. Any command you execute in the shell should be equivalent to calling it from PHP.","Q_Score":0,"Tags":"python,php","A_Id":68277024,"CreationDate":"2021-07-04T20:48:00.000","Title":"Why is my python script dying in the background when called from PHP?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to see if I can protect my python source code in the following scenario:\n\nI am managing a linux server, where I am the only one to have root privileges\nMy users have separated user accounts on this server\nI want to find a way to install a private pure-python module on this server so that my users may import that module, without them being able to access the code\n\nIs there a way to do such a thing?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":97,"Q_Id":68263063,"Users Score":1,"Answer":"It sounds like you want a code obfuscation tool, which makes code unreadable without some very dedicated reverse engineering by renaming variables, functions, modules, etc., replacing their names with gibberish.\nIf a computer can execute code, then someone with admin access to that computer can also read the compiled code, no exceptions. If you don't want someone to steal your logic, you obfuscate. If you don't want people to pirate your software (use it without paying), you can add some software protections (research how other subscription software is protected) and obfuscate those as well, so that it's hard to bypass the restrictions and clearly in breach of IP laws.\nAlternatively (if suitable, which it usually is), you might want to run the code on your own server and publish an API for your customers to use. For their convenience, you might also develop an abstraction of the public API for clients to use. This won't let clients access code at all; clients indirectly ask the server to do something, and the server does it if everything is in order (the client has a valid subscription, for example).","Q_Score":0,"Tags":"python,linux,copy-protection","A_Id":68280040,"CreationDate":"2021-07-05T23:49:00.000","Title":"Keeping Python Code Private On Controlled Linux Server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm looking for a way to run JUnit tests and get the results (whatever the format or the structure) in python. My first guess has been to use JPype, but I would like to know if you know any simpler solution ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":42,"Q_Id":68301737,"Users Score":0,"Answer":"I've managed to extract tests results with a combination of surefire XML reports along with the lxml python module. To use the intermediate XML reports seems to be the easiest yet the most efficient method.","Q_Score":0,"Tags":"java,python,python-3.x,junit","A_Id":69631568,"CreationDate":"2021-07-08T12:34:00.000","Title":"Retrieve JUnit tests results with python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to make a custom 'Share' button with telebot. Is there any option to handle InlineKeyboardButton with switch_inline_query parameter is set? I want to know in which chat\/user the message was sent.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":133,"Q_Id":68315616,"Users Score":0,"Answer":"I made 'share' button by deep link with unique 'start' parameter value.","Q_Score":0,"Tags":"python,telegram,telegram-bot,py-telegram-bot-api","A_Id":68573573,"CreationDate":"2021-07-09T10:55:00.000","Title":"Telebot InlineKeyboardButton how to hanlde switch_inline_query?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to list down all the EC2 instances with its IAM role attached using boto3 in python3. But I don't find any method to get the IAM role attached to existing EC2 instance. is there any method in boto3 to do that ?\nWhen I describe an Instance, It has a key name IamInstanceProfile. That contains instance profile id and arn of the iam instance profile. I don't find name of IAM instance profile or any other info about IAM roles attached to it. I tried to use instance profile id to describe instance profile, But it seems to describe an instance profile, we need name of instance profile (not the id).\nCan someone help on this ? I might be missing something.\nThanks","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1002,"Q_Id":68347014,"Users Score":1,"Answer":"When we describe EC2 instance, We get IamInstanceProfile key which has Arn and id.\nArn has IamInstanceProfile name attached to it.\nArn': 'arn:aws:iam::1234567890:instance-profile\/instanceprofileOrRolename'\nThis name can be used for further operation like get role description or listing policies attached to role.\nThanks","Q_Score":1,"Tags":"python-3.x,amazon-web-services,amazon-ec2,boto3","A_Id":68347354,"CreationDate":"2021-07-12T11:59:00.000","Title":"is there a way to get name of IAM role attached to an EC2 instance with boto3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am making a music player with flutter so, I wanna to ask how to access all the files of a particular extension ( mp3, wav ) with it's details in Flutter or if not in Flutter then Python to play those music files with details like song name, author name","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":67,"Q_Id":68372110,"Users Score":1,"Answer":"If u are using flutter with native app, then you can use path_provider and the dart File to get all you want in Android. However, ios is more like a sandbox, so it is hard to get what u want.","Q_Score":1,"Tags":"python,flutter,file","A_Id":68372605,"CreationDate":"2021-07-14T04:35:00.000","Title":"Accessing Files from User Device using Flutter or Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm doing some load testing with locust and I cant seem to figure out how to change the Hatch Rate to a slower ramp up rate. 1 locust per second is still too fast so is there a way to change this to something that would resemble 1 locust every 20 seconds?\nI've tried using gevent.sleep(19) within the on_start method and setting the hatch rate to 1 locust per second in the UI but this only hatches each locust 1 second apart and then each hatched locust sleeps for 19 seconds (they are still 1 seconds apart).\nIs there a way of forcing each locust hatched at run time to wait 20 seconds before the next locust executes? (e.g. the first locust hatches and runs the on_start method, the next locust waits 19 seconds and then runs the on_start method, the next locust waits 19 seconds more and then runs the on_start method.)","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":418,"Q_Id":68377946,"Users Score":3,"Answer":"The hatch rate\/ramp up parameter accepts float values. Use a hatch rate of 0.05 to spawn one user every 20 seconds.","Q_Score":0,"Tags":"python,python-3.x,load-testing,locust","A_Id":68379445,"CreationDate":"2021-07-14T12:16:00.000","Title":"Locust load testing - Change hatch rate from 1 second to say 20 seconds? (1 locust every 20 seconds)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I suspect it may be rather kid question \u2013 but anyway.\nHow to open another Telegram chat or group or channel using pyTelegramBotAPI? I want to forward the user (not message, the user himself) to another channel if he clicks certain button.\nI saw content type migrate_to_chat_id in Message class declaration. Should I use it? If so, how to get an id of channel I need? It won't send any message to my bot.\nI would better use \"t.me\/...\" url.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":116,"Q_Id":68395653,"Users Score":0,"Answer":"Partly solved.\nSpeaking about the buttons, it is indeed easy. You just use named parameter url= in InlineKeyboardButton() method.\nFor other cases. You need to open another channel(s) from function depending on several conditions for instance. Still don't know. Import requests and make GET request? I suspect that something for it should already be in pyTelegramBotAPI, but searching in lib files wasn't successful.","Q_Score":0,"Tags":"python,py-telegram-bot-api","A_Id":68426320,"CreationDate":"2021-07-15T14:23:00.000","Title":"Open another Telegram chat\/group\/channel using Bot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have data which is processed sequentially, changing from\nState A -> State B -> State C\nIf I had functions\ndef convertAtoB(obj):...\ndef convertBtoC(obj):...\nHow would I write a unit test to test convertBtoC? Since unit tests must be independent from each other, I can't call convertAtoB within the unit test to create the object of state B.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":42,"Q_Id":68426086,"Users Score":1,"Answer":"Either create a mock version of B or create a full static version of B and pass it to convertBtoC.\nFor example:\nfetchJSONWeatherOverHTTP(weatherRequest) -> convertJSONWeatherIntoDataclass(jsonWeather)\nweatherRequest -> jsonWeather -> weather\nIn this case we'd need to mockup the jsonWeather object with fake data or use an old result because we would not want to perform an http request in our unit test.","Q_Score":0,"Tags":"python,unit-testing","A_Id":68426255,"CreationDate":"2021-07-18T04:45:00.000","Title":"Writing unit tests for functions in a pipeline","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am creating a personal website using flask and python. I am using flask-mail to set up a smtp server with gmail, which requires the credentials of a gmail account. I wanted to know if there was a way to encrypt or protect the password and account of my gmail when pushing to GitHub?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":161,"Q_Id":68446751,"Users Score":0,"Answer":"Never Push your credentials and API keys to Github, always prefer to store these credentials in env file.","Q_Score":0,"Tags":"python,flask,github,flask-mail","A_Id":68446819,"CreationDate":"2021-07-19T20:37:00.000","Title":"Password protection for public github","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Recently, I learned that C++ codes runs faster than Python. We have post-processing Python script which takes huge time to run. So, I'm thinking of replacing them with C++ code. I know that C++ code can only be used for Post-processing, and that is fine for me.\nI am not sure how to run the C++ code in Abaqus. I know that I need a compiler to compile the C++ code, like Visual Studio. But I don't know about integrating it with Abaqus and overall flow to compile and run the script.\nAny help will be much appreciated!","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":126,"Q_Id":68449638,"Users Score":-1,"Answer":"Recently, I have the same problem with you,if you want to use C++ you must use the script in command: abaqus make job=filename.cpp.Then abaqus will give you a file:filename.exe,I think that C++ is same as fortran,I couldn't link it to abaqus ,so I couldn't run the .exe file,if you can solve my problem I would appreciate that you could answer me.","Q_Score":0,"Tags":"python,c++,visual-studio,abaqus","A_Id":68647599,"CreationDate":"2021-07-20T04:42:00.000","Title":"Integrating compiler to compile C++ code and running it in Abaqus","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have made a tester file to check my other files are implementing correctly, however I can only get an output by clicking run on the file (top right green arrow). When I type 'python Test.py' in the terminal I get :\n\nFatal Python error: initsite: Failed to import the site module\nModuleNotFoundError: No module named 'site'\nCurrent thread 0x0000000102c0ce00 (most recent call first):\n\nI assume this is an environment issue for my terminal? I am in the correct folder (one above Test.py).\nAny ideas how I can change this?\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":28,"Q_Id":68453528,"Users Score":1,"Answer":"It looks like the python interpreter you are taking when you run python Test.py in the terminal is different from the one when you click the Run Python File in Terminal(green triangle) button.\nCould you type this command in the VSCode terminal(CMD: where python; Powershell: get-command python) to check which python you are using when you take python Test.py command to run your python file? And compare it with another one.","Q_Score":0,"Tags":"python,visual-studio-code,terminal,vscode-settings","A_Id":68466910,"CreationDate":"2021-07-20T10:43:00.000","Title":"Running a tester file in the VSC terminal - ModuleNotFoundError","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I reimaged my RPi4 to a fresh copy of Raspbian (V10, \"buster\"). After doing that I lost my SSH connection for remote debugging in VS Code (in Windows 10). I was able to get the SSH back up and running, but when I run the debugger it crashes and the end of the traceback gives me this message.\nFile \"\/usr\/lib\/python3.7\/ctypes\/init.py\", line 374, in getitem\nfunc = self._FuncPtr((name_or_ordinal, self))\nAttributeError: \/bin\/python3: undefined symbol: AttachDebuggerTracing\nI have searched for this undefined symbol error but have not been able to find any information on what might be causing this.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":299,"Q_Id":68490280,"Users Score":0,"Answer":"We are having the same issue on two different computers that debugging fine one day and then not starting the next. I have been searching all day for answers on the web and so far found nothing useful.","Q_Score":0,"Tags":"python","A_Id":68490727,"CreationDate":"2021-07-22T19:05:00.000","Title":"VS Code Remote Debugger Fails to run on RPi 4","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to manually push updates\/files to devices located on different networks. I know I can run a periodic repository pull command but that is not efficient and based on fixed time intervals. I would like to setup an instant file push instead of a time based one. For example, when I upload a new file all the devices detect this OR are notified by the master an update is ready. How can I make a new file upload detected by my devices as close to instant as possible?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":44,"Q_Id":68491807,"Users Score":1,"Answer":"I'm not sure the scale of the project you're trying to accomplish, but I've set up a sort of auto-update checker in Python before. The basic idea is that you'd have a location to host the file and some way to determine if the file has been changed (I used a version number). This can be a basic web server located on the Pi. Then, each client checks the web server whenever you think it's appropriate to do an update, for example at the start of the program. If there is a version number mismatch, you can automatically pull the file from the web server, or direct the user to download it manually.","Q_Score":0,"Tags":"python,shell,updates","A_Id":68491883,"CreationDate":"2021-07-22T21:42:00.000","Title":"Push a file to multiple devices at once","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"So I would like to know if its possible to make a code the\nmakes a cooldown\nper role\nlike premium has no cooldown\nand bronze has a 10 second\ncooldown if so how can I do it ?\nfor commands","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":106,"Q_Id":68495705,"Users Score":0,"Answer":"Why with commands? Wouldn't it be much easier to add and remove the roles with a command and control the cooldown via the server settings?\nWith a simple level-system this would be done very quickly.\n(You could store the number of messages in a simple .json file and after a certain amount of messages add\/remove the corresponding role.)","Q_Score":0,"Tags":"python,discord,discord.py","A_Id":68502882,"CreationDate":"2021-07-23T07:42:00.000","Title":"how to make a different cooldown for each role in discord in py","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to change the outgoing smtp ip address, i succeeded to change ip address using source_address=(host,port)\nexample : smtpserver = smtplib.SMTP(\"smtp.gmail.com\", 587,source_address=('185.193.157.60',12323)\nBut i can't find how to add username and password of the proxy ( if the proxy requires username and password )\nI tried : smtpserver = smtplib.SMTP(\"smtp.gmail.com\", 587,source_address=('185.193.157.60',12323, 'username', 'password')\nBut it didn't work","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":68521874,"Users Score":0,"Answer":"From the docs...\nSMTP.login(user, password, *, initial_response_ok=True)","Q_Score":0,"Tags":"python,smtp","A_Id":68521903,"CreationDate":"2021-07-25T19:26:00.000","Title":"SMTP Outgoing IP ( source ip )","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing a program that involves PyAudio. I already capture a block using stream.read() and get its amplitude using an RMS function from elsewhere on StackOverflow. However, I'd like to also be able to get the (average?) frequency of that block. I think I'll need to use a (fast?) Fourier transform, since my understanding is that it can \"interpolate periodic functions,\" which sounds like exactly what I need. The issue is that I have no idea how I would go around implementing this. Ideally, I'd have a function that takes in a block and spits out a frequency in Hz.\nEDIT: Thanks to @MSalters, I now know that this question is not quite possible. Correction: Ideally, I'd have a function that would take a block and spit out an array of frequencies (or other descriptive values).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":86,"Q_Id":68528858,"Users Score":1,"Answer":"The frequency probably does not exist - the audio fragment may contain a chord with multiple notes, or percussion instruments. But as you suspected, the FFT is the correct tool. It will tell you the amplitude for each individual frequency.","Q_Score":0,"Tags":"python,fft,audio-recording,pyaudio","A_Id":68528929,"CreationDate":"2021-07-26T11:13:00.000","Title":"Get frequency of a PyAudio block","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am creating an API in PHP which pass some parameters to python and generate a report in pdf format.\nin report_gen.py file I have code to get parameters and generate pdf. Which is working successfully through command line but when I run PHP file from browser or postman it do not works.\nI want to run my PHP file through cronjob so it automatically call in specific time.\n$data = 'Basic Will Johnyy Willson Smith';\n$command = escapeshellcmd(\"python3 report_gen.py $data\");\n$output = shell_exec($command);\necho $output;","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":167,"Q_Id":68543088,"Users Score":0,"Answer":"There can be (at least) two problems.\nFirst you need to check\/know, that the server maid use another environment. I believe, that you did not use the webserver-user for your local checks. So I would try to use absolute pathes. You also have to make sure, that the python-environment (whatever you have configured) has to be the same as your local user.\nSecond you need to make sure, that you have all rights to run the file (the webserver, that is used by the webserver needs to have at least reading right on report_gen.py).","Q_Score":0,"Tags":"python,php,shell-exec","A_Id":68543527,"CreationDate":"2021-07-27T10:17:00.000","Title":"By running python script with php - working in console but not in web browser","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a Python script that goes into my Gmail inbox and looks for certain emails based off the subject line. I would like to automate this process; however, my credentials seem to expire on a weekly basis. Whenever they expire and I run my script, it opens up my browser and prompts me to authorize my app. Is there anyway this can be bypassed so that I can automate my script and not have to constantly authenticate my app through the browser?\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":352,"Q_Id":68552628,"Users Score":0,"Answer":"If your app is in the testing phase the refresh token will expire after a week. If you want your refresh token to last longer you will need to set your application to production and go though the verification process.\nif this is a google workspace email account then you should consider using a service account for authorization and setting up domain wide delegation.","Q_Score":0,"Tags":"python,google-api,google-oauth,google-api-client","A_Id":68562159,"CreationDate":"2021-07-27T23:04:00.000","Title":"How to bypass the Google API Website authentication flow","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Need some help to solve this puzzle folks:\nWhen creating a child class in Python and defining the init method, I would like to import all the attributes of the super\/parent class except certain positional parameters and\ncertain parameters (which are not defined inside parent classes' init method's list of positional or keyworded\/non-keworded parameters but) defined within\/inside the parent class init method with a default value.\nIs there a way to prevent\/avoid certain\/specific parent class attributes to be imported in the child class upon initiation? I am aware that we can override methods in the child class which do not mimic parent class behaviors, but I am not aware how to do the same with attributes, so I was thinking if I could avoid them completely!\nI will give an example of why I need a certain child class to mimic everything from its parent except certain attribute.\nConsider a parent class \"Car\". The child class will be \"ElectricCar\". The parent class has an attribute defined called \"liters_gasoline\" with certain integer as its default value.\nNow, I would like to inherit everything in the ElectricCar sub-class except that \"liters_gasoline\" parameter, because ElectricCars don't use fuel\/gasoline. How to prevent this \"liters_gasoline\" parameter from being inherited in the child class? I don't want this parameter in child class!\nHow to do this?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":674,"Q_Id":68553439,"Users Score":1,"Answer":"If something inherits from a parent class it should have all the attributes of the parent class. For example \"liters_gasoline\" should only be in the class of a gasoline car not an electric car.","Q_Score":1,"Tags":"python,class,inheritance","A_Id":68553471,"CreationDate":"2021-07-28T01:48:00.000","Title":"Prevent certain attributes to be inherited in child class","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a database of ready made images to upload to a twitter page, but can't seem to figure out a way around saving the images to my local machine first.\nThe pictures will be uploaded by a bot running on Heroku, which is pulling the code from Github, so saving and deleting images would mean constant commits etc right?\nIs it possible to upload the image directly as bytes (pre saved as a .png) and skip this? or is there another possible workaround?\nworking with python 3.8 and currently using tweepy, although the module is irrelevant if I can upload images without saving.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":82,"Q_Id":68594714,"Users Score":0,"Answer":"There are no workarounds. You'll have to write the bytes to an actual .png file before you can upload it to the Twitter API.","Q_Score":0,"Tags":"python,mysql,heroku,twitter,twitterapi-python","A_Id":68597524,"CreationDate":"2021-07-30T17:08:00.000","Title":"Upload\/Post an image to Twitter direct from MySQL database (blob\/byte format) without saving image in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"When I send mail with header like this message['Reply-To'] = '' (Python), it work fine on localhost. When I click Reply in Outlook at that received mail, To field is empty. When I send the same mail from production via company SMTP server, the mail also contains empty Reply-To header, however If I click Reply in Outlook, the address from that the mail had been received is prefilled in To field.\nIs there a bug in company SMTP or why does it work only in localhost?\nThank you.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":164,"Q_Id":68596347,"Users Score":1,"Answer":"In Reply-To empty, Outlook would default to the sender address. IMHO that is how it is supposed to work.","Q_Score":0,"Tags":"python,outlook,smtplib","A_Id":68596545,"CreationDate":"2021-07-30T19:42:00.000","Title":"Is it possible to force empty Reply-To header in mail?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using the pyTelegrambotAPI to build a bot to carry out transactions. In the course of carrying out the transaction, I ask the user for their password to authenticate them but I don\u2019t want the password message to show in the chat. This is why I want to hide the password message or if possible hash out the password.\nI\u2019ve searched everywhere and checked the documentation but I can\u2019t seem to find anything.\nI\u2019ll appreciate your solutions. Thanks.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":310,"Q_Id":68632874,"Users Score":1,"Answer":"hello! Unfortunately, there is no way to modify the message of the user who addresses you, what you could do, for example, is to save the message just sent to a database, and then proceed with deleting the message containing the password. Considering the fact that I can't see the bot surce code, I can't help you more than that!\nHave a nice day and happy coding!","Q_Score":0,"Tags":"python,telegram-bot,password-hash,py-telegram-bot-api","A_Id":68655903,"CreationDate":"2021-08-03T08:41:00.000","Title":"How can I hide a message sent from a user to my telegram bot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to download sftp files from server A and save it in server B using python. Both the servers are linux machines. I tried sftp.get(), but that's only between server and local machine. So far I have not seen any solution online. Is it possible to move the files between two servers? Please help","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":52,"Q_Id":68637176,"Users Score":0,"Answer":"I'm not a Python developer, but I know how sftp works, and I don't think you can do what you are trying to do. The best way I can think is to do a sftp.get() to download the file from Server A to your local machine, and then an sftp.put() to upload it to server B","Q_Score":0,"Tags":"python-3.x,linux,sftp,remote-server","A_Id":68637286,"CreationDate":"2021-08-03T13:42:00.000","Title":"Transferring SFTP files from one remote server(linux) to another remote server(linux) using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"so I have the following text:\n\n'\\x56\\x10\\x34\\xf8'\n\nAccording to the assignment I got, this is written in hex. however, I can't convert this into readable text or binary using the unhexlify function from the binascii library (python).\nSo I guess this is a three part question:\nI would really appreciate if someone could identify in which form this text is written, give a brief explanation about it (or give a link that explains it) and give a code that converts it from it's current form to binary and readable text.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":43,"Q_Id":68653451,"Users Score":1,"Answer":"Assuming those values map to ASCII character values, you should be able to loop over those values (possibly converting to int) and then feed them into chr(val) to obtain the corresponding character.","Q_Score":0,"Tags":"python,binary,hex","A_Id":68653518,"CreationDate":"2021-08-04T14:53:00.000","Title":"how can I convert the following text to binary and readable text? and in what form is it written?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"so I have the following text:\n\n'\\x56\\x10\\x34\\xf8'\n\nAccording to the assignment I got, this is written in hex. however, I can't convert this into readable text or binary using the unhexlify function from the binascii library (python).\nSo I guess this is a three part question:\nI would really appreciate if someone could identify in which form this text is written, give a brief explanation about it (or give a link that explains it) and give a code that converts it from it's current form to binary and readable text.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":43,"Q_Id":68653451,"Users Score":2,"Answer":"This is hex representation of ascii text.\nIn python, anything with a '\\x' is a hex character, with the 2 digits after that representing its value.\n'\\x41' represents the capital 'A' character\nYou can turn most of the characters into standard ascii using a str() call however some hex numbers do not map to readable ascii characters, for example '\\x10' maps to the new line character '\\n'.\nHowever strings formatted in this way would not act any differently if they were in their ascii counterparts. The string '\\x54\\x47\\x47\\x19' can be indexed or printed. index 0 would return '\\x54' and index 1 would return '\\x47'. Converting it is not necessary.","Q_Score":0,"Tags":"python,binary,hex","A_Id":68653641,"CreationDate":"2021-08-04T14:53:00.000","Title":"how can I convert the following text to binary and readable text? and in what form is it written?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to write a python code that is un-decryptable. Is this possible there are things like pyarmor and such that would enable a secure source code but I am looking for something that is not decryptable to maximize the security. The aim is to create a secure close-sourced program in python.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":100,"Q_Id":68654599,"Users Score":1,"Answer":"Python is an interpreted language, which means that the interpreter needs the source code at runtime in order to work. This means that even if you were able to encrypt the source code, the interpreter would still need to decrypt the source code to work at all so there is no 100% safe option. There are a few tactics you may want to look into though:\n\nObfuscation, which works by making the source code less readable\nCompilation, which converts the source to machine code (Cython does this I think), which makes it harder to reverse-engineer\n\nCould you make a decryption interpreter for Python? Probably. Would the performance be terrible? Also likely. Is it much easier to do one of the two above? Definitely. Or just switch to a different language which supports compilation and instruction-level obfuscation (like C\/C++, Java, or C#).","Q_Score":1,"Tags":"python,python-3.x,security,encryption,cryptography","A_Id":68654720,"CreationDate":"2021-08-04T16:06:00.000","Title":"Creating a close sourced Python program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to solve a system of equations using genetic algorithm (using python 3.x). is there a way to perform multi-objective analysis using the PyGAD module or an approach that increases accuracy of the GA output?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":113,"Q_Id":68705659,"Users Score":0,"Answer":"PyGAD does not support multi-objective optimization at the current stage. Only single objective optimization is supported.","Q_Score":1,"Tags":"python-3.x,neural-network,genetic-algorithm,equation-solving","A_Id":68722314,"CreationDate":"2021-08-09T00:17:00.000","Title":"is there a way to perform multi-objective analysis with pygad module?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I seek for some best practices that may help to make Pythonic (and object-oriented) code from cffi code, or Python packages that can make\/generate Pythonic code from cffi code.\nFor example, I want to get some struct of one char* and two float* and two int* so I could edit struct's fields without needing to convert Python variable to good-for-cffi variable (like ffi.new(\"int*\", 42)) and I want that Pythonic struct to be easily passable through CFFI.\nIf there is any package, please share usage examples for struct case.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":62,"Q_Id":68728110,"Users Score":0,"Answer":"Are you sure you want to put pointers in your struct? That makes things complicated since you have to manage the lifetime of the objects those pointers reference. There is no \"nice\" way to do this in CFFI because there is no \"nice\" way to do this in C.","Q_Score":0,"Tags":"python,c,pypy,cffi","A_Id":68743164,"CreationDate":"2021-08-10T13:52:00.000","Title":"CFFI Python best (more pythonic) practices","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using raspberry pi 3 and i can communicate to a port via terminal using the following commands:\nto open port\n\nssty -F \/dev\/ttyUSB2 -echo\n\n\ncat \/dev\/ttyUSB2&\n\nTo send messages i use:\n\necho 'AT' > \/dev\/ttyUSB2\n\nThe response of the port is 'OK'\nI doing a python code to save the answers of the terminal in a variable, i tried to use the pySerial library but doesn't work, is there any another method that i can use?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":98,"Q_Id":68730388,"Users Score":0,"Answer":"Just use \"serial\" library. I use it and works good.","Q_Score":1,"Tags":"python,terminal,raspberry-pi3,raspbian","A_Id":68730480,"CreationDate":"2021-08-10T16:23:00.000","Title":"Python reading and writing to ttyUSB","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am just curious to know whether it is possible to export some final graphs or pictures after the successful animation of any object. I have used \"Mathematica\" and I know that a video can be exported as a sequence of images. If it is possible in Manim, then what is the proper way to do it?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":520,"Q_Id":68743394,"Users Score":0,"Answer":"One possible way is to use ffmpeg. Using FFmpeg you can convert the video file into images. After downloading FFmpeg, navigate to the path where FFmpeg exe is available and from the command prompt, you can try the below command.\nffmpeg -i input file path output file path\nEx: ffmpeg -i input file path C:\\images\\img%04d.png\nThe above command will convert each frame of the video to a png image in the path specified. \"img%04d\" is for the output file name format. In the output file path, you will be able to observe files like img0001, img0002. Each png file will represent a particular frame in the video.\nI had tried with an mp4 file and it works fine.","Q_Score":0,"Tags":"python,manim","A_Id":68743765,"CreationDate":"2021-08-11T13:51:00.000","Title":"Is it possible to export the pictures in png format from a Manim animation video?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"By default, MetaFlow retries failed steps multiple times before the pipeline errors out. However, this is undesired when I am CI testing my flows using pytest-- I just want the flows to fail fast. How do I temporarily disable retries (without hard-coding @retry(times=0) on all steps)?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":35,"Q_Id":68776921,"Users Score":1,"Answer":"You can disable it with by setting the METAFLOW_DECOSPECS environment variable: METAFLOW_DECOSPECS=retry:times=0.\nThis temporarily decorates all steps with @retry(times=0)-- unless they are already decorated, in which case this won't override the hard-coded retry settings.\nSource: @Ville in the MetaFlow Slack.","Q_Score":0,"Tags":"python,continuous-integration,pytest,netflix-metaflow","A_Id":68776922,"CreationDate":"2021-08-13T18:29:00.000","Title":"How to disable automatic retries of failed Metaflow tasks?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I created an discord.py bot. Soon after I created it. To make it look decent I want to add discord user profile banner.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":268,"Q_Id":68813816,"Users Score":2,"Answer":"Banners for bots aren't supported by Discord yet. It is only available to normal users with an active Nitro subscription.","Q_Score":0,"Tags":"python,discord.py","A_Id":68814502,"CreationDate":"2021-08-17T08:09:00.000","Title":"How to add Discord user profile banner in my discord.py bot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The module I'm using loads C library via ctypes.LoadLibrary in __init__ and calls a function which creates two processes using pthread_create C api. Thread IDs are not stored anywhere. These processes contain while(1) loops that read and write to serial port. I want to be able to kill the library threads, use said serial port for other purposes and then restore the module functionality with importlib.reload. Right now serial port remains inaccessible until I kill python top-most script with ctrl+c.","AnswerCount":2,"Available Count":2,"Score":-0.0996679946,"is_accepted":false,"ViewCount":97,"Q_Id":68821092,"Users Score":-1,"Answer":"Since you are not saving a reference to the thread. You can't kill it specifically. The easiest and most reliable way is to save the thread ID somewhere.\nSome comments talk about listing threads to kill them. Don't do that! You can't tell which thread are your own and killing someone else thread is not nice. Just save the ID, it's simple and robust.","Q_Score":0,"Tags":"python,c,multithreading","A_Id":68821359,"CreationDate":"2021-08-17T16:37:00.000","Title":"How to kill C pthreads created by python ctypes.LoadLibrary","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"The module I'm using loads C library via ctypes.LoadLibrary in __init__ and calls a function which creates two processes using pthread_create C api. Thread IDs are not stored anywhere. These processes contain while(1) loops that read and write to serial port. I want to be able to kill the library threads, use said serial port for other purposes and then restore the module functionality with importlib.reload. Right now serial port remains inaccessible until I kill python top-most script with ctrl+c.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":97,"Q_Id":68821092,"Users Score":1,"Answer":"You cannot kill a thread without its cooperation. It absolutely will not work. You have two choices:\n\nChange the code of the library or module so that it supports clean shutdown and the threads terminate themselves. This will require changing the while(1) loops so they have some way to exit.\n\nIsolate the library or module into its own process. You can safely reach in from the outside to terminate a process or write code to terminate the process from the inside without changing the library or module.\n\n\nFixing code that doesn't support clean shutdown so that it does support clean shutdown is the better option if it's practical. But sometimes it can be very difficult to add support for clean shutdown to complex code that doesn't have it. In an ideal world, every programmer would design support for clean shutdown into every library or module.","Q_Score":0,"Tags":"python,c,multithreading","A_Id":68822369,"CreationDate":"2021-08-17T16:37:00.000","Title":"How to kill C pthreads created by python ctypes.LoadLibrary","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How would I go about auto updating the requirements.txt file for when I install\/update a package?\nMy main idea would be when I push an update to git it would auto create the requirements.txt file (or something along those lines).\nI understand there are many 3rd party tools out there, but none of them seem to do this either: pipreqs, pipenv, poetry.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":486,"Q_Id":68822722,"Users Score":0,"Answer":"Poetry kind of does this. It has a pyproject.toml file where you declare dependencies. This can be edited manually or more often is updated when you do poetry add. Then there is a poetry.lock file that contains version information for all dependencies, both direct and transitive. This file is updated any time you run poetry install. If you regularly run poetry install to update your dependencies, then you can commit the changes to the lock file.\nDepending on the exact syntax you use for dependency versions in pyproject.toml, poetry install can update to the latest patch of a dependency. I think it will update to the latest minor version. But it will not automatically update to a new major version because these can introduce breaking changes that require some human attention.","Q_Score":2,"Tags":"python,pip,requirements.txt","A_Id":68822993,"CreationDate":"2021-08-17T19:00:00.000","Title":"How to auto update requirements.txt when a new\/updated package is installed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I best structure a program?\nI have some classes in different .py files doing REST API calls to a service using a Bearer auth key.\nSince I don't want to store the key in every class I would want to know how I should best approach this.\nWhere and how should I store the key? How should the classes using this key access it? What is industry best practice?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32,"Q_Id":68839387,"Users Score":0,"Answer":"One good approach would be to make a Base class which loads the api key (and potentionally any other env variables) from a .env file and stores it as a class member. Then all classes which need the api key access would just inherit from Base class.\nDon't forget to add .env file to .gitignore, so you don't share all the private information with other users.","Q_Score":0,"Tags":"python,api,structure","A_Id":68839568,"CreationDate":"2021-08-18T21:13:00.000","Title":"Program structure private key and requets","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I heard about python only but when I see different names on search result than I confused what the hell is this but I taught may be it is used in the part of code conversion but not sure about it what actually these are ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":197,"Q_Id":68841390,"Users Score":1,"Answer":"Python is a language. CPython, IronPython, Jython are different implementations of this langauge. They also all happen to be implemented in different languages themselves: CPython is written in C, IronPython in .NET, and Jython in Java. Thus, it is very easy to integrate IronPython into a .NET program, and it is really easy to embed Jython into a Java program. But for the most part, when people execute Python, they are running their Python code through CPython (even if they don't know that's what it's officially called). It is the original Python implementation, it is the fastest of them, as well as being the implementation that defines what Python is. Unless you want to use Python within .NET or Java frameworks, you might never encounter the other two.","Q_Score":0,"Tags":"python-3.x,jython,cpython","A_Id":68841506,"CreationDate":"2021-08-19T02:42:00.000","Title":"What is the use of Cpython , IronPython , Jython ? Is it used in the process of code conversion from Python to Machine code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I've looked around and although there are a bunch of similarly phrased questions but I haven't found one that addresses my question. I don't really want to trawl through Stack Overflow, so here's to hoping this isn't a duplicate.\nSo I coded a Discord Embed that requires pinging to work. The text is displaying as a discord ping should look with the light blue background and such, but there is no ping and users simply get a new message notification instead of a ping. This is the case for role mentions as well as user mentions. For user mentions I used author.mention and for role mentions I used the ID. Does anyone know how I can change this \"setting?\"\nOne possible workaround that I have thought up is that I could ping the needed parties and then instantly delete the ping right before sending the embed, but for my peace of mind I would prefer if the ping was the one which is displayed in the embed.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1739,"Q_Id":68885347,"Users Score":0,"Answer":"So as i know you can`t do a \"Ping\" in a Embed at least not what you call a ping. To ping People you have to do a ping in a normal message. You could do this before the embed and delete it or you could not delete it.","Q_Score":0,"Tags":"python,discord.py,embed","A_Id":68910098,"CreationDate":"2021-08-22T21:35:00.000","Title":"How to ping people\/roles inside a Discord Embed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to access a python project structure residing on a remote server. I've connected to the remote server using Putty and I am able to see all the files. However, I would like to open the entire set of files as a project in an IDE.\nWhen I try \"python file.py\", the file starts running rather than opening.\nI'd appreciate a way to either open the files individually in notepad\/jupyter or a suggestion for what IDE to use and how to open all the files in that folder.","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":168,"Q_Id":68917733,"Users Score":2,"Answer":"WinSCP integrates with Putty, has its own editor, and allows you to browse folder structures. Vscode also has an SSH extension you can try.\nOtherwise, look into Vscode Server or running JupyterLab on the remote server and editing your code via your local browser if you want a more full IDE experience","Q_Score":0,"Tags":"python","A_Id":68917959,"CreationDate":"2021-08-25T06:16:00.000","Title":"How to open a .py file from a remote server (Putty) in notepad\/jupyter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to access a python project structure residing on a remote server. I've connected to the remote server using Putty and I am able to see all the files. However, I would like to open the entire set of files as a project in an IDE.\nWhen I try \"python file.py\", the file starts running rather than opening.\nI'd appreciate a way to either open the files individually in notepad\/jupyter or a suggestion for what IDE to use and how to open all the files in that folder.","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":168,"Q_Id":68917733,"Users Score":1,"Answer":"Putty will never let you open an IDE, you can run nano file.py, you can see the file, edit and save. you can copy the code to your local in an IDE and then paste it back there. you can use your remote IP and port and transfer files using SCP on the PowerShell","Q_Score":0,"Tags":"python","A_Id":68917823,"CreationDate":"2021-08-25T06:16:00.000","Title":"How to open a .py file from a remote server (Putty) in notepad\/jupyter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to access a python project structure residing on a remote server. I've connected to the remote server using Putty and I am able to see all the files. However, I would like to open the entire set of files as a project in an IDE.\nWhen I try \"python file.py\", the file starts running rather than opening.\nI'd appreciate a way to either open the files individually in notepad\/jupyter or a suggestion for what IDE to use and how to open all the files in that folder.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":168,"Q_Id":68917733,"Users Score":0,"Answer":"Running GUI software on remote server, that's what you want.\nYou need to figure out a way to redirect XServer\nOne way is to use\n\"ssh -X\"\nthe option -X will do some work for you.","Q_Score":0,"Tags":"python","A_Id":68917922,"CreationDate":"2021-08-25T06:16:00.000","Title":"How to open a .py file from a remote server (Putty) in notepad\/jupyter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For more clarifying information, I am using a Ubuntu 20.04. I am receiving the following error when trying to read a text file from a different directory: FileNotFoundError: [Errno 2] No such file or directory\nSay that the python code \"code.py\" that I am trying to run resides in Folder1. The text file \"test.txt\" that I am trying to read off of is in Folder2, where the relative pathing from \"code.py\" is \"..\/Folder2\/test.txt\". However, when I am using: from pathlib import Path and\nPATH = Path(\"..\\Folder2\\test.txt\"), I receive the error. Is there a better way to go about this? Thank you in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":417,"Q_Id":68933390,"Users Score":0,"Answer":"You should use os.path.join(), as it was built to work cross-platform(Linux\/Mac\/Windows).","Q_Score":0,"Tags":"python,ubuntu,path","A_Id":68933781,"CreationDate":"2021-08-26T06:16:00.000","Title":"Receiving FileNotFoundError: [Errno 2] No such file or directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using locust to run load test. Specifically I am trying to use docker-compose and following the documentation at https:\/\/docs.locust.io\/en\/stable\/running-locust-docker.html\nI want to retrive test stats in CSV format per the directions in https:\/\/docs.locust.io\/en\/stable\/retrieving-stats.html\nNow when running this setup headless how can I get aggregated results in CSV format from all workers? The non headless version allows me to download the aggregated, results as a CSV, but am not sure of the headless version would work here.\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":294,"Q_Id":68943425,"Users Score":1,"Answer":"You should only have to worry about running --headless --csv=example (as noted from the docs page you linked to) and such on the master. The workers don't need those as headless only applies to the master and they don't aggregate their own results. The CSVs generated by the master should contain all the results from all the workers. If you've tried this and you're not seeing all the data you're wanting, you may want to try adding --csv-full-history.\nFrom the docs page:\n\nThe files will be named example_stats.csv, example_failures.csv and example_history.csv (when using --csv=example). The first two files will contain the stats and failures for the whole test run, with a row for every stats entry (URL endpoint) and an aggregated row. The example_history.csv will get new rows with the current (10 seconds sliding window) stats appended during the whole test run. By default only the Aggregate row is appended regularly to the history stats, but if Locust is started with the --csv-full-history flag, a row for each stats entry (and the Aggregate) is appended every time the stats are written (once every 2 seconds by default).","Q_Score":0,"Tags":"python,docker,locust","A_Id":68943924,"CreationDate":"2021-08-26T18:04:00.000","Title":"locust how to use docker-compose and get aggregated results","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm designing a UML class diagram for a Mastermind game and I'm having trouble figuring out how to make the attribute 'Name' unique and not changeable. I'm assuming that I do this by naming the 'Name' attribute private and show it in the class diagram as well. Any sort of help would be highly appreciated. Thanks","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":101,"Q_Id":68947662,"Users Score":1,"Answer":"As per Python you can only indicate private attributes by adding an underscore in front of the name. Language-wise this is not a language construct but a convention. UML does not care since it's language-agnostic. Model it as private (by showing the - in front of the name). If you are generating code from that UML model the code generator might create the underscore automatically.\nIn any case, if you create a model with UML and indicate something to be private then the coder for the language must take care. For a closed implementation you just need to train your coders. For an open (library) implementation Python will let you stand in the rain with that.","Q_Score":1,"Tags":"python,oop,attributes,uml","A_Id":68949550,"CreationDate":"2021-08-27T03:21:00.000","Title":"Username must be unique and can't be changed in Mastermind","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My understanding about interpreted languages like Python is that, it converts (or, compiles, depending on the exact definition of the terms) the source code to low-level and platform-independent bytecode. When bytecode needs to be executed on a specific machine, it will be again converted to target machine-specific machine code by a Python VM so that my Python code (already in bytecode format) could be successfully understood by the CPU of a target machine.\nIn this procedure, source code and bytecode are platform-independent and the final machine code is platform-dependent.\nMy question is, what if I save the resultant machine code generated by Python VM and re-use it on the same machine? Does it mean that I already get Python source code compiled just like C\/C++? My understanding is, on the machine code level, the concept of \"high-level programming languages\" disappears and source code which generates such machine code becomes irrelevant--machine code is just machine code, CPU does not care and cannot find out which language such machine code comes from. Does it mean that, somehow, PythonVM-generated machine code can be as fast as C\/C++ generated machine code?\n(I understand that such machine code will NOT be cross-platform anyway--but this is not the concern of this question. Since I can always compile my source code targeting different platforms just like C\/C++.)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":93,"Q_Id":68962375,"Users Score":0,"Answer":"No. Python bytecode is not the same as a machine code. Obviously you could build a hardware that uses Python bytecode as machine code.\nBut instead of creating a real hardware machine, Python devs created a sort of Python Virtual Machine that runs the Python code as its machine code (Im saying sort of, because it's mainly interpreted instead of compiled like JVM languages and the VM is not really a VM but an interpreter, you should study a bit more about the difference between VM and interpreted:-)). You can imagine the VM as a program that \"emulates real hardware\" for the purposes of running the code.\nThis way, you don't need to care about the underlying hardware, but you have to ship a Python interpreter environment together with your code to form an executable.\nI think that the misconception that there is a direct conversion to machine code is the culprit. In a way, yes, Python is translated to machine code, but sort of indirectly by executing the Python environment on the machine and then the Python environment in the process of executing your code happens to transforms your Python code to machine code in order to run it.","Q_Score":0,"Tags":"python,compilation,machine-code","A_Id":68962987,"CreationDate":"2021-08-28T07:48:00.000","Title":"Will interpreted languages like Python be as fast as compiled languages like C++ if I keep the machine code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been learning about HashMaps and their best practices. One of the things that I stumbled upon was collision resolution.\nThe methods include:\n\nDirect Chaining,\nLinear Probing,\nQuadratic Probing,\nDouble Hashing.\n\nSo far I've found that direct chaining was much easier to implement and made the most sense. I'm not sure which I should focus on in terms of being prepared for technical interviews.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":86,"Q_Id":68969650,"Users Score":1,"Answer":"For technical interviews, I'd suggest getting a high level understanding of the pros\/cons of these approaches - specifically:\n\ndirect chaining degrades slowly as load factor increases, whereas closed hashing\/open addressing approaches (all the others you list) grow exponentially worse as load factor approaches 1.0 as it gets harder and harder to find an empty bucket\nlinear probing can be CPU cache friendly with small keys (compared to any of the other techniques): if you can get several keys onto the same cache line, that means the CPU is likely to spend less time groping around in memory after collisions (and SIMD instructions can sometimes help compare against multiple buckets' keys concurrently)\nlinear probing and identity hashing can produce lower-than-cryptographic-hashing collision rates for keys that happened to have a nice distribution across the buckets, such as ids that tend to increment but may have a gap here and there\nlinear probing is much more prone to clusters of collisions than quadratic probing, especially with poor hash functions \/ difficult-to-hash-well keys and higher load factors (e.g. ballpark >= 0.8), as collisions in one part of the table (even if just by chance more than flawed hashing) tend to exacerbate future use of that part of the table\nquadratic probing can have a couple bucket offsets that might fall on the same cache line, so you might get a useful probability of the second and even third bucket being on the same cache line as the first, but after a few failures you'll jump off by larger increments, decreasing clustering problems at the expense of more cache misses\ndouble hashing is a bit of a compromise; if the second hash happens to produce a 1 then it's equivalent to linear probing, but you might try every 2nd bucket, or every 3rd etc. - up to some limit. There's still plenty of room for clustering (e.g. if h2(k) returned 6 for one key, and 3 for another key that had hashed to a bucket 3 further into the table than the first key, then they'll visit many of the same buckets during their searches.\n\nI wouldn't recommend focusing on any of them in two much depth, or ignoring any, because the contrasts reinforce your understanding of any of the others.","Q_Score":0,"Tags":"python,data-structures,hashmap,hashtable","A_Id":69095440,"CreationDate":"2021-08-29T03:38:00.000","Title":"Hash Map, when to use which method?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Vue, Django integrated project. I hosted the Vue project on Netlify and the Django project on Heroku. A python script (integrated into Heroku) is called on certain buttons which extract data and posts this to the Django API to be viewed on the frontend.\nI have trained a font type for my pytesseract OCR script. However, when i run it on Heroku, it seems like i can only use the 'eng' (normal font) as 'language' for my pytesseract image_to_string function. If I have the .traineddata file of the font type that I want to use, how can I use this file within the pytesseract functions? I can call the individual file, but I need the right TESSDATA_PREFIX as well. Does someone know how to deal with this?\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":69014331,"Users Score":0,"Answer":"I had the same issue. It is olved by setting TESSDATA_PREFIX Config Var to a custom directory and inserting all .traineddata files to that directory.","Q_Score":0,"Tags":"django,heroku,fonts,tesseract,python-tesseract","A_Id":71949469,"CreationDate":"2021-09-01T13:05:00.000","Title":"Pytesseract - using .traineddata file on hosted server (Heroku)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I need to do some text mining of trending topics from El Salvador, but this country does not have a WOEID active code.\nAny other alternatives?\nThanks in advance for your support.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":19,"Q_Id":69017380,"Users Score":0,"Answer":"try using API.trends_closest(lat, long). I'm not sure this will work.","Q_Score":0,"Tags":"python,twitter","A_Id":69040591,"CreationDate":"2021-09-01T16:16:00.000","Title":"Twitter trending topics for a country without WOEID","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Although my issue is related to building Python, it could be considered generic. I have built Python with a custom TclTk installation, using --with-tcltk-includes and --with-tcltk-libs. Say I passed \/foo\/bar\/spam path to the latter. The problem is, when I use strace to check where the binary looks for its shared libraries, I see \/foo\/bar\/spam in the search path, although I do not want that because this application will be shipped and this path does not exist anywhere else beyond my own machine. So I want to use it just during the build, but not as a search path for the generated binary. Any ideas?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":16,"Q_Id":69034352,"Users Score":0,"Answer":"Static linking is probably your best bet, because you likely can't guarantee that your customers will have any of the other required libraries (like sqlite3, for example) either. Just don't pass the flag --enable-shared to .\/configure and it will build a statically-linked lib by default.\nUnfortunately, I don't see a way with the standard options to build a partial-static\/partial dynamic lib. That doesn't mean it isn't possible with some creative tinkering with the Makefile, but conceptually I'm not sure how it would work anyway.","Q_Score":0,"Tags":"python,python-3.x,build,configuration","A_Id":69034556,"CreationDate":"2021-09-02T16:52:00.000","Title":"How to fine-tune where a binary looks for its shared libraries during configure\/build (linux)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've been wondering if there is any way to send a request to the site to determine if the site has 'index of' mode enabled; by that, I mean the site has all of the directories indexed (or part of visible directories).\nIs there any way I could do it using HTTP requests in Python?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":21,"Q_Id":69041845,"Users Score":0,"Answer":"No.\nThe closest you could come would be to make requests to URLs on the site that ended in \/ and then run some heuristics to see if the format of the HTML document that came back matched the automatically generated index pages of various common web servers.","Q_Score":0,"Tags":"html,python-requests","A_Id":69041892,"CreationDate":"2021-09-03T08:33:00.000","Title":"How to know if site has index of mode enabled in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm sorry that this has already been asked, but I have not found anything helpful.\nI am trying to create a discord bot and am following YouTube videos.\nWhen I try to run my code, I keep getting the error:\nModuleNotFoundError: No module named 'discord'\ndespite having installed discord and discord.py.\nI checked where it has been asked before and some people have said that using older Python versions makes it work, but newer ones don't. Why not? How can I use an older Python version without ruining the latest one?\nThank you in advance.","AnswerCount":2,"Available Count":2,"Score":-0.0996679946,"is_accepted":false,"ViewCount":106,"Q_Id":69058866,"Users Score":-1,"Answer":"Did you tried pip install discord and pip install discord.py?","Q_Score":0,"Tags":"python,discord","A_Id":69062399,"CreationDate":"2021-09-04T20:49:00.000","Title":"ModuleNotFoundError: No module named 'discord' \/ how to switch python versions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm sorry that this has already been asked, but I have not found anything helpful.\nI am trying to create a discord bot and am following YouTube videos.\nWhen I try to run my code, I keep getting the error:\nModuleNotFoundError: No module named 'discord'\ndespite having installed discord and discord.py.\nI checked where it has been asked before and some people have said that using older Python versions makes it work, but newer ones don't. Why not? How can I use an older Python version without ruining the latest one?\nThank you in advance.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":106,"Q_Id":69058866,"Users Score":0,"Answer":"this happened to me and none of my modules worked.\nuninstall python and then reinstall it; so that it is updated.","Q_Score":0,"Tags":"python,discord","A_Id":69062447,"CreationDate":"2021-09-04T20:49:00.000","Title":"ModuleNotFoundError: No module named 'discord' \/ how to switch python versions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a bot in discordpy. I have a discord server for only people in school. Everyone has a school email, and I want to make a bot that can send a code to verify them.\nWhere I am stuck is that when the bot askes for an email, it wont let me DM the bot back. In discord I'm being told that my message can't be delivered, because we don't share any mutual servers, etc. There are no errors in the python log. Also, when a new person joins, they are banned right away so they can't read or write anything. All of the verification is happening in DM's. The person is only unbanned after they've been verified.\nI have tried googling everywhere, but I just cannot find an answer. If there is one that already exists, could you please point me to it?\nIs there a solution to this? Or should I try something else, like blocking the user from reading all channels except one?\nThank you so much for your help! It really means a lot to me. ;D","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":210,"Q_Id":69144082,"Users Score":0,"Answer":"It's simply something that you aren't allow to do in Discord. It doesn't depend on the Discord API.\n\nOr should I block the user to see al the channels except one?\n\nthis can be the best alternative.","Q_Score":0,"Tags":"python,discord,discord.py","A_Id":69144104,"CreationDate":"2021-09-11T14:54:00.000","Title":"Message isn't delivered when I try to DM my bot in discord","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a bot in discordpy. I have a discord server for only people in school. Everyone has a school email, and I want to make a bot that can send a code to verify them.\nWhere I am stuck is that when the bot askes for an email, it wont let me DM the bot back. In discord I'm being told that my message can't be delivered, because we don't share any mutual servers, etc. There are no errors in the python log. Also, when a new person joins, they are banned right away so they can't read or write anything. All of the verification is happening in DM's. The person is only unbanned after they've been verified.\nI have tried googling everywhere, but I just cannot find an answer. If there is one that already exists, could you please point me to it?\nIs there a solution to this? Or should I try something else, like blocking the user from reading all channels except one?\nThank you so much for your help! It really means a lot to me. ;D","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":210,"Q_Id":69144082,"Users Score":0,"Answer":"What I did for my school server is to have all the channels be locked, then send a verification DM. They can't see the students and they don't have permission to make a new invite, so the user has to complete the verification. After that, send the replies to a mod-only channel for approval.\nIf they have their DMs closed then... That's on them.","Q_Score":0,"Tags":"python,discord,discord.py","A_Id":69147964,"CreationDate":"2021-09-11T14:54:00.000","Title":"Message isn't delivered when I try to DM my bot in discord","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was wondering whether running two scripts on a dual-core CPU (in parallel at the same time) decreases the speed of the codes as compared to running them serially (running at different times or on two different CPUs). What factors should be considered into account while trying to answer this question?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":88,"Q_Id":69145314,"Users Score":0,"Answer":"How Dual Cores Works When Running Scripts\nrunning two separate scripts\nif you run one script then another script on a dual core CPU, then\nweather or not your scripts will run on each of the cores is dependent on\nyour Operating System.\nrunning two separate threads\non a dual core CPU then your threads will actually be faster than on a single core.","Q_Score":0,"Tags":"python,performance","A_Id":69145408,"CreationDate":"2021-09-11T17:34:00.000","Title":"Does running two scripts in parallel on a dual-core CPU decrease the speed as compared to running them serially?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to have an AWS Lex chatbot send a follow-up response to a user if the user has not replied after a certain amount of time?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":58,"Q_Id":69214293,"Users Score":0,"Answer":"Lex responds to direct inputs. Lex, by itself, will not prompt the user to engage if the user does not respond within a specified timeframe.\nThat is custom logic that you would need to implement outside of Lex.","Q_Score":0,"Tags":"python-3.x,aws-lambda,amazon-lex","A_Id":69222864,"CreationDate":"2021-09-16T19:43:00.000","Title":"AWS Lex Chatbot - Send user a follow up message if no response detected","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I had made more than 1 pytest test files I needed it to be convert them to a single exe file\n\nI used pyinstaller for that not able to convert the test cases to .exe file\n\nEven though if some how I will convert it I could not run it via clicking on .exe file as on console I am running it by python -m pytest\n\n\nSo Please help me guys","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":200,"Q_Id":69255920,"Users Score":0,"Answer":"Is there any way to execute the exe file created by pyinstaller, that like on just clicking the exe file the exe will get execute based on the code mentioned just like on clicking the exe file the code should execute via python -m pytest","Q_Score":1,"Tags":"python,pytest,pyinstaller","A_Id":69263646,"CreationDate":"2021-09-20T14:12:00.000","Title":"Execute pytest via pyinstaller created exe extension file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"so I have a python program that invokes singularity exec on a .sif file via os.system. Then on the next line of my program, I use os.system again to attempt to run a python script. I assumed that this would start up the singularity, and then run my script from it, however currently it just runs the exec command, brings me into the container, and then hangs (it does not execute the python command).\nDoes anybody have any advice or experience with this issue?\nThank you.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":94,"Q_Id":69258322,"Users Score":0,"Answer":"Singularity exec runs a single, specified command, it does not change the execution environment to that of the singularity image.\nIf you need an interactive session, use: singularity shell my_image.sif\nIf you need to run multiple commands, write a shell script and use that: singularity exec my_image.sif my_script.sh\nAlternatively, use singularity to run your python script. Then everything will be done in the context of the image rather than the host machine.","Q_Score":0,"Tags":"python,os.system,singularity-container","A_Id":69268989,"CreationDate":"2021-09-20T17:03:00.000","Title":"executing os.system python commands after invoking a singularity exec command via os.system","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using the latest version telethon 1.23. when i connected everything is good. But as soon as I start to download contact avatars (using download_profile_photo ) after the third or fifth count, the account number goes to the ban by telegram. The user has been deleted\/deactivated (caused by GetDialogsRequest).\nPlease help!!!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":273,"Q_Id":69264742,"Users Score":0,"Answer":"I'm not the only one with this error.\nAfter the release of update 1.24 everything worked.","Q_Score":1,"Tags":"python,telethon","A_Id":70820581,"CreationDate":"2021-09-21T07:08:00.000","Title":"The user has been deleted\/deactivated (caused by GetDialogsRequest)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've entered login information during tests but I no longer want this data to be present in the source code which will be uploaded to GitHub soon. How can I make use of this data in the tests without storing the login info in the source code? Is it safe to store it in an environment variable? A database? A local file? What's the best way to go about encrypting and decrypting this info?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":169,"Q_Id":69278105,"Users Score":1,"Answer":"If your project working fine , you can use\/add spy method in to code and validate\/add unit test for the login file. (spyse used to get actual response from methods to test files, its inbuild feature in unit tests).\nIf you use secret for login, anybody can add console and check your credentials, I'm not sure that's good idea if you upload to github.","Q_Score":2,"Tags":"python,unit-testing,security,privacy","A_Id":69278190,"CreationDate":"2021-09-22T04:13:00.000","Title":"How to use sensitive data in unit tests?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have my source code hosted on gitlab repository, and I intend to run a python script if it detects any new push or commit in that gitlab repository. How can I catch this event ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":395,"Q_Id":69303474,"Users Score":2,"Answer":"You can use Jenkins or AWS CodeStar to check for commits and then invoke your function inside Jenkins or AWS code build, or if you have a serverless function you can invoke it there. Setting a complete pipeline you will need some knowledge of CI\/CD and DevOps. This is a pretty standard way of doing it.\nA more get-around of doing this would be to use Gitlab API to check for commits every few minutes and invoke your code.","Q_Score":2,"Tags":"python,gitlab","A_Id":69303676,"CreationDate":"2021-09-23T16:09:00.000","Title":"How can I execute a python script as soon as there is a new commit on my gitlab repository?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to build a custom firmware based on the micropython for the ESP8266 board in an automated environment like CI.\nThe microphone firmware that is built from the tutorials does show how to load the REPL loop and use the ampy.py script to copy the custom micropython code to the device over the serial port.\nIs there a way to add custom scripts to the micropython firmware so that the \".bin\" file can be generated from the GitHub CI?\nOne option we looked at is dumping the flash with custom scripts but it involves manual intervention whenever the code changes.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":179,"Q_Id":69310581,"Users Score":0,"Answer":"You can place python scripts in the micropython\/ports\/esp8266\/modules\/ folder and during the build they will be compiled and included as frozen python modules in the firmware.bin.","Q_Score":0,"Tags":"esp8266,micropython","A_Id":69323926,"CreationDate":"2021-09-24T06:38:00.000","Title":"Custom Micropython firmware for ESP8266","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to add all this information that goes\/prints on the terminal to a separate file. Since my VPS goes down quite often and I would like to monitor any and all errors. This is for a discord bot by the way. So I have specific error handlers for certain commands.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":62,"Q_Id":69311076,"Users Score":0,"Answer":"If you execute the script of your bot followed by > file.txt, anything shown on the stdout (the output of print()) will be written in file.txt\nYou can learn more on that by googling cmd redirect output to file :)","Q_Score":0,"Tags":"python,terminal,discord.py","A_Id":69319769,"CreationDate":"2021-09-24T07:23:00.000","Title":"How can I get all information that gets printed to the terminal including errors","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"As some StackOverflow answers show, you can get the exact gzip decompressed file size using decompressedSize = gzipFile.seek(0, io.SEEK_END). Some people also suggest for files smaller than 4 GiB to do .seek(-4, 1). However, because it's seeking through the file till the end, it's very time consuming for bigger files (for approximately 1 GiB of decompressed data, it took few seconds to seek to the end).\nI then tried using gunzip -l somefile.gz (same file) and it manage to instantly output the current file size as well as the file size when decompressed.\nHow am I able to get the file size of decompressed gzip as fast as gunzip if not even faster?\n(P.S. The reason for me trying to get the decompressed gzip size is for a CLI progress bar when decompressing)","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":381,"Q_Id":69351289,"Users Score":5,"Answer":"gzip -l is in fact seeking to and reading the last four bytes of the file. Your comment \"because it's seeking through the file till the end, it's very time consuming for bigger files\" suggests that you don't understand what seeking is. Seeking is not reading the entire file until you get to the end. Seeking is moving the read pointer of the file to the desired point, and reading from there. It takes O(1) time, not O(n) time (where n is the size of the file). @crissal's answer shows how to do this correctly.\nThose last four bytes are the uncompressed length of the last gzip member, modulo 232, assuming that there is no junk at the end of the gzip file.\nYou will notice three caveats in that sentence. First, as you have already noted, the uncompressed size needs to be less than 232 bytes for that number to be meaningful. However, you can't necessarily tell by looking at the compressed file if that's true or not. gzip can compress to more than a factor of 1024, so the gzip file could be, say, only 222 bytes in length, 4 MB, but decompress to over 4 GB.\nThe second caveat is that the gzip file must have only one member. The gzip format permits concatenated gzip members, for which the last four bytes represent the length of only that last member. There is no reliable way to find the other members, other than decoding the entire gzip file.\nThe third caveat is that the gzip file not have any junk on the end. In general I haven't seen that in the wild, but it is possible for there to be padding at the end of the gzip file, which would again confound finding the length.\nBottom line: if it is important to you to reliably determine the compressed size, then you can use the last four bytes only if you are in control of the generation of the gzip files, and you can assure that the content is < 4 GB, there is only one member, and there is no junk at the end.\nFor your application, you do not need to know the length of the uncompressed data. You should instead base your progress bar on the fraction of compressed data processed so far. You know the compressed size of the file from the file system, and you know how much compressed data you have consumed so far. If the data is approximately homogeneous, the compression ratio will be approximately constant throughout the decompression. For a constant compression ratio, a compressed-data progress bar will show exactly the same thing as an uncompressed-data progress bar.","Q_Score":3,"Tags":"python,performance,compression,gzip,gunzip","A_Id":69353889,"CreationDate":"2021-09-27T17:59:00.000","Title":"Get gzip decompressed file size as fast as gunzip (no seek)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need my win.flip() call as much close to being real-time as possible. Meanwhile, while waiting for the trigger to occur, which flips the buffer, I also want some keyboard keypresses to be listened for. So, which one is faster:\n\nassigning event.globalKeys.add() and relying on pyglet's thread to poll it\nor manually checking for len(event.getKeys()) in my trigger callback?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":40,"Q_Id":69354415,"Users Score":1,"Answer":"You should be using the new Keyboard class which can plug into either the ioHub event polling system or the Psychtoolbox engine for event polling. Both of those poll the keyboard on a separate process independent of the rendering loop and timestamp the keypresses at source. Calls to event.getKeys() use pyglet and then polling occurs only once per screen refresh, at least during dynamic updating.\nWe would typically recommend, however, that you simply create studies in the Builder which will automatically use the current best practice and methods so you don't have to keep abreast of what the latest recommendations are.","Q_Score":0,"Tags":"python,real-time,polling,psychopy,low-latency","A_Id":69375109,"CreationDate":"2021-09-28T00:12:00.000","Title":"How do I minimize latency caused by event polling in Psychopy?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does anyone know how can I forward an album (which contains multiple medias in it) with telegram api since forwardMessage only gets a message_id, I know this is possible because my friend uses some package in python and he can do that but I couldn't find anything on official telegram docs","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":152,"Q_Id":69362193,"Users Score":0,"Answer":"There is currently not method in the bot API which let's you do this easily. You'll have to catch all the messages in the media group and resend the media as album via sendMediaGroup.","Q_Score":0,"Tags":"telegram,python-telegram-bot,php-telegram-bot,py-telegram-bot-api","A_Id":69363278,"CreationDate":"2021-09-28T12:57:00.000","Title":"Telegram api: how to forward an album","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I have a Flask API running through a Systemd service running on a piece of hardware that's battery powered (to control other hardware). I have a bunch of state that I need to save and in case something goes wrong, like a power outage, I need to be able to restore that state.\nRight now I save the state as JSON files so I can load them (if they exist) on startup. But I'd also need to be able to remove them again in case it gets the shutdown signal.\nI saw somewhere I could set KillSignal to SIGINT and handle the shutdown as a keyboard interrupt. Or something about ExecStop. Would that be enough, or is there a better way to handle such a scenario?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":69372881,"Users Score":0,"Answer":"If you look at the shutdown logs of a linux system you'll see 'sending sigterm to all processes... sending sigkill to all processes'. In a normal shutdown processes get a few second's grace before being killed. So if you trap sigterm you can run your shutdown code, but it had better be over before the untrappable sigkill comes along. Since sigterm is always sent to kill a running process, trapping it is indeed the Right Way (TM) to cleanup on exit. But since you are using systemd services you could also cleanup in the service.","Q_Score":0,"Tags":"python,systemd,shutdown","A_Id":69372997,"CreationDate":"2021-09-29T08:24:00.000","Title":"Python handling system shutdown, but not crash (Or how I would like to restore state in case of something unexpected)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have search about this issue and couldn't find anything that would help me.\nEDITED\nThe main idea is to, each time the lambda function is triggered by cloudwatch (everyday), choose a subsequent line from the text file that I get from a s3 bucket, that line will be attached to an e-mail.\nThe next time the lambda is triggered, the same will happen, but with the next line in the text file, and so on.\nI have more or less an idea, using a for loop, my problem is how to, each time the function is triggered, select the next line in the text file.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":74,"Q_Id":69398725,"Users Score":1,"Answer":"If you need to read lines from your file in sequence, one lambda execution a day is one line, then you have to keep track of those lines. If its only once a day, you could use SSM Parameter Store for that. Each time your lambda executes, it would query SSM Parameter Store the the line number which was read previously.\nSimilarly, after successful dispatch of a line, the Lambda function would update the parameter in SSM Parameter Store.\nThe exact details depend on how big the file is, as this process can get progressively slow with time.","Q_Score":1,"Tags":"python-3.x,amazon-web-services,amazon-s3,aws-lambda","A_Id":69399665,"CreationDate":"2021-09-30T20:54:00.000","Title":"Send line from file each time Lambda function is triggered [python]","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a lambda function where, after computation is finished, some calls are made to store metadata on S3 and DynamoDB.\nThe S3 upload step is the biggest bottleneck in the function, so I'm wondering if there is a way to \"fire-and-forget\" these calls so I don't have do wait for them before the function returns.\nCurrently I'm running all the upload calls in parallel using asyncio, but the boto3\/S3 put_object call is still a big bottle neck.\nI tried using asyncio.create_task to run coroutines without waiting for them to finish, but as expected, I get a bunch of Task was destroyed but it is pending! errors and the uploads don't actually go through.\nIf there was a way to do this, we could save a lot on billing since as I said S3 is the biggest bottleneck. Is this possible or do I have to deal with the S3 upload times?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":115,"Q_Id":69399774,"Users Score":1,"Answer":"If there was a way to do this,\n\nSadly there is not, unless you are going to use other lambda function to do the upload for you. This way your main function would delegate time consuming file processing and upload to a second function in an asynchronous way. Your main function can then return immediately to the caller, and the second function does that heavy work in the background.\nEither way, you will have to pay for the first or second function's execution time.","Q_Score":1,"Tags":"python,amazon-s3,aws-lambda,boto3,python-asyncio","A_Id":69399858,"CreationDate":"2021-09-30T23:27:00.000","Title":"Fire-and-forget upload to S3 from a Lambda function","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"What is the best way to save random user tool settings in a nuke script file? I searched around online a fair bit and found nothing regarding this topic which I found hard to believe.\nAt the end of the day my goal is to save some random tool data on in the file and additionally save some other data specifically on a few nodes in the graph. I was unable to find info on either.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":96,"Q_Id":69408647,"Users Score":0,"Answer":"Save it on the root! Create a custom knob of any type, set it to \"hidden\" and store it on the Root of the script:\nnuke.Root()\nThe Root is just a fancy knob, so most any command that works on a node can also work on the Root.","Q_Score":0,"Tags":"python,nuke","A_Id":69417968,"CreationDate":"2021-10-01T15:45:00.000","Title":"Nuke Python save tool settings in nuke script file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"heroku git:remote -a mymailapp-live\n\u00bb Warning: heroku update available from 7.53.0 to 7.59.0.\nError: Command failed: git remote\nfatal: not a git repository (or any of the parent directories): .git\nit is showing me above error.\nplease help me.\ni am hosting this using heroku-cli.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":174,"Q_Id":69414030,"Users Score":0,"Answer":"Type **\n~$ git init\n** and then run your command it should work and make sure you have git installed on your device","Q_Score":0,"Tags":"python,django,heroku-cli","A_Id":69637731,"CreationDate":"2021-10-02T04:43:00.000","Title":"heroku git:remote -a command is not working","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm looking for a method to estimate of a server member's original join date.\nThe problem with just getting member.joined_at is that if a member leaves and rejoins, it resets this date. So the best alternative seems to be getting the date of the oldest message sent by a member.\nHowever, member.history(limit=1, oldest_first=True) seems to just return the oldest message in the member's DM.\nIs there any way in the api to find a member's oldest message in a server? This seems to be something only available to users via the search bar.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":126,"Q_Id":69469041,"Users Score":2,"Answer":"Unfortunately discord is channel-based - which mean, you have to search for messages in a certain channel such as DMChannel or a TextChannel.\nIn this case you will need to loop over all visible TextChannel in your server and do a search since the beginning of the channel, which is resourcefully costly.\nDiscord API does not allow you to search via its search functionalities so that will be your only way. I believe bigger bot simply has a database that store the first time it sees someone joins the server to avoid this problem altogether.","Q_Score":0,"Tags":"python,discord.py","A_Id":69469084,"CreationDate":"2021-10-06T16:04:00.000","Title":"discord.py find first message of a member in a guild","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a java developer and just now started working in Python. I have written one AWS lambda code in python 3.9. In first attempt I have written the complete code in one or two files. But somewhere I have read that we should not create fat files. Then I try to segregate the code into different folders and files. Folders like handlers, services , utils , dao, entity. Each folder has one file and each file has number of functions which can be called independently from another file through import. Then one of the Python expert told me to apply OOPS concept and also to follow either DDD design or MVC pattern.\nIs it necessary to follow OOPS concept and create classes in serverless architecture?\nCan you point me to some sample GIT repo showcasing the framework for developing an object oriented lambda?\nAWS lambda gets activated on request and dies down when request is served. It is not like server which is active 24hours without request.\nWhat is best design pattern or architecture or coding paradigm to follow in AWS lambda code for python language which also supports modular programming?","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":394,"Q_Id":69471022,"Users Score":3,"Answer":"It depends a lot on your use case.\nLambda's are stateless. There is little point in building Classes for most situations in Lambdas because you cannot pass that class instantiation out of the lambda. (meaning you'd have to re-instantiate it again in a different lambda called in succession) In addition, because of the limitations on time and memory in Lambdas, its best if they have small scope - they do one or two things then update the database or call another lambda or continue in a Step Function. The most likely class you might create would be a Struct type -which there isn't really one in python. A dictionary in python performs much the same functionality as a struct and with far less overhead.\nClean Code and TDD ideologies would indicate that it be best to have lots of little functions that you call in succession in your Lambda handler. That lets you get better testing patterns and behaviro testing done without having to mock a bunch of stuff when testing bits of components.\nIt also helps because, while you can run your lambda handler as any other function on your local, you will not have easy access to the mocked context if you are trying to use some of that in the lambda, and running on your local does not mean that the lambda will successfully run once deployed. so a test is nice, but not definite. But if you can verify the behavior of all your smaller functions you have far less to troubleshoot at the lambda level in the cloud.\nas for any other architectural pattern... whatever makes you comfortable. You can very much make lambdas the Controllers in an MVC. You can then organize your file structure around that. Or you can have a collection of lambdas for a domain in DDD and organize around that. Honestly, there is no best way to do it in general, there is only the most effective and efficient for your project way.\nOne thing to note as you go into multiple lambdas however is how they are deployed through various systems like CDK or Cloudformation. In which case, it is FAR better to have every lambda in its own directory only referencing it self internally (You'll have to have fun with Python Imports to get this to work in your local tho)","Q_Score":0,"Tags":"python,amazon-web-services,design-patterns,aws-lambda","A_Id":69474011,"CreationDate":"2021-10-06T18:36:00.000","Title":"Which design pattern to follow while writing AWS lambda code in Python 3.9","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am a java developer and just now started working in Python. I have written one AWS lambda code in python 3.9. In first attempt I have written the complete code in one or two files. But somewhere I have read that we should not create fat files. Then I try to segregate the code into different folders and files. Folders like handlers, services , utils , dao, entity. Each folder has one file and each file has number of functions which can be called independently from another file through import. Then one of the Python expert told me to apply OOPS concept and also to follow either DDD design or MVC pattern.\nIs it necessary to follow OOPS concept and create classes in serverless architecture?\nCan you point me to some sample GIT repo showcasing the framework for developing an object oriented lambda?\nAWS lambda gets activated on request and dies down when request is served. It is not like server which is active 24hours without request.\nWhat is best design pattern or architecture or coding paradigm to follow in AWS lambda code for python language which also supports modular programming?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":394,"Q_Id":69471022,"Users Score":0,"Answer":"Try writing helper functions into utils.py file so that your lambda_function.py file is not big. You can also write async funtions to reduce timeout error as each lambda has its own execution time out. Service Pattern will sit the best for these kind of services.You can invoke async function by invoking a lambda inside one lambda.","Q_Score":0,"Tags":"python,amazon-web-services,design-patterns,aws-lambda","A_Id":69471410,"CreationDate":"2021-10-06T18:36:00.000","Title":"Which design pattern to follow while writing AWS lambda code in Python 3.9","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am running psynet, and the experiments seems to work fine, however no audio is played. For example, hearing test is stopped working for me: no sound is played. Tried two different computers. Did anyone experience such an issue?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":26,"Q_Id":69480953,"Users Score":1,"Answer":"Run dallinger generate-constraints in the (correct) experiment directory; this will solve the problem.","Q_Score":1,"Tags":"python","A_Id":69480971,"CreationDate":"2021-10-07T12:13:00.000","Title":"In psynet4 audio stop working for certain experiments","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Unfortunately I can't use shell=True or cwd=whatever\/.., I don't want a subshell.\nNeither providing the full path of the command or setting the PATH environment variable makes any difference. Calling shutil.which() on the command returns the expected path. I've tried providing the command as a string and as a list.\nBut, as mentioned, what is really killing me is that the identical code works perfectly on a slightly newer R-Pi with an identical directory structure.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":49,"Q_Id":69520936,"Users Score":0,"Answer":"(Moved solution on behalf of the question author to move it to the answer section).\nThe second R-Pi had no \/usr\/bin\/bash, only \/bin\/bash ..\nShell files being called by Popen had #!\/usr\/bin\/bash headers, so 'file not found' was the correct error, but it was interpreter not found, rather than script not found, as I'd assumed!","Q_Score":0,"Tags":"python-3.x,raspberry-pi,subprocess","A_Id":69605705,"CreationDate":"2021-10-11T04:11:00.000","Title":"python3.7 subprocess.Popen throws \"[Errno 2] No such file or directory\" on one R-Pi but not the other, both running buster","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"My question is: I would like to know if there is a way to enable a debug on telethon library as initially I thought it was Telegram related but now it seems more like arch (os\/python..?) related:\nFacts:\n-armv6 (raspberyy pi1, busterOS, python3): telethon client authenticates (with .start()) and disconnects after 3-5 minutes(!). Need to resend request\/receive auth sms and it stays connected for another 3-5 minutes after which asks again for phone number\n-armv7(raspberry pi4, busterOS, python3): telethon client authenticates (with .start()) and STAYS authenticated, as it should\nPython version(Python 3.7.3), telethon package (Telethon1.23.0) are STRICTLY the same, only the architecture is a generation different between the two devices.\n(What worth noticing (probably) is that when using armv6 (and having another session opened also on a phone), when the disauthenthication happens on armv6 the phone app gets logged out of telegram also, like a \"disconnect ALL sessions\" request is taking place all of a sudden)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":72,"Q_Id":69538477,"Users Score":0,"Answer":"I found why I had the disauthentication. The difference between the two devices was not the arch generation but the kernel NAME, not the version.\nThe device that triggered the disauthentication had a kernel name like 4.16.30CUSTOM while the \"good\" device had it like 4.16.30-v7lCUSTOM.\nI recompiled the \"broken\" device's kernel using a custom name like 4.16.30-vxCUSTOM (using a dash -) and now everything is working.\nLater edit: the default_system_version is split from the Kernel name (aka system.release) in telegrambaseclient.py file:\ndefault_system_version = re.sub(r'-.+','',system.release)","Q_Score":0,"Tags":"python,telethon","A_Id":69692138,"CreationDate":"2021-10-12T09:54:00.000","Title":"Telethon gets disauthenticated on armv6 (but not armv7)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wanted to try Python's Geemap module, I installed it via conda install geemap -c conda-forge. But when importing it in my pyhton code I have this error message :The 'pyasn1-modules>=0.2.1' distribution was not found and is required by google-auth. So I updated pyasn1-modules, and now I have version 0.2.8 but the errors remains.\nIf someone has a idea...","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":703,"Q_Id":69542123,"Users Score":0,"Answer":"Conda was the problem for me. Tried creating a new environment and installing everything with pip and that got rid of the error.","Q_Score":1,"Tags":"python,conda,geemap","A_Id":70388627,"CreationDate":"2021-10-12T14:13:00.000","Title":"The 'pyasn1-modules>=0.2.1' distribution was not found and is required by google-auth","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"After I added my bot written discord-interactions and discord.py to the server, the available slash-commands stopped showing, although they were previously available on the same server. Also commands are available in direct messages. In server permissions are allowed to use Slash-commands. How can I fix this problem?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3175,"Q_Id":69554579,"Users Score":0,"Answer":"Slash commands, if not explicitly registered to a group of servers will take roughly an hour to register globally. I suggest waiting and coming back if it still doesn't work.","Q_Score":0,"Tags":"python,discord.py","A_Id":69555775,"CreationDate":"2021-10-13T11:20:00.000","Title":"Slash-commands are not available on the discord server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I opened command prompt (I'm on Windows) and I typed:\n'''none\npip3 install discord\n'''\nThen it said it installed discord, and I was ready to go! (I already had Python 3.9.7 installed)\nThen when I opened VSCode up and typed: import discord I got this error message:\n\n\"discord\" is not accessedPylance\nImport \"discord\" could not be resolvedPylancereportMissingImports\n\nWhat does this mean, and how can I fix it? I was really looking forward to coding the bot, but don't know how, now that this is messed up.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":87,"Q_Id":69558197,"Users Score":0,"Answer":"Open an integrated Terminal in VS Code,\n\nrun python --version, it should be python3.9.7 which is selected as python interpreter and shown in status bar.\n\nrun pip show discord to check if its location is \\..\\python3.9.3\\lib\\site-packages. If not, reinstall it.","Q_Score":0,"Tags":"python,visual-studio-code,discord","A_Id":69566450,"CreationDate":"2021-10-13T15:25:00.000","Title":"I tried to add Python to VSCode, but it won't work","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I opened command prompt (I'm on Windows) and I typed:\n'''none\npip3 install discord\n'''\nThen it said it installed discord, and I was ready to go! (I already had Python 3.9.7 installed)\nThen when I opened VSCode up and typed: import discord I got this error message:\n\n\"discord\" is not accessedPylance\nImport \"discord\" could not be resolvedPylancereportMissingImports\n\nWhat does this mean, and how can I fix it? I was really looking forward to coding the bot, but don't know how, now that this is messed up.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":87,"Q_Id":69558197,"Users Score":0,"Answer":"check in the bottom left corner of the VS Code window for which version of Python is it using. This issue usually occurs for me when I\u2019m working in a virtual environment but VS Code is pointing to my global Python installation.","Q_Score":0,"Tags":"python,visual-studio-code,discord","A_Id":69558268,"CreationDate":"2021-10-13T15:25:00.000","Title":"I tried to add Python to VSCode, but it won't work","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I opened command prompt (I'm on Windows) and I typed:\n'''none\npip3 install discord\n'''\nThen it said it installed discord, and I was ready to go! (I already had Python 3.9.7 installed)\nThen when I opened VSCode up and typed: import discord I got this error message:\n\n\"discord\" is not accessedPylance\nImport \"discord\" could not be resolvedPylancereportMissingImports\n\nWhat does this mean, and how can I fix it? I was really looking forward to coding the bot, but don't know how, now that this is messed up.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":87,"Q_Id":69558197,"Users Score":0,"Answer":"You can change the Python Interpreter in VSCODE to solve this issue.\n\n\nOpen settings in VSCODE by pressing Ctrl + Shift + P. Make sure your .py file is open while doing this step.\n\n\nSearch there Python: Select Interpreter and choose the right version.\n\nReload VSCODE and see if it works!","Q_Score":0,"Tags":"python,visual-studio-code,discord","A_Id":69559150,"CreationDate":"2021-10-13T15:25:00.000","Title":"I tried to add Python to VSCode, but it won't work","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What I wish to understand is what is good\/bad practice, and why, when it comes to imports. What I want to understand is the agreed upon view by the community on the matter, if there's any one such in some PEP document or similar.\nWhat I see normally is people have a python environment, use conda\/pip to install packages and all that's needed to do in the code is to use \"import X\" (and variants). In my current understanding this is the right way to do things.\nWhenever python interacts with C++ at my firm, though, it always ends up with the need to use sys.path and absolute imports (but we have some standardized paths to use as \"base\" and usually define relative paths based on those).\nThere are 2 major cases:\n\nPython wrapper for C++ library (pybind\/ctype\/etc) - in this case the user python code must use sys.path to specify where the C++ library to import is.\nA project that establish communications between python and C++ (say C++ server, python clients, TCP connections and flatbuffer serialization between the two) - Here the python code lives together with the C++ code, and if it some python files end up using sys.path to import python modules from the same project but that live in a different directory - Essentially we deploy the python together with the C++ through our C++ deployment procedure.\n\nI am not fully sure if we can do something better for case #1, but case #2 seems quite unnecessary, and basically forced just by the choice to not deploy the python code through a python package manager. Choice ends up forcing us to use sys.path on both the library and user code.\nThis seems very bad to me as basically this way of doing things doesn't allow us to fully manage our python environments (since we have some libraries that we import even thought they are not technically installed in the environment), and that is probably why I have a negative view of using sys.path for imports. But I need to find if I'm right, and if so I need some official (or almost) documents to support my case if I'm to propose fixes to our procedures.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":69567639,"Users Score":0,"Answer":"For your scenario 2, my understanding is you have some C++ and accompanying python in one place, and a separate python project wants to import that python.\nCould you structure the imported python as a package and install it to your environment with pip install path\/to\/package? If it's a package that you'll continue to edit, you can add the -e flag to pip install so that when the package changes your imports get the latest code.","Q_Score":0,"Tags":"python,import","A_Id":69567996,"CreationDate":"2021-10-14T08:42:00.000","Title":"Python sys.path vs import","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm looking for help with terminology to explain that a unit test failed because the test script itself has errors. The statement \"this unit test failed because...\" usually implies that the test script is correct and it's the function under test that is incorrect. I'm looking for the other way around.\nContext: I'm grading a bunch of assignments in Python 3.x where students had to define some classes and subclasses while also providing the unit testing in Pytest. I would like to give succinct but correct feedback.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":81,"Q_Id":69598892,"Users Score":0,"Answer":"Working as an SDET I often need to distinguish between bad\/broken tests and bad product code. We normally do this by talking about what needs to be fixed for the test to pass (while still being a useful and valid test).\nRegardless of the source of the failure you're still talking about a failure in code. In both cases (if you've taken the time to identify and isolate the cause) you can say \"Caused by bug on line n of file.py\", or \"bug within function f of file.py\". It is then implied by the file we're talking about whether we're dealing with a failure caused by bad product code or bad test code.\nYou can reinforce this implication by supplying an explanation for why that code is the source of the problem. Some contrived examples would look like:\n\nTest n failed because of a bug on line 5 of test.py. assert False will always fail, and doesn't meaningfully test anything in class.py.\n\n\nTest n failed because of a bug on line 20 of class.py. sub(a, b) should return a - b instead of a + b","Q_Score":0,"Tags":"python,unit-testing,pytest,terminology","A_Id":69619324,"CreationDate":"2021-10-16T19:23:00.000","Title":"What is the proper way to say that a unit test failed but only because the test script is broken?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have tens of thousands of geofences on the AWS Redshift table A.\nAnd also logging of tens of thousands of AIS signals every 1 hour on table B.\nHowever, I want to check and log that which AIS is incoming or outgoing for whole geofences.\nHow can I achieve that?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":53,"Q_Id":69611705,"Users Score":0,"Answer":"From your description of the problem, I would guess that a geofence needs to be transformed into a polygon using ST_Polygon(). Once you have your polygons (table A), you will need to take the AIS signals and transform them into geolocation points (table B) using ST_Point().\nWhen you have all your data transformed into compatible geolocation format - you will use the ST_Contains().\nI will add that geolocation data might take sometime in Redshift and you will most likely have to do a cartesian product of all your polygons vs all your geolocation points.\nI hope I understood your problem properly.","Q_Score":0,"Tags":"python,amazon-redshift,ais,geofence","A_Id":69612977,"CreationDate":"2021-10-18T06:37:00.000","Title":"How to check an AIS signal is outgoing from a geofence with spatial database?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"i have problem with import telebot in pyTelegramAPI.\nMy error is this:\nTraceback (most recent call last):\nFile \"\/home\/yaser\/Desktop\/pyhton codes\/Insta-tel-bot\/insta\/telegram.py\", line 2, in \nimport telebot\nModuleNotFoundError: No module named 'telebot'\nI have python 3.9.7 and Pip 21.\n\nI don't install telebot.\ncan you help me please.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":223,"Q_Id":69680189,"Users Score":0,"Answer":"What platform do you use for pyhton?\nIf you use pyhcharm you can install modules in packages side.","Q_Score":0,"Tags":"python","A_Id":71482639,"CreationDate":"2021-10-22T16:22:00.000","Title":"Can't import telebot from pyTelegramAPI","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently developing a Telegram bot using python\/Pytelegrambotapi.\nIn my local machine, if the bot is started and left for sometime without any request, It terminates and throws the error\nrequests.exceptions.ReadTimeout: HTTPSConnectionPool(host='api.telegram.org', port=443): Read timed out. (read timeout=25)\nCan someone help me handling this error.\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":248,"Q_Id":69688314,"Users Score":0,"Answer":"Sometime network or Telegram issues happen.\nHandle exceptions or use bot.infinity_polling() instead of bot.polling()\nedit: Try this function with these parameters (you can adjust later as you'd like)\n\nbot.infinity_polling(timeout=10, long_polling_timeout = 5)","Q_Score":0,"Tags":"python,bots,telegram,telegram-bot,py-telegram-bot-api","A_Id":69688351,"CreationDate":"2021-10-23T12:48:00.000","Title":"Pytelegrambotapi Throws ReadTimeout error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a script on my RasPi that on startup is in charge of moving and erasing a bunch of old files.\nThe script, named \"erasePi.py\" is called from rc.local\nI have had some issues in the past few days with this script, lacking required permissions to erase and copy files.\nAt the end, I've found I was calling erasePi.py from rc.local with the following line:\nsudo python \/home\/...\/erasePi.py\nand I changed with:\npython \/home\/...\/erasePi.py\nsince all the scripts run from rc.local have root permissions.\nEverything working now, but I would like to ask if this solution is a coincidence of various factors or simply, with that sudo I was triggering an abnormal behavior of Raspbian?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":101,"Q_Id":69694670,"Users Score":0,"Answer":"It seems to be that the sudo command was the issue.\nAs you mentioned in your comment, rc.local file has root permissions. So it is not necessary to include sudo command.\nI hope this comment helps you\nKind regards","Q_Score":0,"Tags":"python,file,raspberry-pi,sudo","A_Id":69729199,"CreationDate":"2021-10-24T07:26:00.000","Title":"Delete files on a Raspberry Pi with Python script - permission error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have import psycopg2 in my code yet I keep getting ImportError: No module named psycopg2when I try to run it. I've tried\n\n\u2514\u2500$ pip3 install psycopg2 \n\u2514\u2500$ pip install psycopg2-binary \n\u2514\u2500$ sudo apt-get install build-dep python-psycopg2\n\nanyone have a solution to this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":54,"Q_Id":69730808,"Users Score":0,"Answer":"The issue here is: Which Python version do you want to have psycopg2? I am posting 2 solutions, since I'm not sure which one is helpful in your case:\n\nIf you want to install it for Python 2, python -m pip install psycopg2 should do this.\n\nIf you want to install the package for Python 3, you can run python3 -m pip or pip3. This should avoid confusions with Python 2 installations.","Q_Score":0,"Tags":"python,pip,psycopg2","A_Id":69739649,"CreationDate":"2021-10-26T22:50:00.000","Title":"Issues with psycopg2","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In short, I have written a Python program to write a series of commands to a serial device I'm working with, and I want to make sure they're working in the way I want them to.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":49,"Q_Id":69731125,"Users Score":1,"Answer":"For sure, no device connected means no response\/nothing to read...\nDid you consider trying a serial port sniffer, if you google for serial port sniffer, you'll find more than you need.\nConnect any serial device and sniff what you send.","Q_Score":0,"Tags":"python,serial-port,pyserial,monitor","A_Id":69731252,"CreationDate":"2021-10-26T23:46:00.000","Title":"Is there a way to view what is being written on serial from a Python script without connecting a device?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am proficient in Bash and a beginner in Python (I have some experience with Flask and Requests).\nI wrote a Bash script which asks for some input (four strings) and creates a configuration file based on that input. That's good for me, but I would like to convert it to a (no frills) web interface. I know how to configure Apache, if necessary.\nI know there are zillions of ways to do that. I'd like some hints on how to tackle my problem, ideally using Bash or Python. By the way, I've used Octave on CGI for some of this in the past, and I think it's excellent for math purposes, but I'd like to get ideas about some simpler, more generic avenues.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":81,"Q_Id":69761417,"Users Score":1,"Answer":"I would create a Django site for this. It can be setup really quickly. I would recommend you host it on PythonAnywhere. They have a free tier, and works really well. Django is similar to Flask, but I personally like Django. If you could be more specific on what your App needs to do, some sample code could be provided.","Q_Score":0,"Tags":"python,html,bash,apache,cgi","A_Id":69761598,"CreationDate":"2021-10-28T21:57:00.000","Title":"Create a web page which asks for some input and writes it to a file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created a script that runs when I press a combination of keys, it means that I call my \"script.py\" from my \"keyboard customize shortcuts\".\nIt does not work properly because when I run my script from the terminal, I have to type my sudo password.\nJust to be more clear, if I run my script without sudo, it shows this: ImportError: You must be root to use this library on linux.\nSo, it must be like this sudo python3 script.py, then it ask for my password (which I rather to not).","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":111,"Q_Id":69786566,"Users Score":0,"Answer":"I fixed it.\nI created a file inside \"\/etc\/sudoers.d\" named \"script\" without extension.\nInside the script file I put \"myuser ALL=(ALL) NOPASSWD: \/home\/user\/Documents\/Scripts\/script.py\".\nThen I gave the right permissions with \"chmod +x \/home\/user\/Documents\/Scripts\/script.py\"\nFinally I put \"sudo \/home\/user\/Documents\/Scripts\/script.py\" on my custom shortcut.\nThanks!","Q_Score":1,"Tags":"python-3.x,linux-mint","A_Id":69849675,"CreationDate":"2021-10-31T11:46:00.000","Title":"How to run script on Linux without password?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I created a script that runs when I press a combination of keys, it means that I call my \"script.py\" from my \"keyboard customize shortcuts\".\nIt does not work properly because when I run my script from the terminal, I have to type my sudo password.\nJust to be more clear, if I run my script without sudo, it shows this: ImportError: You must be root to use this library on linux.\nSo, it must be like this sudo python3 script.py, then it ask for my password (which I rather to not).","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":111,"Q_Id":69786566,"Users Score":0,"Answer":"There could be a few things to blame for this:\n\nYou are logged in as root by default (not recommended) and so when you installed the library with pip3 install theLibrary, you installed it on the sudo account. Trying running sudo pip3 install theLibrary, or just create a new user account.\nYou are running this in IDLE, and you did not provide it with root privileges. You could fix this by running sudo idle first.\nThe quick fix: You could log in as sudo before running anything and stay as sudo for the duration of your session (so you wouldn't have to type your password every time) by running sudo -i and then typing your password once when prompted.","Q_Score":1,"Tags":"python-3.x,linux-mint","A_Id":69786894,"CreationDate":"2021-10-31T11:46:00.000","Title":"How to run script on Linux without password?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"im trying to retrieve the date and time of a message, and the date is correct, but the time is about 6 hours off. how can i fix this?\nit is 5pm currently, but this line of code returns 23:00\n\nmsgDate = update.message.date\n\nedit: it is returning the minutes properly, so its close, just not sure on what to do about the hours.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":176,"Q_Id":69818062,"Users Score":1,"Answer":"It seems as though function built into python-telegram-bot uses the UTC timezone, so yes, it does return the proper date and time, just converted into UTC","Q_Score":0,"Tags":"python,telegram,python-telegram-bot","A_Id":69820400,"CreationDate":"2021-11-02T23:32:00.000","Title":"Python-telegram-bot api 'update.message.date' is returning the wrong time. how do i fix this?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm doing PID gain tuning for a DC motor\nI gathered real data from the motor which involve the position according to time.\nAnd i want to calculate the rise time, overshoot, and settling time from the data.\nIs there any function in matlab or python which can do this?\nThank you!!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":111,"Q_Id":69871085,"Users Score":0,"Answer":"In the cases that you use the step command to extract the step-response characteristics of the system, the stepinfo command calculates the rise time, overshoot, and settling time, and so on. I don't know whether it is applicable in the data case or not but you can test it?","Q_Score":0,"Tags":"python,matlab,controls","A_Id":69880340,"CreationDate":"2021-11-07T09:11:00.000","Title":"Is there any function that calculates the rise time, overshoot, and settling time?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some c source files. Inside, there is multiple comments with '\/\/' style and others with '\/* *\/' style.\nI want to change all of them to \/* *\/ to have more uniformity inside my code and also to respect the standard column width.\nHow can I change all this comments automatically ?\nThank you for reading !\n\nEdit: I just realize that I didn't explain something important. I need to change my comments to make them compatible with C89. The rest of the coding style is already compatible. Just I don't want to delete all comment or to edit all of them manually. And I think it is also an interesting question.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":108,"Q_Id":69886172,"Users Score":1,"Answer":"Typically, that would be the job of a code formatter, and you'd need to at least be able to lex C, which is not really something you want to implement in a shell script or awk program.\nInstead, for example, clang-format has plenty options to adjust how your comments look, and should be pretty much available on any desktop OS.\nNote that using \/\/ for one-line comments is actually fine, imho, and you don't gain anything by using the \/* *\/ syntax for such.","Q_Score":0,"Tags":"python,c,bash,awk,formatting","A_Id":69886233,"CreationDate":"2021-11-08T15:41:00.000","Title":"How can I change all \/\/ comments into \/* *\/ comments in C language?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hi is there a way to run a python script located\/saved in certein gdrive folder?\nI need this cause i want use python running on container but be able to modify py script whenever i need.\nIs it possibile? Or is there a batter way?\nRegard","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":22,"Q_Id":69889306,"Users Score":0,"Answer":"solved downloading from github when container start.","Q_Score":0,"Tags":"python,gdrive","A_Id":69945224,"CreationDate":"2021-11-08T20:04:00.000","Title":"Run python script saved on gdrive","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"When I run pipenv run pytest on my Windows machine, I get the following message:\n\nWarning: Your Pipfile requires python_version 3.7, but you are using unknown\n(C:\\Users\\d.\\v\\S\\python.exe).\n\n\n$ pipenv --rm and rebuilding the\nvirtual environment may resolve the issue.\n$ pipenv check will surely fail\n\nI have tried running pipenv --rm, pipenv install & re-running the tests but I get the same error message.\nUnder Programs and Features, I have Python 3.7.0 (64-bit) & Python Launcher so I'm not sure where it is getting the unkown version from.\nCan someone please point me in the right direction?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":631,"Q_Id":69943147,"Users Score":0,"Answer":"I had a similar issue, the following fixed my issue.\n\nUpdating pip using the 'c:\\users...\\python.exe -m pip install --upgrade pip' command\nadding PYTHONPATH (pointing to the directory with the pipfil) to enviroment variables\nremoving the current virtualenv (pipenv --rm)\nand reinstalling (pipenv install)","Q_Score":1,"Tags":"python,pytest","A_Id":70285571,"CreationDate":"2021-11-12T12:43:00.000","Title":"Receiving Your Pipfile requires python_version 3.7, but you are using unknown, when running pytest even though I have Python 3.7.0 installed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I try to read two one billion record files from a Unix server for file comparison.\nI tried in python with paramiko package but it is very slow to connect and read the Unix files. That's why I chose Java.\nIn Java when I read the file I am facing memory issues and performance issues.\nMy requirement: first read all records from Unix server file1, then read second file records from Unix server and finally compare the two files.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":49,"Q_Id":69946752,"Users Score":0,"Answer":"As you are working in UNIX, I would advise you to sort the files and use the diff commandline tool: UNIX' commandline commands are quite powerful. Please show us an excerpt of the files (maybe you might need cut or awk scripts too).","Q_Score":0,"Tags":"python,java,unix","A_Id":69970573,"CreationDate":"2021-11-12T17:20:00.000","Title":"How to handle two one billion record for file comparison","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I try to read two one billion record files from a Unix server for file comparison.\nI tried in python with paramiko package but it is very slow to connect and read the Unix files. That's why I chose Java.\nIn Java when I read the file I am facing memory issues and performance issues.\nMy requirement: first read all records from Unix server file1, then read second file records from Unix server and finally compare the two files.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":49,"Q_Id":69946752,"Users Score":0,"Answer":"Sounds you want to process huge files. Rule of thumb is they will exceed your RAM so never hope to get them read all at once.\nInstead try to read meaningful chunks, process them, then forget them.\nMeaningful chunks could be characters, words, lines, expressions, objects.","Q_Score":0,"Tags":"python,java,unix","A_Id":69947114,"CreationDate":"2021-11-12T17:20:00.000","Title":"How to handle two one billion record for file comparison","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a player class and a weapon class. The weapon class has a reload method that checks the inventory property of the player. The player class has a weapon property that would hold the current weapon object, from which the reload method would be called. Since the player can change weapons, I would like to instantiate the player object without a weapon object, but have access to weapon object intellisense in development. Is this possible?\nIn short, I'd like to be able to see the methods of my weapon class from within my player class, without an instance being created.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":52,"Q_Id":69968180,"Users Score":2,"Answer":"Why not use a dummy weapon object that the player holds when they're not holding a weapon? It can be an invisible weapon and lets you access whatever you want in this context.\nIf it'll mess with the unarmed state, you can make the player use unarmed attack animations if that's needed.","Q_Score":1,"Tags":"python,class,oop,methods,properties","A_Id":69968218,"CreationDate":"2021-11-15T00:01:00.000","Title":"Can you set the property of a Python class equal to an empty class object?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to make a transaction with PyTezos. But in order of calculate the fees, I have to use the method fill() or autofill(). But those functions take a lot of time to process, so I suppose they are doing call to the tezos node, but why is it ?\nShouln't those function just have to calculate the size of the request and estimate the gas needed ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32,"Q_Id":69977430,"Users Score":0,"Answer":"In order to build a transaction you have to made several node requests. Part of them can be cached, although you still have to make them at least once.\nHere are these requests:\n\nChain ID\nCurrent protocol hash\nProtocol constants\nBranch (hash of some block in the past, used to adjust TTL)\nCounter\n\nBut the most time consuming part is fee estimation which requires dry-run simulation (another RPC call).","Q_Score":1,"Tags":"python","A_Id":72351855,"CreationDate":"2021-11-15T16:09:00.000","Title":"Pytezos function fill is very slow","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an idea to make a twitter bot that block annoying accounts:\nmy question is can I block accounts on behalf of other user?\nI am using tweepy\nI already have tokens for my account","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":50,"Q_Id":69987869,"Users Score":1,"Answer":"Yes, if you have access tokens for the other user. You can get these by using the sign-in with Twitter API, and have the other user go through that process to authorize your app.","Q_Score":0,"Tags":"python,twitter,bots,tweepy","A_Id":69991606,"CreationDate":"2021-11-16T10:56:00.000","Title":"how to block twitter accounts on behalf of others with tweepy?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any API or attributes that can be used or compared to determine if all messages in one topic partition are consumed? We are working on a test that will use another consumer in the same consumer group to check if the topic partition still has any message or not. One of our app services is also using Kafka to process internal events. So is there any way to sync the progress of message consumption?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":320,"Q_Id":70039321,"Users Score":0,"Answer":"Yes you can use the admin API.\nFrom the admin API you can get the topic offsets for each partition, and a given consumer group offsets. If all messages read, the subtraction of the later from the first will evaluate to 0 for all partitions.","Q_Score":0,"Tags":"apache-kafka,kafka-consumer-api,confluent-kafka-python","A_Id":70087085,"CreationDate":"2021-11-19T18:24:00.000","Title":"Kafka consumer: how to check if all the messages in the topic partition are completely consumed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to open discord and join a voice channel with a voice command. All I find is about bots, while I'm trying to do it with the user, me, in this case. Opening discord is not a problem, but I have no idea of how to do the voice channel thing, I'm still a begginer.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":56,"Q_Id":70043346,"Users Score":1,"Answer":"First of all, discord does not allow you execute client side commands directly or more specifically, pull users to voice channels. Making an user force-join a voice channel via a command would be a serious security exploit.\nWhat you can do to make users join channels, is to let them join a waiting room of some sort, than pulling them to channels from there.\nNow as far as i understand, you want to join a specific channel via a voice command yourself. In that case i would suggest not using discord API. I would implement a web scraper (in this case something like a web scraper would suffice since discord is basically running its website as an app, Press Ctrl+Shift+I and you will understand what i mean) to target a text containing the voice channel name i want to join. I would get that name from voice recognition. Then get that text position on screen and click it. You could use pyautogui for that purpose.\nTo be fair, this is not a beginner project at all, however with sufficient research and work you can make it.\nCheers","Q_Score":0,"Tags":"python,discord","A_Id":70046782,"CreationDate":"2021-11-20T04:57:00.000","Title":"Open Discord and make user join a specific voice channel","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to get the location geotag from an already posted Instagram post using the Basic Display Instagram API?\nI can't find any endpoints that let me get the location. Am I missing something or is that something we just cannot do?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":233,"Q_Id":70049191,"Users Score":0,"Answer":"This can be done by opening the post, right-clicking on top of the post, tick mark Properties, and then Location. You will get a map with location coordinates in decimal degrees which you can use to pinpoint that spot on Google Maps or another mapping service. APIs calculate this too but APIs are for developers only so it is not accessible to an average Instagram user unless you're building an app related to it.","Q_Score":0,"Tags":"python,instagram-api","A_Id":70061412,"CreationDate":"2021-11-20T19:27:00.000","Title":"How to get the location geotag from an Instagram post using the API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm looking for a fitting API to send CAN signals via CANoe. I'm pretty familiar with python and found a usable API with the pywin32 package. A Requirement of my project is to guarantee real-time (in this case <20ms) communication. I'm not an expert when it comes to details like latency etc., but as far as I know, python isn't the fastest. Are there any other APIs that secure the real-time requirement or are my concerns unfounded using a python script works fine?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":76,"Q_Id":70112994,"Users Score":1,"Answer":"Real-Time is a very broad buzz word, the question is what is your acceptable response time on all events you want to react on.\nE.g. dSPACE has adapted Python to be somewhat real-time capable, so you can run it synchronous with your plant model even at 1ms rate, with very limited code in there.\nI am not sure whether there exists e.g. an integration, which allows to write measurement or ECU\/ simulation nodes, these are the ones which are theoretically real-time capable in CANoe, in Python or more precise IronPython in this case.\nHowever, this would then be a standard Python not optimized for that and thus probably have issues.\nLast, if you really need it fast, you would have to use a Vector hardware, which allows CANoe to offload its runtime\/ kernel to the interface processor.\nOnly the very high end stuff would allow you to install e.g. IronPython, despite they usually run some embedded Windows version.","Q_Score":0,"Tags":"python,api,real-time,canoe","A_Id":70190820,"CreationDate":"2021-11-25T14:40:00.000","Title":"CANoe API for realtime requirement","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a script on my local machine that I would like to run remotely. This script requires a lot of GPU power so I can\u2019t run it from my laptop or phone which I would like to do. If there\u2019s any way I could connect to my local machines powershell or command prompt please let me know.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":55,"Q_Id":70115922,"Users Score":0,"Answer":"Use ssh, exemple:\nssh user@192.254.2.145 python -","Q_Score":0,"Tags":"python,powershell,mobile,remote-access","A_Id":70115956,"CreationDate":"2021-11-25T18:38:00.000","Title":"How can I invoke a .py script remotely?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python script whose boto3 operations\/function calls must be restricted to a single IAM user which has extremely limited access. My understanding is that the execution of the script depends on the configured profile for AWS CLI. Would that sort of restriction have to done inside the script?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":40,"Q_Id":70120741,"Users Score":2,"Answer":"The script could be created as a AWS Lambda function. Only the single IAM user should then be given access to execute that function.\nAnother script can be written to invoke that Lambda (boto3.client(\"lambda\").invoke()). Anyone can execute that script, but anyone but the right user will get an AccessPermissions error.\nNote:\n\nThere are limitations on the execution time\/memory allocation for AWS lambdas, which might make this a bad solution for your current script. That really depends on what your script exactly does.","Q_Score":0,"Tags":"python,amazon-web-services,boto3","A_Id":70122608,"CreationDate":"2021-11-26T07:19:00.000","Title":"Running a python script on AWS which is executable by a single IAM user only","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a scenario in which I have a peptide frame having 9 AA. I want to generate all possible peptides by replacing a maximum of 3 AA on this frame ie by replacing only 1 or 2 or 3 AA.\nThe frame is CKASGFTFS and I want to see all the mutants by replacing a maximum of 3 AA from the pool of 20 AA.\nwe have a pool of 20 different AA (A,R,N,D,E,G,C,Q,H,I,L,K,M,F,P,S,T,W,Y,V).\nI am new to coding so Can someone help me out with how to code for this in Python or Biopython.\noutput is supposed to be a list of unique sequences like below:\nCKASGFTFT, CTTSGFTFS, CTASGKTFS, CTASAFTWS, CTRSGFTFS, CKASEFTFS ....so on so forth getting 1, 2, or 3 substitutions from the pool of AA without changing the existing frame.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":122,"Q_Id":70178355,"Users Score":1,"Answer":"Let's compute the total number of mutations that you are looking for.\nSay you want to replace a single AA. Firstly, there are 9 AAs in your frame, each of which can be changed into one of 19 other AA. That's 9 * 19 = 171\nIf you want to change two AA, there are 9c2 = 36 combinations of AA in your frame, and 19^2 permutations of two of the pool. That gives us 36 * 19^2 = 12996\nFinally, if you want to change three, there are 9c3 = 84 combinations and 19^3 permutations of three of the pool. That gives us 84 * 19^3 = 576156\nPut it all together and you get 171 + 12996 + 576156 = 589323 possible mutations. Hopefully, this helps illustrate the scale of the task you are trying to accomplish!","Q_Score":3,"Tags":"python,data-science,computer-science,bioinformatics,biopython","A_Id":70178766,"CreationDate":"2021-12-01T02:11:00.000","Title":"Generate the all possible unique peptides (permutants) in Python\/Biopython","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So, I'm currently trying to construct a c++ aplication that calls for a python script. The main idea is that the python script runs a loop and prints decisions based on user input. I want the cpp program to be able to wait and read(if there s an output from python). I tried to make them \"talk\" via a file but it turned out bad. Any ideas?\nPS: im calling the script using system(\"start powershell.exe C:\\\\python.exe C:\\\\help.py\");\nIf there is any better way please let me know! Thanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":70180960,"Users Score":0,"Answer":"You could write to a file from python and check every certain amount of time in the c++ program to check for any changes in the file.","Q_Score":0,"Tags":"python,c++,multithreading,operating-system,multiprocessing","A_Id":70180979,"CreationDate":"2021-12-01T08:19:00.000","Title":"Is there a way to continuously collect output from a Python script I'm running into a c++ program?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I haven't touched python in a long time and I forgot how much of a pain importing can be.\nSo I'm using pylance and pipenv as my shell. I have pytest installed in my local env, I can run pytest from the command line and test my code. However, I can't import it in the same file I'm running my tests from. Any idea what might be causing that problem?\nPython version 3.9\nI have my tests in a separate file right below root. I don't have a init.py file in tests. I've read that that can cause problems.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1919,"Q_Id":70230636,"Users Score":0,"Answer":"I tried h. deville fletcher's answer and it didn't seem to work for me, but I could have messed up in there too. However, in the process, I remembered that I hadn't changed my interpreter. Once I changed the interpreter to my pipenv shell that fixed my problem.","Q_Score":0,"Tags":"python,pytest,pylance","A_Id":70231617,"CreationDate":"2021-12-05T00:35:00.000","Title":"\"pytest\" is not accessed \/ Import \"pytest\" could not be resolved - Pylance","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have X micro-services each of them are them are publishing to the same pub\/sub topic. The messages they publish contain the micro-service ID.\nI am looking for a way to make sure that the pub\/sub has finished servicing all the messages of a certain micro-service.\nMy current solution is to count all the messages that were published from the micro-service, and then count the messages that were served in the pub\/sub topic (via cloud-function). There are some known issues with this approach, and I was wondering if there is a better way to know if the pub\/sub does not contain messages from the specific micro-service?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":371,"Q_Id":70243237,"Users Score":0,"Answer":"The solution I ended up with is as follows:\n\ncreate a set in redis, and add a new message id to it\nInclude this new message id in the message published to the pubsub\nthe cloud function that runs after the pubsub should remove the new message_id from the set\nby the end of the process, we check the set and if it is empty then the process is done.\n\nThis also handle the times when pub\/sub publish the same message more than once.","Q_Score":0,"Tags":"python,google-cloud-platform,google-cloud-functions,google-cloud-pubsub","A_Id":70285587,"CreationDate":"2021-12-06T09:22:00.000","Title":"How to know if the pub\/sub topic contains messages with specific content?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have X micro-services each of them are them are publishing to the same pub\/sub topic. The messages they publish contain the micro-service ID.\nI am looking for a way to make sure that the pub\/sub has finished servicing all the messages of a certain micro-service.\nMy current solution is to count all the messages that were published from the micro-service, and then count the messages that were served in the pub\/sub topic (via cloud-function). There are some known issues with this approach, and I was wondering if there is a better way to know if the pub\/sub does not contain messages from the specific micro-service?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":371,"Q_Id":70243237,"Users Score":2,"Answer":"There is no solution to know the content of a message than getting the message, opening it and reading it.\nA better solution could be to use a separate topic for each type of message, and is the subscription queue is empty, that means all the message have been processed. If you need to count them, you can use the logs to track your message processing in Cloud FUnctions.\nAn alternative is to use a single PubSub topic and to add the ID in attribute of the message. Then you can create PubSUb subscription with a filter on that attribute and to oversee the subscription as before.\nThe bad side of that solution is that it's not compliant with Cloud Functions PubSub integration. You need to create an HTTP functions and a PubSub push subscription to be able to leverage the filter feature.","Q_Score":0,"Tags":"python,google-cloud-platform,google-cloud-functions,google-cloud-pubsub","A_Id":70246385,"CreationDate":"2021-12-06T09:22:00.000","Title":"How to know if the pub\/sub topic contains messages with specific content?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"can someone help me in creating a alert and event service for a bacnet code written using python BAC0 library.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":70255358,"Users Score":0,"Answer":"Event and alert are not supported yet.\nPR are welcomed though !","Q_Score":0,"Tags":"python-3.x","A_Id":70608681,"CreationDate":"2021-12-07T05:31:00.000","Title":"How to create alert and event service using BAC0 in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a project to be converted from C++ to Python. The project was originally written by others. The logic is described as below:\n\"It loaded 20 plain text files in which each line represents a record of 7 columns. It then parses each line and loaded all data into objects of C++ vectors and maps. It then uses binary serialization to output C++ vectors and maps into corresponding 20 binary files\".\nI don't know what's the purpose of the author by using binary serialization, but I guess it might be due to three reasons:\n\nReduced binary file sizes than plain text files\nReduced initialization time, since the system starts by loading these files into memory and populating structures.\nIt MIGHT speed up at runtime besides initialization stage, although the possibility is small.\n\nI have little experience of object serialization and when I now rewrite it with python, I don't know whether I should use object serialization or not. In Python, does object serialization speed up programs noticeably, or it reduces file sizes to be stored on disk? Or any other benefits? I know the downside is that it makes program more complicated.\nIn implementing the logic described above in Python, should I use object serialization as well?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":37,"Q_Id":70297044,"Users Score":1,"Answer":"Sounds like it's almost certainly the case that the point is to avoid this part: \"It then parses each line and loaded all data into objects of C++ vectors and maps\".\nIf the binary machine data in the \"C++ vectors and maps\" can later be loaded directly, then all the expenses of parsing the text to recreate them from scratch can be skipped.\nCan't answer whether you \"should\" do the same, though, without knowing details of the expenses involved. Not enough info here to guess.","Q_Score":0,"Tags":"python,object-serialization","A_Id":70297122,"CreationDate":"2021-12-09T21:39:00.000","Title":"Does object serialization help in runtime or initialization speed up?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Im using python 3.9 and coverage 6.2\nI would like to have a record of my most recent coverage but Im not sure if I should upload my .coverage file. Im guessing no since it sort of has info about my directory layout. So i would like to know how I should go about that, is it even standard to upload such a thing? If not, why not?\nI also generated the htmlcov folder but I didnt upload it since it has a default gitignore for the entire folder.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":287,"Q_Id":70297207,"Users Score":1,"Answer":"Most people don't upload the .coverage or HTML report, because they don't need to track it over time. But there's no harm in uploading them. You mention directory layout as if it was a secret to protect, but isn't your layout already committed to GitHub?\nIf you want to commit the HTML report, you will need to remove the .gitignore file in the directory.","Q_Score":1,"Tags":"python,coverage.py","A_Id":70304570,"CreationDate":"2021-12-09T21:55:00.000","Title":"Python, Should I upload my .coverage file to my github repository?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm testing AI model with rabbit mq.\nBecasue the process using AI model is heavy, i use rabbit mq to control the task order.\nThe problem is killing the callback function after consuming.\nFor example, there are three tasks in rabbit mq(A,B,C in order)\n\ntask A is consuming, callback function(include AI model) is running\ntask B,C is waiting untill basic_ack arrived\nI want cancel task A ,B and analysis C first\n\nin this case,\n\nhow can i kill the process (task A),\ndelete the message B in rabbit MQ","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":79,"Q_Id":70300249,"Users Score":0,"Answer":"I find the way but cannot sure the right way.\nUse another queue to receive all message from rabbitmq\nand create_task by using asyncio to cancel when i want\nit works well only all funcs are asyncronose","Q_Score":0,"Tags":"python,deep-learning,process,rabbitmq","A_Id":70387588,"CreationDate":"2021-12-10T05:48:00.000","Title":"How can i kill the process in rabbit mq?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to set up a sort of basic screensaver on a Raspberry PI.\nI'm using python because I like it a lot more than bash.\nThe script uses popen to call feh and display a slideshow.\nThere's also NodeRed running on this Pi, and that manages the actions bound to a few GPIO buttons.\nI would like to intercept those button inputs to stop the slideshow.\nI thought of 3 ways:\n\nuse NodeRed to kill (-15 or -9) feh. But this leaves behind a \"defunct\" process, and python should rely on the absence of the spawned process before spawning a new one\nuse the RPi.GPIO library and bind a callback event to the button press. This doesn't work because it throws the error that the channel (i.e. the GPIO pin) is already in use, and the RPI crashes and has to be power cycled.\nuse a OS environment variable. This could work, but I don't want to continually be polling the variable. The feh process needs to stop immediately upon a button press.\n\nSo how else could this be achieved?\nIs there a way to bind a function to some external trigger?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":120,"Q_Id":70313951,"Users Score":0,"Answer":"I realized that since the script logic is very simple and only has one task, it would have been easy to use a socket (synchronous and blocking) and wait on that for NodeRed to send its command. And indeed it was","Q_Score":0,"Tags":"python-3.x,events,triggers,gpio","A_Id":70319910,"CreationDate":"2021-12-11T09:22:00.000","Title":"make python wait for external trigger","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I handle a big number of XML files, each of which stores a float64 array in the form of a base64 string.\nFor each of these files, I would like to access the value of its array at a specific index without loading the whole array. I wish to do this in Python.\nCurrently, I decode the entire string and then access the value at given index, but I am looking for a much faster method.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":57,"Q_Id":70324840,"Users Score":0,"Answer":"As I understand, each float uses 8 bytes to store. Each 3-bytes of binary data are mapped to 4 base64 chars. So, in order to access i-th float, you'll need to:\n\nget base64 chars from index (i * 8 \/ 3) * 4 to (i * 8) \/ 3) * 4 + 4\ndecode that chunk from base64 to binary\ndrop first (i * 8) % 3 bytes\nuse next 8 bytes as a float64 value.","Q_Score":0,"Tags":"python,base64","A_Id":70325056,"CreationDate":"2021-12-12T15:13:00.000","Title":"Decode base64 array at specific index positions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently doing a data-driven test. I created a test template that will use data from one excel file(specific sheet) for the input data. Is it possible that I import the data from more than one excel sheet in a single robot file?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":103,"Q_Id":70331435,"Users Score":0,"Answer":"Yes, it is possible. Use for loop to search through several files one by one.\nyou can use something like below: f1,f2,f3 etc.\n`with open(filepath, 'r') as f1:\nlines = f.readlines()\nfor line in lines:\n#do something`","Q_Score":0,"Tags":"python-3.x,automation,robotframework,data-driven-tests","A_Id":70332463,"CreationDate":"2021-12-13T07:55:00.000","Title":"For data driven test using robotframework, is it possible to have more than one data driver (using more than one datasheet)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Im trying to unittests methods in fileA.py. fileA.py contains imports to firebasehandler.py where Im setting a connection to firebase. The methods I'm trying to test have no relation or need at all with anything from firebasehandler.py, but when running the tests I don't want to go through the credentials checking phase. What can I do to skip that import when running the unittests?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":25,"Q_Id":70332628,"Users Score":-1,"Answer":"I guess you can mock the imported object or method from fileA.py in your UT.","Q_Score":0,"Tags":"python,unit-testing","A_Id":70332707,"CreationDate":"2021-12-13T09:44:00.000","Title":"How to skip imports that are not needed while unittesting python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Whereas assert in Python is ideal to verify wether certain function calls return an expected output for a given input, could it also be used to check for results printed on screen (i.e., in procedures that return no results but only have side efffects like printing stuff on screen)? The context of this question is how to write such automated tests that I would like to include in an automated grader tool.\nSince expect the answer to this question to be: assert does not serve this purpose; what other trick could I use then to check the screen output produced by a procedure?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":20,"Q_Id":70366281,"Users Score":1,"Answer":"You could redirect the standard output to a file and then compare it's content for validity.","Q_Score":0,"Tags":"python,printing,assert","A_Id":70366324,"CreationDate":"2021-12-15T15:29:00.000","Title":"Is there an easy way to use asserts in Python to check for results printed on screen","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to measure coverage in my project by integration tests (integration of several microservices). Applications - python, tests - pytest.\nI know about pytest-cov, but the problem is that my application and tests start in different docker containers. And all interaction between app and tests is carried out through http. So tests know nothing about applications code and vice versa the same.\nI know that in C\/\u0421# it is possible to make special build (instrumental build - or something like this (the name may be wrong :-))). The main idea it is that after work, application generate some report with coverage and you can check it.\nIs there something similar for python? Or may be some another way?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":162,"Q_Id":70378685,"Users Score":0,"Answer":"However you start your application under test, you can start it with coverage.py instead. If you normally use python my_app.py, use coverage run my_app.py instead. When the app finishes, you will have coverage data for the application.\nCoverage.py is the coverage measurement tool that pytest-cov coordinates. You will get the same measurement.","Q_Score":1,"Tags":"python,testing,pytest,code-coverage","A_Id":70392370,"CreationDate":"2021-12-16T12:01:00.000","Title":"How to measure test coverage of app on python if application and tests in different projects","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a newbie to network programming in python. I would like to know if there is any way that we can code in python to detect this kind of scan. I would like to build a open source project by using the method that you might suggest.\nThanks in advance !!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":389,"Q_Id":70384109,"Users Score":0,"Answer":"unfortunately there is no actual way to achieve this since port scanning have no standard protocol which can be used to indicate, it is just like a regular socket connection, be it a client connection to fetch a web page for example. (it can be port scanner for port 80 or actual client who wants specific page)\nyou can develop an algorithm that checks the number of requests received to say.. 100 random ports, and if at least x of them points to those random ports within a time range, it can possibly be a port scanner.\nbe aware this is will not always work, since port scanning doesn't always mean all ports, it can also be a range of ports, specific port and so on.","Q_Score":1,"Tags":"python,python-3.x,port,port-scanning","A_Id":70384388,"CreationDate":"2021-12-16T18:43:00.000","Title":"How to detect TCP Port Scan using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Brownie was working great yesterday. Today I get this error. Anyone have a solution?\nPS C:\\Users\\philk\\demos\\web3_py_simple_storage> brownie --version\nINFO: Could not find files for the given pattern(s).\nTraceback (most recent call last):\nFile \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\\lib\\runpy.py\", line 197, in run_module_as_main\nreturn run_code(code, main_globals, None,\nFile \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\\lib\\runpy.py\", line 87, in run_code\nexec(code, run_globals)\nFile \"C:\\Users\\philk.local\\pipx\\venvs\\eth-brownie\\Scripts\\brownie.exe_main.py\", line 4, in \nFile \"C:\\Users\\philk.local\\pipx\\venvs\\eth-brownie\\lib\\site-packages\\brownie_init.py\", line 6, in \nfrom brownie.project import compile_source, run\nFile \"C:\\Users\\philk.local\\pipx\\venvs\\eth-brownie\\lib\\site-packages\\brownie\\project_init.py\", line 3, in \nfrom .main import ( # NOQA 401\nFile \"C:\\Users\\philk.local\\pipx\\venvs\\eth-brownie\\lib\\site-packages\\brownie\\project\\main.py\", line 45, in \nfrom brownie.network import web3\nFile \"C:\\Users\\philk.local\\pipx\\venvs\\eth-brownie\\lib\\site-packages\\brownie\\network_init_.py\", line 4, in \nfrom .account import Accounts\nFile \"C:\\Users\\philk.local\\pipx\\venvs\\eth-brownie\\lib\\site-packages\\brownie\\network\\account.py\", line 13, in \nimport eth_account\nFile \"C:\\Users\\philk.local\\pipx\\venvs\\eth-brownie\\lib\\site-packages\\eth_account_init_.py\", line 1, in \nfrom eth_account.account import (\nFile \"C:\\Users\\philk.local\\pipx\\venvs\\eth-brownie\\lib\\site-packages\\eth_account\\account.py\", line 11, in \nfrom eth_keyfile import (\nFile \"C:\\Users\\philk.local\\pipx\\venvs\\eth-brownie\\lib\\site-packages\\eth_keyfile_init_.py\", line 7, in \nfrom eth_keyfile.keyfile import ( # noqa: F401\nFile \"C:\\Users\\philk.local\\pipx\\venvs\\eth-brownie\\lib\\site-packages\\eth_keyfile\\keyfile.py\", line 6, in \nfrom Crypto.Cipher import AES\nFile \"C:\\Users\\philk.local\\pipx\\venvs\\eth-brownie\\lib\\site-packages\\Crypto\\Cipher_init_.py\", line 36, in \nfrom Crypto.Cipher._mode_gcm import _create_gcm_cipher\nFile \"C:\\Users\\philk.local\\pipx\\venvs\\eth-brownie\\lib\\site-packages\\Crypto\\Cipher_mode_gcm.py\", line 51, in \nfrom Crypto.Util import _cpu_features\nFile \"C:\\Users\\philk.local\\pipx\\venvs\\eth-brownie\\lib\\site-packages\\Crypto\\Util_cpu_features.py\", line 34, in \n_raw_cpuid_lib = load_pycryptodome_raw_lib(\"Crypto.Util._cpuid_c\",\nFile \"C:\\Users\\philk.local\\pipx\\venvs\\eth-brownie\\lib\\site-packages\\Crypto\\Util_raw_api.py\", line 309, in load_pycryptodome_raw_lib\nraise OSError(\"Cannot load native module '%s': %s\" % (name, \", \".join(attempts)))\nOSError: Cannot load native module 'Crypto.Util._cpuid_c': Not found '_cpuid_c.cp39-win_amd64.pyd', Not found '_cpuid_c.pyd'","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":77,"Q_Id":70395528,"Users Score":-1,"Answer":"I rebooted but problem still persisted. I uninstalled brownie and reinstalled\npipx uninstall eth-brownie\npipx install eth-brownie\nI was prompted with missing path\nC:\\Users\\username.local\\bin\"\nso i added it\nworks now.","Q_Score":0,"Tags":"python,brownie","A_Id":70426098,"CreationDate":"2021-12-17T15:41:00.000","Title":"Brownie error Cannot load native module 'Crypto.Util._cpuid_c'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"In Raspberry Pi 4, I am trying to read a series of files(more than 1000 files) in the specific directory with the fopen function in the for loop, but fopen cannot read the file if it exceeds a certain number of iterations. How do I solve this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":63,"Q_Id":70418351,"Users Score":0,"Answer":"When you open file using fopen the system uses a file descriptor to point to that file. And there are only so many of them available. A quick google search says microsoft usually has 512 file descriptors. Also, the file is loaded to memory. So, loading a lot of files will use up your memory fast. You should close each file after you are done with them. This usually is not a problem when working with a few files. But in case like yours where thousands of files are necessary, they should be closed as soon as possible after using them.","Q_Score":0,"Tags":"python,c,fopen","A_Id":70418464,"CreationDate":"2021-12-20T07:01:00.000","Title":"Using fopen in Raspberry pi4","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In Raspberry Pi 4, I am trying to read a series of files(more than 1000 files) in the specific directory with the fopen function in the for loop, but fopen cannot read the file if it exceeds a certain number of iterations. How do I solve this?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":63,"Q_Id":70418351,"Users Score":1,"Answer":"but fopen cannot read the file if it exceeds a certain number of iterations.\n\nA wild guess: you neglect to fclose the files after you are done with them, leading to eventual exhaustion of either memory or available file descriptors.\n\nHow do I solve this?\n\nMake sure to fclose your files.","Q_Score":0,"Tags":"python,c,fopen","A_Id":70418380,"CreationDate":"2021-12-20T07:01:00.000","Title":"Using fopen in Raspberry pi4","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Could you please tell me how can I create an alarm from a Python script in a Zabbix system?\nI have a Python script in which a certain function is processed, and at a certain point I would like to create an alarm in the Zabbix system when a certain condition is created in the script. I also have a mail server. I was thinking of creating a separate mailbox for Zabbix, to this email address I will send a letter from Python, and the Zabbix system will receive this letter, process and create a Problem. Is such functionality possible?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":47,"Q_Id":70423366,"Users Score":1,"Answer":"Easiest is to use zabbix for this. To do that you feed values to an item in zabbix in one of the many ways and create a trigger that fires when you want it.\nIf a script is needed to generate the values you can implement the script as a user parameter if it is short running. If it takes more than a few seconds using zabbix sender might be smarter.","Q_Score":0,"Tags":"python,zabbix","A_Id":70426045,"CreationDate":"2021-12-20T14:32:00.000","Title":"From Python to create an alarm in Zabbix","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to make a flutter app that, when a button is pressed, it runs a python or a js script that I made and is saved in a .js or a .py file. Essentially, I want to run a .js or a .py file when a button in Flutter is pressed. Is that possible? And if yes, how can it be done? I am making a desktop application that has to work offline.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":81,"Q_Id":70436141,"Users Score":1,"Answer":"Yes, this is possible, but it requires Python and JS interpreters to be installed on the device. A way to ensure this is to ship them together with your app, although this will take a lot of extra space. From your app, you just launch the interpreter as a subprocess, for example python3 your_script.py\nIf your script is hardcoded and not changed later by the app, you can also turn it into a standalone executable, using a tool such as py2exe. But this is basically the same thing, the interpreter just ends up included in your script.","Q_Score":2,"Tags":"javascript,python,flutter,dart","A_Id":70436272,"CreationDate":"2021-12-21T13:20:00.000","Title":"Is it possible to run a js or python script from a .js or .py file when a button in Flutter is pressed? (Not Flutter Web)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to make a flutter app that, when a button is pressed, it runs a python or a js script that I made and is saved in a .js or a .py file. Essentially, I want to run a .js or a .py file when a button in Flutter is pressed. Is that possible? And if yes, how can it be done? I am making a desktop application that has to work offline.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":81,"Q_Id":70436141,"Users Score":1,"Answer":"Yes you can using API, you make API in django or flask backend which run the python script you want after you make a request to your API via clicking the flutter button","Q_Score":2,"Tags":"javascript,python,flutter,dart","A_Id":70436198,"CreationDate":"2021-12-21T13:20:00.000","Title":"Is it possible to run a js or python script from a .js or .py file when a button in Flutter is pressed? (Not Flutter Web)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"So, I've built this program using python what is currently running in the terminal.\nMy goal is to eventually design the application in a modern way like (discord, slack, or any other 2021 downloaded desktop-app),but I'm not really sure what to use.\nThe thing is, I know React\/Electron would be the best way to build\/design a desktop application like discord, teams etc. However, I'm looking to keep my python as some sort of backend, while using lets say Electron as front\nHow can I keep my python functions, while designing a modern GUI\/front end?\nThanks for advice","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":164,"Q_Id":70448013,"Users Score":0,"Answer":"You could use the Tkinter python module although it is not to much like react.","Q_Score":0,"Tags":"python,user-interface,desktop-application","A_Id":70448055,"CreationDate":"2021-12-22T11:02:00.000","Title":"Best way to build a desktop app while keeping my python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am setting up Robot Framework on RHEL 8.4. I have python 3.6 installed on my machine. However, when I try to run robot from within python virtual environment it throws\n-ksh: robot: cannot execute [Permission Denied]\nI also ran whereis robot and gave all permissions to the robot file.\nThe error happens when I am trying to run robot as a user other than root from within the virtual environment however, it works fine when run within virtual environment as root.\nHowever, I am not keen to continue normal development as root and would like this to work via my normal user.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":91,"Q_Id":70461139,"Users Score":0,"Answer":"It sounds quite strange but upgrading PIP resolved the issue.","Q_Score":0,"Tags":"python,linux,robotframework,rhel8","A_Id":70463794,"CreationDate":"2021-12-23T10:55:00.000","Title":"RHEL Permission Denied whilst trying to Run Robot Framework","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"Is it possible to get proto files from generated pb2.py with protoc? Will be the same reverse engineering possible for gRPC?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":807,"Q_Id":70479912,"Users Score":0,"Answer":"It is possible but I'm unaware of any tools that do this.\nProtocol Buffers (protos) including gRPC service definitions are compiled by protoc into language-specific sources. You're looking for a decompiler.\nWe know that the process is invertible because it works; we're able to send messages using generated sources -- even across languages -- to peers.","Q_Score":1,"Tags":"protocol-buffers,grpc,protoc,grpc-python,protobuf-python","A_Id":70481385,"CreationDate":"2021-12-25T12:06:00.000","Title":"Reverse engineering .proto files from pb2.py generated with protoc","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So currently, I'm trying to create a bot that messages every 5 minutes using python-telegram-bot JobQueue. The app is deployed on heroku and it seems to be working just fine. But sometimes it doesn't message me after periods of inactivity (ex. not using \/start with the bot) How do I solve this issue ? When I check the log it seems to be running fine. Thanks !","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":133,"Q_Id":70498650,"Users Score":0,"Answer":"Instead of worker python bot.py use clock python bot.py in the Procfile","Q_Score":0,"Tags":"telegram-bot,python-telegram-bot","A_Id":70891136,"CreationDate":"2021-12-27T17:34:00.000","Title":"Running Telegram Bot on Heroku","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm very new to python and programming in general, and I'm looking to make a discord bot that has a lot of hand-written chat lines to randomly pick from and send back to the user. Making a really huge variable full of a list of sentences seems like a bad idea. Is there a way that I can store the chatlines on a different file and have the bot pick from the lines in that file? Or is there anything else that would be better, and how would I do it?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":49,"Q_Id":70501825,"Users Score":0,"Answer":"You can store your data in a file, supposedly named response.txt\nand retrieve it in the discord bot file as open(\"response.txt\").readlines()","Q_Score":0,"Tags":"python,discord,discord.py","A_Id":70501865,"CreationDate":"2021-12-28T01:00:00.000","Title":"discord.py: too big variable?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm very new to python and programming in general, and I'm looking to make a discord bot that has a lot of hand-written chat lines to randomly pick from and send back to the user. Making a really huge variable full of a list of sentences seems like a bad idea. Is there a way that I can store the chatlines on a different file and have the bot pick from the lines in that file? Or is there anything else that would be better, and how would I do it?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":49,"Q_Id":70501825,"Users Score":0,"Answer":"I'll interpret this question as \"how large a variable is too large\", to which the answer is pretty simple. A variable is too large when it becomes a problem. So, how can a variable become a problem? The big one is that the machien could possibly run out of memory, and an OOM killer (out-of-memory killer) or similiar will stop your program. How would you know if your variable is causing these issues? Pretty simple, your program crashes.\nIf the variable is static (with a size fully known at compile-time or prior to interpretation), you can calculate how much RAM it will take. (This is a bit finnicky with Python, so it might be easier to load it up at runtime and figure it out with a profiler.) If it's more than ~500 megabytes, you should be concerned. Over a gigabyte, and you'll probably want to reconsider your approach[^0]. So, what do you do then?\nAs suggested by @FishballNooodles, you can store your data line-by-line in a file and read the lines to an array. Unfortunately, the code they've provided still reads the entire thing into memory. If you use the code they're providing, you've got a few options, non-exhaustively listed below.\n\nConsume a random number of newlines from the file when you need a line of text. You would look at one character at a time, compare it to \\n, and read the line if you've encountered the requested number of newlines. This is O(n) worst case with respect to the number of lines in the file.\n\nRather than storing the text you need at a given index, store its location in a file. Then, you can seek to the location (which is probably O(1)), and read the text. This requires an O(n) construction cost at the start of the program, but would work much better at runtime.\n\nUse an actual database. It's usually better not to reinvent the wheel. If you're just storing plain text, this is probably overkill, but don't discount it.\n\n\n[^0]: These numbers are actually just random. If you control the server environment on which you run the code, then you can probably come up with some more precise signposts.","Q_Score":0,"Tags":"python,discord,discord.py","A_Id":70501924,"CreationDate":"2021-12-28T01:00:00.000","Title":"discord.py: too big variable?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running .py file using Robotframework. py file has a logic to compare two csv files and generate 2 new csv files with details of difference. This py file works well(within seconds) and smoothly when executed using python IDE but it is taking too long time to get completed (I kept timeout of 10min).\nI am using Process Library along with my py file to run these together.\nRun Process runs the .py file and returns the result to RF console. But in this case, it is getting timed out. I am using RF 3.2.2","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":42,"Q_Id":70523127,"Users Score":0,"Answer":"I have used py as a library to import the python function to do desired task. It just enabled me to use that as a keyword inside my robot file. This was executed quickly with the right output. I could then print that to console.","Q_Score":0,"Tags":"python,robotframework","A_Id":71748499,"CreationDate":"2021-12-29T17:53:00.000","Title":"Running python code from RobotFramework taking too long","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"bitnami Review Board The Python module \"subvertpy\" is not installed when adding repository\nThe Python module \"subvertpy\" is not installed. You may need to restart the server after installing it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":70527410,"Users Score":0,"Answer":"It seems to beening some error on bitnami ReivewCode 4.04, I try a lower verion on\nbitnami-reviewboard-3.0.9-1-linux-debian-9-x86_64.ovam,and problem solved!!","Q_Score":1,"Tags":"python,review-board","A_Id":70529140,"CreationDate":"2021-12-30T04:15:00.000","Title":"bitnami Review Board The Python module \"subvertpy\" is not installed when adding repository","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to run a Python script and save its console output to a file, while still being able to see the output in the console. For example, a \"Hello World\" script as simple as print('Hello World') would show Hello World in the console and also save this output to a file.\nI was previously using pythonscript.py > console_output.txt to shell redirect, I can't see anything in the console with this solution (and for some reason, it no longer saves anything to the specified file, no idea why). This is a solution using Linux shell redirection, but now I would like to write a separate python script to do it.\nI don't think I need any special error logging stuff. I'm currently using try: except blocks and just printing the Exception and then using that to find the error.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":370,"Q_Id":70542526,"Users Score":1,"Answer":"Try tee command, for example: pythonscript.py | tee console_output.txt","Q_Score":0,"Tags":"python,logging,stdout","A_Id":70542646,"CreationDate":"2021-12-31T12:53:00.000","Title":"How to save Python script console output to a file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I made a chatbot with rasa stack and I would like to use it in WhatsApp, I explored twilio, but I would like to know if there are more options that allows the implementation. Twilio is a little bit expensive and complicate to me and some clients don't like for the high price.\nI'm using rasa\/rasa: 2.7.2, have anyone found another alternative for twilio?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":72,"Q_Id":70568390,"Users Score":0,"Answer":"As far as I know, the only WhatsApp alternative is WhatsApp business, which is likely more expensive as you need to have a business license with them. Unfortunately their API is not public like most messaging services are.","Q_Score":0,"Tags":"python,twilio,rasa","A_Id":70575943,"CreationDate":"2022-01-03T16:01:00.000","Title":"how connect rasa stack chatbot with whatsapp without Twilio","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to send requests to a deployed app on a cloud run with python, but inside the test file, I don't want to hardcode the endpoint; how can I get the URL of the deployed app with python script inside the test file so that I can send requests to that URL?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":151,"Q_Id":70580631,"Users Score":2,"Answer":"You can use gcloud to fetch the url of the service like this\n\ngcloud run services describe SERVICE_NAME\n--format=\"value(status.url)\"","Q_Score":0,"Tags":"python,google-cloud-run","A_Id":70581001,"CreationDate":"2022-01-04T14:50:00.000","Title":"Retrive endpoint url of deployed app from google cloud run with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using fido2 python package and I would like to know how to generate an EC pair (ES256)\npublic and private key.\nand also how to sign a challenge using the private key\nso it'll be possible to verify it with the public key\nThanks","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":56,"Q_Id":70581405,"Users Score":-1,"Answer":"The Web Authentication protocol (and FIDO2 CTAP2 protocol built on top of it) have a challenge\/response protocol against a device representing authentication of the user called an Authenticator.\nThe fido2 python library is meant to be used to talk to the authenticator, not to emulate an authenticator itself. The role that talks to the authenticator is called a Relying Party.\nSystems typically further divide the Relying Party role into client and server roles - the client communicates with the authenticator, but really it is relaying the communication to and from the server. In WebAuthn, the browser, the site javascript it is running, and any underlying platform support are all considered part of the client. If you have native code talking USB or NFC to an authenticator (on platforms which let you), that native code is considered an authenticator.\nThe underlying authentication challenge does not have a cryptographic signature from the relying party. Instead, the cryptographic signature is made by the authenticator - the authenticator generates a new key pair on registration, and then supplies a signature from that key to prove possession and thus prove authentication. Since fido2 does not have authenticator support, it has no need to generate key pairs (outside of potential test code).\nNote that this gets to an essential of the underlying WebAuthn and FIDO2 platform trust model - the user must trust the client. For this reason, several platforms have locked out low-level access to authenticator hardware (USB, NFC and BLE communication to hardware) and instead provide system API. Native applications must have entitlements to operate on behalf of a particular web origin as a WebAuthn client, and browsers must request special entitlements from the platform in order to represent all web domains.\nThis does not affect usage of fido2 for implementing server functionality, but I'd advise you to double-check platform support if you plan to use it to implement any client functionality.","Q_Score":0,"Tags":"python,encryption,fido","A_Id":70589441,"CreationDate":"2022-01-04T15:44:00.000","Title":"how to generate fido2.cose import ES256 fido2 key pairs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a KVM in Apigee with the name \"test_kvm\" and the key is \"name\" with value \"myname\".\nSo basically it's like {\"name\": \"myname\"} and the value is encrypted. In KVM policy also I am using private prefix ...<\/>\nNow when I am trying to fetch this variable into my python script using PythonScript policy using the script getname = flow.getVariable(\"private.name\") this value is getting populated by \"None\". and not by value \"myname\".\nWhy am I getting None and how to properly fetch the Key value from KVM in Python?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":202,"Q_Id":70593226,"Users Score":0,"Answer":"Got it, the thing is we have to deploy kvm in the same environment that we are using to deploy our api proxy.","Q_Score":1,"Tags":"python,apigee","A_Id":70608338,"CreationDate":"2022-01-05T12:55:00.000","Title":"Not able to fetch the key-value from KVM in Apigee using Python Script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Python, pytest-bdd but have been creating frameworks in Java, TestNG, cucumber for a long time. So here in pytest-bdd I am creating the feature file and then on top of that, we are creating the step definitions and then running the tests.\nWhats the purpose of creating the feature file in pytest-bdd, if we are still running the tests from step definitions.. Is it just to check the coverage ??","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":69,"Q_Id":70594906,"Users Score":0,"Answer":"Well, unfortunately we are not at that AI level, wherein you type \"I don't want to write code\" and the system interprets, \"Ok! Alright! Lemme do it for you\" . So just writing the feature files won't work :)\nThe purpose of BDD feature files in any framework is to act as a scenario document understandable by all stakeholders. Internally it also helps in reusability, since if a step is available, you know that the code is available somewhere to achieve the step.\nEven in testng, cucumber, Java, ultimately, you are running tests from the xml\/maven which calls a Java runner file and tests run. You do not run a feature file, so to say.","Q_Score":0,"Tags":"python,pytest,pytest-bdd","A_Id":70602736,"CreationDate":"2022-01-05T14:50:00.000","Title":"What is the benefit of creating a feature.file in pytest-bdd, as we are still running the tests from steps. Unlike cucumber with Java","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to write a program that will take msg files and extract data fields from the msg files such as to, cc, bcc, subject, date\/time sent etc. Using the Python library extract_msg I have successfully done this.\nWhat I now need to do is add the functionality to extract individual emails from PST files at bulk into individual MSG files.\nI've looked around for a python library that will easily achieve this but I am struggling to find anything. Does anyone have any good suggestions on how I might do this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":192,"Q_Id":70598106,"Users Score":0,"Answer":"What I now need to do is add the functionality to extract individual emails from PST files at bulk into individual MSG files.","Q_Score":0,"Tags":"python,msg,pst","A_Id":70830235,"CreationDate":"2022-01-05T18:48:00.000","Title":"Convert pst file to msg files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"About 5 years ago this question was asked:\n\"On a web page in my web browser (preferably, but not necessarily Firefox), I can search (byctrl+f) for a given text \"abc\" within the body text of the page. From there then I must move the mouse cursor to another (relative) position (height plus x pixels), and there I must do a mouse click.\nI cannot do this otherwise since the needed info is not contained in the source code but is fetched by mouse click from the web server. The problem for me is to identify the position of the found text \"abc\", in order to move the mouse cursor there; from there it's easy.\nI currently try to solve my problem by searching for the background color which changes for the text \"abc\" when found, but the same color is found in lots of other positions on the screen, so this is unreliable, and finding the text \"abc\" as a graphic is unreliable, too. So I'm looking for an alternative, programmatic way to identify the position of found text, if there is any.\"\n==> I'm currently facing the same problem and so far haven't really found a solution! I'm using Python, but libraries such as pyautogui do not include any way (as far as I can tell) of obtaining the position of text located via Ctrl-F. I'm hoping for some solution that works under Windows and Linux, if possible. Any solutions\/workarounds\/suggestions would be greatly appreciated! Wayne","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":390,"Q_Id":70607418,"Users Score":1,"Answer":"My final approach to this problem only requires pyautogui. The first step is to use the \"find\" option (Ctrl-f) in Chrome to locate the text in question. The found text is then highlighted, generally in Orange (RGB=255,150,50) but sometimes in Yellow (RGB=255,255,0). I then take a screenshot using im = pyautogui.screenshot(). Finally, I search that image ('im') to look for pixels of the appropriate background color in order to identify the upper-left and lower-right corners of the highlighted rectangle. Using those two locations it is easy to compute the center of the highlighted text.\nI'm sure this is not the most efficient way of searching for the location of text on the screen, but this method certainly seems fast enough for many applications.\nThis method should be platform-independent, assuming that pyautogui is available. Also, no other special libraries such as Selenium are needed.\nNOTE: This approach will locate the FIRST occurrence of the text being sought, so care should be taken when defining that text.\nHoping that other folks may find this approach useful, Wayne","Q_Score":0,"Tags":"python,pyautogui,text-cursor","A_Id":70623648,"CreationDate":"2022-01-06T12:54:00.000","Title":"How to find screen coordinates of found text?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"It's my first post on this web site. I'm having a problem with running my python codes on Windows Power Shell although my Atom text editor can run. Because I've alread installed the latest python version. When I try to run codes with PowerShell it says me basicly that Python can not be found.\nDo you have any idea to solve this problem.\nThank you.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":42,"Q_Id":70615151,"Users Score":1,"Answer":"Find python (where \/R \\ python.exe) and add it to your path (win+r systempropertiesadvanced, go to environment variables, find PATH under the top box, start editing it, then add the python.exe directory to path.) Then restart powershell.","Q_Score":0,"Tags":"python,powershell","A_Id":70615183,"CreationDate":"2022-01-07T00:15:00.000","Title":"I can't run my python codes in Windows Power Shell despite my text editor can run","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"This is a question for deeper understanding, I understand that in practice, use cases for something like this would be extremely rare (though by all means I'm eager to hear of them).\nIf I understand correctly, the default metaclass used to generate all classes is the type(..., ..., ...) constructor function. In all examples I've seen of using custom metaclasses, at some point you are still calling the type(..., ..., ...) constructor function as well. You might be returning a pre-existing value, but still you at some point called type or one of the built-in classes to produce what you return.\nIs this always the case? Is there a way to use this feature where you don't use type at some point? Are there alternate methods to producing classes? Python seems to almost-always have some sort of well-actually-there's-a-protocol trick under the sheets.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":78,"Q_Id":70622731,"Users Score":2,"Answer":"Without calling the type \"function\" (it is actually a class), yes.\nWithout calling, at some step the type.__new__ method, no.\nNot in pure Python code - it would be possible with a native code extension, that would re-use the data structures of Python itself. I'd not recommend trying it, but for playing around.\nThe formal way for doing it without calling type is to use types.new_class. It will,however, call type.__new__ internally.\nBTW, for creating any instance of any class, with Python code, it is just the same with one of the built-in types .__new__. Usually object.__new__ is needed, unless you subclass one of the other built-ins (int, float, list, dict) - some of those will bypass object.__new__ and instantiate the your subclass directly - but they can only do that using native code and manipulating the structures that represent an object directly.\nok, both things should be possible with ctypes, which allow you to manipulate the memory structures in \"raw\" and call the internal APIs. And therefore in \"pure Python\" - but the idea is the same: you have to redo the workings of object.__new__ or typing.__new__ and correctly populate the data structures that represent these objects. That would be way more cumbersome than doing the same from a C file.","Q_Score":1,"Tags":"python,metaclass","A_Id":70623746,"CreationDate":"2022-01-07T14:31:00.000","Title":"Can you create classes without the type function?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to get the list of users accounts who have liked a tweet.\nReading the documentation of twitter api, it only returns up to 100 accounts. My question is: Is there another way to get more than 100 accounts with other method?\nThank you","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":55,"Q_Id":70627509,"Users Score":0,"Answer":"There is no way to get this information on arbitrary past Tweets. If you are the owner of an account you can track the likes using the Account Activity API after you post a Tweet, and can then keep track of the like actions. This would be the way to get the account information for likes on Tweets, beyond the API limit of 100 (which exists in both v1.1 and v2).","Q_Score":0,"Tags":"python,api,web,web-scraping,twitter","A_Id":70628144,"CreationDate":"2022-01-07T21:45:00.000","Title":"Getting more than 100 users accounts who have liked a tweet","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm not very familiar with pytest but try to incorporate it into my project. I already have some tests and understand main ideas.\nBut I got stuck with test for Excel output. I have a function that makes a report and saves it in Excel file (I use xlsxwriter to save in Excel format). It has some merged cells, different fonts and colors, but first of all I would like to be sure that values in cells are correct.\nI would like to have a test that will automatically check content of this file to be sure that function logic isn't broken.\nI'm not sure that binary comparison of generated excel file to the correct sample is a good idea (as excel format is rather complex and minor change of xlsxwriter library may make files completely different).\nSo, I seek an advice how to implement this kind of test. Had someone similar experience? May you give advice?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":247,"Q_Id":70643411,"Users Score":0,"Answer":"IMHO a unit test should not touch external things (like file system, database, or network). If your test does this, it is an integration test. These usually run much slower and tend to be brittle because of the external resources.\nThat said, you have 2 options: unit test it, mocking the xls writing or integration test it, reading the xls file again after writing.\nWhen you mock the xlswriter, you can have your mock check that it receives what should be written. This assumes that you don't want to test the actual xlswriter, which makes sense cause it's not your code, and you usually just test your own code. This makes for a fast test.\nIn the other scenario you could open the excel file with xslsreader and compare the written file to what is expected. This is probably best if you can avoid the file system and write the xls data to a memory buffer from which you can read again. If you can't do that, try using a tempdir for your test, but with that you're already getting into integration test land. This makes for a slower, more complicated, but also more thorough test.\nPersonally, I'd write one integration test to see that it works in general, and then a lot of unit tests for the different things you want to write.","Q_Score":0,"Tags":"python,pytest,python-unittest","A_Id":70643489,"CreationDate":"2022-01-09T16:40:00.000","Title":"Python Unit Test for writing Excel file","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python code on my desktop where I call Google APIs to get some data. I am trying to deploy it on AWS Lambda to run it periodically but I and running into some issues. Below are the steps I followed:\n\nDownloaded google package using pip3 install google-api-python-client -t . Zipped this folder and uploaded it to a layer in AWS Lambda\nLinked the layer with my function but when I am trying to execute the lambda function, I get the following error:\n\n\"errorMessage\": \"Unable to import module 'lambda_function': No module named 'googleapiclient'\",\nIn my code I have the following import statement:\nfrom googleapiclient.discovery import build\nPlease let me know if I am missing something and how to debug this.\nRegards,\nDbeings","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":291,"Q_Id":70643567,"Users Score":0,"Answer":"You typically receive this error when your Lambda environment can't find the specified library in the Python code. This is because Lambda isn't prepackaged with all third party python libraries.\nin your local environment \"googleapiclient\" are compiled and available during runtime but it's not available in lambda runtime.\nTo resolve this error, create a deployment package(pre-compilied\/zip) or Lambda layer that includes the libraries that you want to use in your Python code for Lambda.\nbest of luck","Q_Score":0,"Tags":"amazon-web-services,aws-lambda,google-api,google-api-python-client","A_Id":70643777,"CreationDate":"2022-01-09T16:58:00.000","Title":"Google API Python Client Call with AWS Lambda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have created a fifo using C and python programs. The fifo is created in the C program, which does the reading Operation and the writing is done in Python. My question is as follows:\n\nIf my reader(C program) is killed forcefully, my writer keeps writing to the fifo. How can I handle this so that the writer exits when reader is killed?\nWhen the reader is killed , is a SIGPIPE signal recieved by the writer?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":70648067,"Users Score":0,"Answer":"So I observed the following on further testing:\n\nWhen the reader process is killed, SIGPIPE is not recieved by the writer.\nHowever, when reader is killed, the open call for the fifo file is blocked at the writer's end.\nSo, I have currently resolved the issue in question no.1 by adding O_NONBLOCK flag in my writer's open call. Once this is added, open call throws an exception if the fifo has no active readers.\nThanks!","Q_Score":0,"Tags":"python,c,named-pipes,fifo,sigpipe","A_Id":70665248,"CreationDate":"2022-01-10T05:14:00.000","Title":"Is SIGPIPE signal received when reader is killed forcefully(kill -9)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a fifo using C and python programs. The fifo is created in the C program, which does the reading Operation and the writing is done in Python. My question is as follows:\n\nIf my reader(C program) is killed forcefully, my writer keeps writing to the fifo. How can I handle this so that the writer exits when reader is killed?\nWhen the reader is killed , is a SIGPIPE signal recieved by the writer?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":70648067,"Users Score":0,"Answer":"When writing to a pipe with a defunct reader, the writer will receive a SIGPIPE signal. By default, this will kill the process. If the signal is ignored, the write will return error EPIPE. This happens regardless of how the reader died.","Q_Score":0,"Tags":"python,c,named-pipes,fifo,sigpipe","A_Id":70648160,"CreationDate":"2022-01-10T05:14:00.000","Title":"Is SIGPIPE signal received when reader is killed forcefully(kill -9)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to programming and currently following a brownie tutorial.\nWhile interacting with smart contracts, my tutor puts a tx.wait(1) after every transaction that requires a state change of the contract.\nI'm guessing tx.wait(1) means that we tell brownie to wait for at least one confirmation of the transaction before proceeding further.\nBut\n\ntx.wait(1) is not required after deploying a contract. Why don't we wait for a confirmation after deployment?\nmy tutor skips tx.wait(1) during testing. why does it still work?\n\nIt is clear that I don't fully understand what tx.wait(1) actually does. Can someone please explain it to me? Or atleast point me towards some documentation about it?\nI'd really appreciate the help. TIA.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":228,"Q_Id":70677788,"Users Score":0,"Answer":"number of confirmations are required to finalize a transaction with high\nprobability. Confirmations serve as an additional mechanism to ensure that there is probabilistically a very low chance for a transaction to be reverted, but otherwise, once a mined block is finalized and announced, the transactions within that block are final at that point. Bitcoin has 6 block confirmations. The key idea behind waiting for six confirmations is that the\nprobability of double spending is virtually eliminated after six confirmations.","Q_Score":1,"Tags":"python,solidity,smartcontracts,ganache,brownie","A_Id":70678274,"CreationDate":"2022-01-12T07:31:00.000","Title":"When is tx.wait(1) required?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to run a python script file on the 20th of every month. This code will read the tsv file (stored somewhere) then call to the fee registration API and log the response to a file and save it. The processed tsv file will be moved to the processed folder.\nI dont know the best way to implement this in AWS?\nManual approach is:\n\nCreate EC2 instance, run python script\nStore tsv file on s3 (I dont know the best way to handle file upload problem)\nUse lambda to trigger on the 20th of every month.\n\nWhat is the best way to implement this in AWS?\nWhat is the best way to implement file storage and upload?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":135,"Q_Id":70693362,"Users Score":2,"Answer":"You can do it without an Amazon EC2 instance:\n\nCreate an AWS Lambda function that will perform the process (call API and log the response)\nStore any persistent data in an Amazon S3 bucket and have the Lambda function download\/upload from there\nCreate a CloudWatch Events rule to trigger the AWS Lambda function at the desired interval\n\nAWS Lambda functions provide 512MB of storage in the \/tmp\/ directory, so you can download the TSV file to there, perform your operations and then upload the resulting file back to S3.\nYou will only be charged for the duration that the Lambda function actually runs.","Q_Score":0,"Tags":"python,amazon-s3,amazon-ec2,amazon-ecs,script","A_Id":70693466,"CreationDate":"2022-01-13T08:19:00.000","Title":"What is the best way to run python scripts once per month in AWS?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am a Senior High School IEA student and I am trying to develop a discord bot for a project. It is in my interest for the bot to have robust functions and have the capability to play music. I've glanced across multiple tutorials on youtube and I still find myself scratching my head.\nWhats the difference between discord.py and discord.py rewrite?\nAre you supposed to pip install discord.py[voice] separately from those two?\nIs discord.py[voice] compatible with discord.py rewrite? Or is there a different version of voice on rewrite?\nAlso is there a specific IDE that you particularly recommend using for developing a discord bot?\nSome clarity would be nice!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":302,"Q_Id":70698875,"Users Score":1,"Answer":"discord.py is now up to date, so it will work fine for the project. I believe (I haven't worked with it before) discord.py[voice] is just a superset of discord.py with audio functionality, so installing it should leave you all set for your project.\nAs for an IDE, I recommend visual studio code or pycharm, this part isn't really important, just pick an editor that you like, get used to it, and it will get the job done fine.\nAlso, it's worth noting that mainline development for discord.py has recently ended, this shouldn't affect your project because it's a very recent change, but keep this in mind in the future in case things start to become incompatible.","Q_Score":0,"Tags":"python,discord,discord.py","A_Id":71302949,"CreationDate":"2022-01-13T15:13:00.000","Title":"What is the difference between discord.py and discord.py rewrite? And are they both compatible with discord.py[voice]?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Using Python 3.8.\nI have a module that imports pgpy for encryption\\decryption.\nWhen run manually, everything works as expected.\nHowever, when it is called by a Python scheduler running as a Windows service, it constantly throws the error:\nDLL load failed while importing _openssl: The specified module could not be found.\n\nI've look at other solutions that talk about having the specific dlls in the DLL path, but that hasn't helped me.\nlibcrypto-1_1.dll, libcrypto-1_1-x64.dll, libssl-1_1.dll, and libssl-1_1-x64.dll are all located in the Python38\\DLLs folder (and the Scripts folder also for some reason).\nAgain, the script runs correctly with no issue when run manually. It's only when it's called by a scheduler run under a Windows service that it fails.\nLooking for any advice or clue as to what I might be able to do here.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":191,"Q_Id":70702974,"Users Score":0,"Answer":"pip install --upgrade pip\npip uninstall pyopenssl cryptography\npip install pyopenssl cryptography\nimport openssl:\npython -v -c 'from OpenSSL import SSL'","Q_Score":0,"Tags":"python-3.8","A_Id":71550539,"CreationDate":"2022-01-13T20:51:00.000","Title":"Python as a Windows service: DLL load failed while importing _openssl","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"In A* search, which data structure would be more efficient ? Min-heap or Binary search tree.\nConsidering that below operations are to be handled frequently:\n(a) extract min\n(b) search a node\n(c) update the node\n(d) insert a node\nNote: Search operation would be very frequent as we need to check the presence of each probable child node in the open-list of A*.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":75,"Q_Id":70709497,"Users Score":1,"Answer":"A min-heap is a much simpler data structure than a balanced binary search tree, and it's typically implemented in an array, which reduces memory used and improves cache locality.\nFor these reasons, a min-heap implementation will be much faster if you do it right.\nIt's often tricky to implement the decrease-key operation in an array-based min-heap, though. The usual solution is not to implement decrease-key at all, but just to insert another record in the min-heap whenever the distance to a node is decreased.\nThis will not increase the time complexity of the algorithm, the min-heap will take O(|E|) space. If your graph is very dense, then a node's weight may be decreased many times, and this memory consumption might be too much. If that's so, then you should just clean up the min-heap -- remove invalid entries and re-heapify -- whenever more than half of the entries in the heap are invalid. This will keep memory consumption down to O(|V|) without significantly affecting run time.","Q_Score":0,"Tags":"python-3.x,data-structures,binary-search-tree,a-star,min-heap","A_Id":70711551,"CreationDate":"2022-01-14T10:53:00.000","Title":"Which data structure is more efficient for A*?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to have both keyboards (telegram.InlineKeyboard and telegram.ReplyKeyboard) under a single message?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":35,"Q_Id":70746935,"Users Score":1,"Answer":"no, that's not possible. the reply_markup parameter of send_message & friends only accepts one keyboard. The closest you can get is to send two messages with one keyboard each and delete the message with the ReplyKeyboardMarkup right away.","Q_Score":0,"Tags":"python,python-3.x,python-telegram-bot","A_Id":70751591,"CreationDate":"2022-01-17T20:06:00.000","Title":"Is it possibile to have both InlineKeyboard and ReplyKeyboard on telegram?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Since the python logging package is based on PEP 282 and influenced by Apache's log4j system, does this package is impacted by the recent log4j vulnerabilities?\nMy knowledge of this particular module is limited so I'm hoping somebody here is a bit more familiar.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":573,"Q_Id":70755261,"Users Score":3,"Answer":"It's not affected (disclosure: I'm the maintainer of Python logging), because Python logging is not a direct port of log4j, just influenced by it (in part). There are no equivalents in Python logging to the JNDI functionality built into log4j, that led to the vulnerabilities in it.","Q_Score":0,"Tags":"python,logging,log4j,cve-2021-44228","A_Id":70756477,"CreationDate":"2022-01-18T11:58:00.000","Title":"Python logging module & indirect log4j vulnerability exposure?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"when i works with coverage i see that when i want to run test with it i must code for example like \"coverage run manage.py test src.apps.accounts.tests \" in terminal and when i want see the result i must write \"coverage report --include=src\/apps\/service\/accounts\/* -m \" .my question is why we use \". \" for run and use \"\/ \" for see the result? and in general when we should use \".\" and when we should use \"\/\" (this example did not only one case i see so i want a way to understand when should use each other of them)\n*in advance i am tank you for get me full solution and read the my question that write with my weak english understand.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":43,"Q_Id":70784035,"Users Score":0,"Answer":"\".\" is the pythonic way of writing paths, \"\/\" is for general purpose\nWhen you are including apps in your settings.py, you will write it with \".\"\nWhen you are saving a file on your computer (with notepad or any other software), you will use \"\/\"","Q_Score":0,"Tags":"python,django,path,filesystems,test-coverage","A_Id":70785125,"CreationDate":"2022-01-20T09:51:00.000","Title":"Different structure path of python base program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"After running pip3 install python-telegram-bot in command prompt, I get 'telegram' module is not found when I run python -m telegram after the installation.\nI have Python 3.9 and 3.10.1 installed, and it seems like the package is installed in the Python 3.9 directory as the output during the installation shows ...pythonsoftwarefoundation.python.3.9\nI am new to programming, so I am at a lost as to how to install it for Python 3.10.1. Appreciate any guidance I can get.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":181,"Q_Id":70810485,"Users Score":0,"Answer":"Since you installed the module through pip3 there is a chance you just need to use python3. Try python3 -m telegram.\nOpposite it might be that you need to use pip install python-telegram-bot for it to work with python.\nUsually pip is linked to python and pip3 is linked to python3 but it is only a guideline, not a rule.\nIf that doesn't work you can always invoke pip for the other python binary with python -m pip install python-telegram-bot","Q_Score":0,"Tags":"python,python-3.x,python-telegram-bot","A_Id":70810553,"CreationDate":"2022-01-22T06:23:00.000","Title":"How do I install python-telegram-bot to python 3.10.1?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"The title says it all. It seems better and faster to use one of the methods belonging to gevent.Pool to run greenlets in parallel (sort-of) in a pool, as opposed to gevent.joinall(). What are the pros and cons of each approach?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":37,"Q_Id":70819533,"Users Score":1,"Answer":"I think the key difference is not raw performance but instead performance management. When you use gevent.joinall() you have to do your own management of how many greenlets exist at once. The naive implementation would create as many as might be needed by the request for the computation.\nOn the other hand gevent.Pool can easily be configured to cap how many are running at once and thus protect against running your application out of resources.\nAs usual, it's tradeoffs. Your pool may run slower because it potentially won't allow as many greenlets to run as would a naive implementation using gevent.joinall(), however, you are less likely to run your application out of resources (and cascade into other errors).\nUltimately you have to answer questions like this: Are you likely to get too large of requests? Do you have plenty of resources to draw from? Is raw peak performance more important than average reliability?","Q_Score":0,"Tags":"python,multithreading,pool,gevent,greenlets","A_Id":70835681,"CreationDate":"2022-01-23T05:59:00.000","Title":"Why Use gevent.joinall() Instead of pool.imap_unordered() to Run Greenlets?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a username and password I built from scratch, this works fine until I thought, people forgetting their password.\nI would like to find a way to check when a url has been visited to then change the password for urls like \"example.com\/fp?id=\" that has been sent by email.\nI cannot use the flask-security module at this point due to the way I have created the databases and how its integrated into my website.\nYes I have looked, and it seems most ways require using flask-login and flask-security, thanks for any answers in advance :)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":47,"Q_Id":70841502,"Users Score":0,"Answer":"Fixed! I just sent an email using smptlib and determining the id using that","Q_Score":0,"Tags":"python,email,flask,jinja2,confirm","A_Id":70893762,"CreationDate":"2022-01-24T22:59:00.000","Title":"Flask Email Conformation For Password Reset","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a telegram bot written using telebot(pytelegrambotapi) and it has a line of code that closes the programs os.system('taskkill \/F \/IM test.exe \/T') but after that the console is displayed [the process exited with code 1] and the bot is not responding to my messages.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":31,"Q_Id":70878089,"Users Score":0,"Answer":"This line of code kills process of your bot. If your problem in that -remove this line, if you want to stop the script - replace this line to exit()","Q_Score":0,"Tags":"python,operating-system","A_Id":70999452,"CreationDate":"2022-01-27T11:50:00.000","Title":"Telebot taskkill","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am testing a React Native app using Appium in Python. This is the first time seeing that the app responds too slow with Appium but works completely fine while testing manually. Any idea on how to improve speed of tests?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":140,"Q_Id":70893889,"Users Score":0,"Answer":"One way to improve test speed is use a modern device. For your issue, because the app runs well without also running appium doesn't mean the device is not the culprit. Appium does run on the device while also running the app, so the device needs to be able to run both the app and other apps at the same time well to be able to run smooth appium tests.","Q_Score":1,"Tags":"python,appium,ui-automation","A_Id":70900023,"CreationDate":"2022-01-28T12:34:00.000","Title":"Appium gets too slow while testing React Native app","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a lambda function lambda1 that gets triggered by an API call and computes the parameters for another job downstream that will be handled by a different function lambda2.\nThe resources required to complete the downstream job are not available immediately and will become available at some future time datetime1 which is also calculated by lambda1.\nHow do I make lambda1 schedule a message in an SNS topic that will be sent out at datetime1 instead of going out immediately? The message sent out at the correct time will then trigger lambda2 which will find all the resources in place and execute correctly.\nIs there a better way of doing this instead of SNS?\nBoth lambda1 and lambda2 are written in Python 3.8","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":121,"Q_Id":70936176,"Users Score":1,"Answer":"You would be better off using the AWS Step Functions. Step functions are generally used for orchestrating jobs with multiple Lambda functions involved and they support the wait state that you need to run a job at a specific time.\nBasically, you will create multiple states. One of the states will be wait state where you will input the wait condition (timestamp at which it will stop waiting). This is what you will send from Lambda1. The next state would be task state which will be your Lambda2.","Q_Score":0,"Tags":"python-3.x,amazon-web-services,aws-lambda,amazon-sns","A_Id":70937211,"CreationDate":"2022-02-01T06:05:00.000","Title":"AWS Send SNS message from lambda at a specified time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I try to edit the Roles from a Member trough the member.edit(roles = list_of_roles) command. For the most Users this works just finde, but for some the I get the Error discord.ext.commands.errors.CommandInvokeError: Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions altrough the bot HAS the heighest role on the Server AND admin rights. (No the Role that I try to remove\/add is NOT highter or at the same Level as the bot role) Is there anything I might missed? because I dont understand why he cant remove the roles from some members (the members dont have admin rights).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":128,"Q_Id":70945500,"Users Score":0,"Answer":"After many hours I found out, you cant remove the booster role. This is why \u00edt doesn't work how it should.","Q_Score":1,"Tags":"python,discord,discord.py","A_Id":70957201,"CreationDate":"2022-02-01T18:14:00.000","Title":"Discord.py missing permissions error with permissions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created a NamedTemporaryFile in my python program with the parameter delete=False because I wanted to keep it for testing. However in the process of testing and running the program over and over it sometimes did not reach the point where the tempfile was closed and\/or its path logged so I could delete it manually.\nIs there a way to find out where these files are stored? Will they clog up my hard drive or does python choose a directory which is cleaned by my os? The documentation does not talk about this.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":41,"Q_Id":70958593,"Users Score":0,"Answer":"tempfile.gettempdir() gives the directory and\ntempfile.gettempprefix() gives the prefix of the tempfile names to distinguish them from other files in the directory.","Q_Score":0,"Tags":"python","A_Id":70958673,"CreationDate":"2022-02-02T15:45:00.000","Title":"Find undeleted tempfiles in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python script that when run it will automatically send an email to a user using python's smtplib package. It runs on 2 conditions from a sql query, if they have a new customer or if they havent spoken with their customer in a long time (sends a reminder to call them) I could see our team requesting this check to be run on a daily basis, but what if a user already received an email? It would probably be annoying to get the same email over and over again.\nI was wondering if theres someway that I can capture if a user was sent an email or not? I am not sure what that would look like in python? I am thinking I probably will have to create some sort of a database that tracks when an email was sent or not, otherwise how would the program know if something was sent last run. The problem with the database solution is that I dont have the power to update tables (we depend on another department to manipulate our snowflake tables)\nIf anyone has any thoughts that would be helpful, thanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":41,"Q_Id":70964927,"Users Score":0,"Answer":"If I understand, you don't need to know when the email was sent successfully, you need to know when your email was correctly received.\nThey look similar, but they are different.\nThe Offen marketing campaign uses this approach, because for them:\n\nOK = user opened the email\nKO = all other situations (SPAM, not\nopen,....)\n\nIf you need something like this, I propose you solve it at the application level (as other solutions work). Like?\n\nYou can put the image, hosted on some server, in the email.\nWhen the user opens their email this image will be loaded.\nOn your server you can configure a trigger (to be executed when this\nURL is called) to do some UPDATE on the database to ensure the user\nhas opened their email.\n\nPS:\nI use an image as an example, but you can use anything else.\nPS:\nAdmittedly, this URL must be unique per user (URL or query string)","Q_Score":1,"Tags":"python,sql,database","A_Id":70967956,"CreationDate":"2022-02-03T01:28:00.000","Title":"Check if an email has been sent to a user on the previous day","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use iTerm2 as my default terminal app in OSX. A would like to ask if is possible to insert text automatically with a hotkey (or selecting it from a menu), with iTerm, like the old macros of some word processing packages. My idea is, for example, if I press cmd + ctrl s , iTerm insert automatically \"sftp -i\"\nI know that iTerm has support for scripting with AppleScript and Python but I'm not sure how I do this","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":163,"Q_Id":70971049,"Users Score":0,"Answer":"You can also use Keyboard shortcuts.\nFrom Preferences -> Keys\nDefine a new shortcut and use the \"Action\" \"Send Text\"\nThis works on iTerm2 build 3.4.15","Q_Score":1,"Tags":"python,scripting,applescript,iterm","A_Id":72213801,"CreationDate":"2022-02-03T12:10:00.000","Title":"Is it possible to create a macro \/ script in iTerm2 that insert text automatically selected from a list?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have to analyze a set of bgp-update-files using python and the pybgpstream with a given routing table file. My task is to analyze these update files regarding prefix hijacking events. As far as I know, analyzing these files means to look for all ASs that advertise prefixes that do not belong to them and list those events.\nMy current code just allows me to go through the directory and check all update files for prefixes and as-paths. Since I do not know how to use the routing table file (ground truth) in pybgpstream, i cannot go any further into analyzing the prefix ownership.\nHas anybody a idea, how to check, whether a prefix belongs to a specified AS?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":84,"Q_Id":70974225,"Users Score":0,"Answer":"Think about what part of AS-Path called origin. Fix research results:\n\nThe last AS along the path to the prefix is considered to be the\norigin AS\n[https:\/\/www.cs.colostate.edu\/~massey\/pubs\/conf\/massey_imw01.pdf]\n\nLittle hint try to use scientific search engines additionaly to google ;)","Q_Score":0,"Tags":"python,network-security,bgp","A_Id":71196103,"CreationDate":"2022-02-03T15:45:00.000","Title":"identify potential prefix hijacking events in BGP update data using Python and pybgpstream","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Excuse me if this post should be on a forum other than stack overflow.\nOn a linux cluster I am running a python script 24\/7 to connect to a data stream, process it, and push it to a database. A crontab file is setup to monitor that the script is running and if it stops it will be started again.\nI need to edit the script and test it, so created a git branch for that. I want to make sure that if the original script (on branch main) stops, the crontab will run it and not the modified file on the new branch.\nMy two questions are:\n\nDoes crontab run scripts on main (or master) by default?\nHow can I specify the git branch of file I want to run when calling it? (Mostly for verbosity)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":52,"Q_Id":70977997,"Users Score":1,"Answer":"Crontab will run on a file, so, whatever state the local repo is in, whether it's updated with main\/master or pulled to another branch, or edited locally, it will run that file.\nIf you want to explicitly run a particular branch, my advice is to point cron at a separate script, which could take the branch as a parameter, that will then prepare the script location however you want, and subsequently run it.","Q_Score":0,"Tags":"python,git,cron","A_Id":70978168,"CreationDate":"2022-02-03T20:41:00.000","Title":"Will crontab run scripts on git branch master or main by default?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I created a telegram robot that forwards video files by selecting Start. And I want them to be deleted automatically after 1 hour. Can anyone help me?\ncontext.bot.sendDocument(chat_id=update.message.chat_id, document='https:\/\/t.me\/mychanel\/2',caption=\"1\")\ncontext.bot.sendDocument(chat_id=update.message.chat_id, document='https:\/\/t.me\/mychanel\/3',caption=\"2\")\ncontext.bot.sendDocument(chat_id=update.message.chat_id, document='https:\/\/t.me\/mychanel\/4',caption=\"3\")\nhow can I delete auto those?\u261d\u261d\u261d\u261d","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":76,"Q_Id":70997774,"Users Score":0,"Answer":"You can do\nmessage =context.bot.sendDocument(chat_id=update.message.chat_id, document='https:\/\/t.me\/mychanel\/2',caption=\"1\")\nAnd save the message.message_id with a timestamp in a data structure, list or dict, after that you can schedule a periodic thread that do\nbot.delte_message(message_id,chat_id) on the expired videos","Q_Score":0,"Tags":"telegram,telegram-bot,python-telegram-bot","A_Id":71002656,"CreationDate":"2022-02-05T11:56:00.000","Title":"deleted automatically telegram bot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using telethon to scrape members from a group, I can filter out active and non-active members but when adding members to another group I mostly get UserPrivacyRestrictedError.\nbecause of that I usually get PeerFloodError after few request. is there a way to get participants that does not have privacy enabled?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":118,"Q_Id":71018733,"Users Score":0,"Answer":"No. You can only find that out by trying to perform that action.","Q_Score":0,"Tags":"python,bots,telegram,telethon","A_Id":71039307,"CreationDate":"2022-02-07T12:40:00.000","Title":"Telethon check if user has privacy settings enabled","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have multiple rabbitmq queue which recieve the message. I recently add 2 more queue in my file but when i run that reciever script through nohup, it is not able to consume the message although in background script is running. when i run the same script by python script.py It is working fine. My all previous rabbitmq reciever queue is working fine with nohup. My nohup command to run\nthe script is nohup python script.py >> script-rabbit-reciever-app.log 2>&1 &. Is there any limitation of how many process we can run through nohup?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32,"Q_Id":71048215,"Users Score":0,"Answer":"There is a limit on nohup which is a single command (in this case is just is python). You are limited in the number of instances in nohup which is the same as any other process in linux. You can see the process limit for a user in most common shells with ulimit -u","Q_Score":0,"Tags":"python,linux,rabbitmq,nohup","A_Id":71048749,"CreationDate":"2022-02-09T10:48:00.000","Title":"RabbitMq is not consuming the message when running the script through nohup","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Error Trace:\nImportError: \/lib\/arm-linux-gnueabihf\/libc.so.6: version `GLIBC_2.33' not found (required by \/home\/pi\/.local\/lib\/python3.7\/site-packages\/grpc\/_cython\/cygrpc.cpython-37m-arm-linux-gnueabihf.so)\nScenario:\nI'm using google cloud vision api to detect text in images. The program works fine on laptop but gives the above mentioned error when ran in raspberry pi. I've searched a lot but couldn't find any working solution. I'd really appreciate if any one could let me know how to solve this.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1957,"Q_Id":71054519,"Users Score":1,"Answer":"GLIBC and the kernel of the OS go hand-in-hand; you basically need a newer version of your OS, if you need a more recent GLIBC\nthe version of the GLIBC can be quickly found out with the following command:\nldd --version","Q_Score":4,"Tags":"python,raspberry-pi,glibc,libc,google-cloud-vision","A_Id":71055926,"CreationDate":"2022-02-09T18:02:00.000","Title":"GLIBC_2.33 not found in raspberry pi python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"We have got microservice application deployed in Kubernetes cluster. We need to run the locust load test tool on the Kubernetes cluster and send the metrics to Prometheus. How to get the locust loadtest data to Prometheus in the Kubernetes cluster environment.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":66,"Q_Id":71062315,"Users Score":0,"Answer":"If you already have metrics sent to prometheus in your service then any load-test will trigger these just like any other rest calls.","Q_Score":0,"Tags":"python,kubernetes,microservices,prometheus,locust","A_Id":71109600,"CreationDate":"2022-02-10T09:01:00.000","Title":"How to get the locust loadtest data to prometheus in the kubernetes cluster environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to save mail via Python and get this error\n\n-2147352567, 'Exception occurred.', (4096, 'Microsoft Outlook', 'Unable to write to file: C:\\...\\ docs. Right-click the folder containing the file you want to write to, and then select 'Properties' from the menu and check your permissions for this folder.'\n\nAccount has all the permissions and access to the folder.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":85,"Q_Id":71069259,"Users Score":1,"Answer":"Please show your code. Make sure you pass a fully qualified file name that includes both the path and the file name, not just a path or a file name. It looks like you are only passing the path (C:\\docs).","Q_Score":0,"Tags":"python,file-io,outlook,win32com","A_Id":71070610,"CreationDate":"2022-02-10T17:01:00.000","Title":"Error saving e-mail from outlook via Python win32com.client: Unable to write to file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to save mail via Python and get this error\n\n-2147352567, 'Exception occurred.', (4096, 'Microsoft Outlook', 'Unable to write to file: C:\\...\\ docs. Right-click the folder containing the file you want to write to, and then select 'Properties' from the menu and check your permissions for this folder.'\n\nAccount has all the permissions and access to the folder.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":85,"Q_Id":71069259,"Users Score":0,"Answer":"The system drive C:\\ requires admin privileges for writing. Try choosing another drive or folder.","Q_Score":0,"Tags":"python,file-io,outlook,win32com","A_Id":71069323,"CreationDate":"2022-02-10T17:01:00.000","Title":"Error saving e-mail from outlook via Python win32com.client: Unable to write to file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"how can I run the telegram auto message bot when I turn off my computer with the API I made with python?\nOtherwise, it exits the terminal and the bot closes automatically.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":45,"Q_Id":71082428,"Users Score":0,"Answer":"Are you asking why when your computer turns off, and the python file stops running, the bot no longer functions?\nYou would need to have either a server or another device to run it then, should you wish to turn your computer off\nI'm not sure if I misunderstood this or not.","Q_Score":0,"Tags":"python,telegram,telethon,py-telegram-bot-api","A_Id":71082488,"CreationDate":"2022-02-11T15:17:00.000","Title":"How can I use the Telegram automatic message bot when I am not there?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a threaded timer running to disconnect from p4 after a certain amount of time (because perforce will auto timeout in our application and fails to reconnect). I want to make sure that I do not disconnect if any long action is running (like downloading a large file). Are there any p4 commands that can check if there are currently commands being run.\nThanks","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":14,"Q_Id":71087011,"Users Score":1,"Answer":"You can run p4 monitor show to check from the server side if any commands are running.\nFor your use case, though, it would be more straightforward for your script to simply keep track of its own run() calls, since anything you care about will take place in the context of one of those calls. It's generally good practice to close your connection once you're done invoking commands with run(), since holding idle connections open can potentially DDoS the server if enough client instances do it.","Q_Score":0,"Tags":"python,perforce,p4python","A_Id":71089920,"CreationDate":"2022-02-11T22:04:00.000","Title":"p4python check if any actions are being run","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm making a music bot for my discord server and I want it to run 24\/7 on repl.it but when I run it on my computer I add executable=\".\/ffmpeg.exe\" to the from_probe function. Nevertheless, replit doesn't support executable files so I need to find an other way to make this work. I tried installing ffmpeg package, I also looked up for tutorials how to use ffmpeg-python with youtube_dl. None of these worked. If you need some additional info, just ask me in the comment section.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":160,"Q_Id":71104685,"Users Score":0,"Answer":"It's not possible on replit. FFmpeg was working on replit before, it does not work now, you possibly could find another module to play music.","Q_Score":0,"Tags":"python,ffmpeg,discord.py,youtube-dl,replit","A_Id":71295381,"CreationDate":"2022-02-13T20:42:00.000","Title":"How to run a music bot on replit (discord.py)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Unlike earlier version 3 releases nowadays building Python 3.10 from source does not seem to run the (time-consuming) tests.\nI need to build Python 3.10 on an oldish platform (no, I can't change that). I would actually like to run the tests, even if they are time consuming.\nUnfortunately, I can't find the way to do it. Googling shows nonsensical results (how to do testing while using Python, unittest etc), while .\/configure --help doesn't show anything.\nHave the tests been removed? If not, how can I enable them?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":71113146,"Users Score":0,"Answer":"Building from source make -j 4 prefix=\"\/usr\" usually does the tests too. At least that's what I've observed.","Q_Score":0,"Tags":"python,compilation,python-3.10","A_Id":71119777,"CreationDate":"2022-02-14T14:04:00.000","Title":"How to run tests while building Python 3.10+ from source?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to replace text in PDF\nWe have a huge amount of PDFs (900k +)which needs some text replacement, only on first page\n\nName, Address email and number\n\nI have tried many solutions with Python and Perl as well but I landed into different errors, \"index not found\", \"codec cant decode\" etc.\nThe only solution that worked so far is asposepdfcloud api. which is a cloud based api and I dont know what's happening behind. and We cannot process our files via external API due to privacy concerns\nI was wandering if there is something similar like this.\nI also have a bot using uipath, which opens the PDF file in Acrobat pro and do search and replace and then save the document, but this whole process takes around 1 min for 1 file at least. So this is not a suitable solution for the huge amount of files.\nAny help would be appreciated.\nP.S. Its not currently possible to replace text before creating and regenerate all PDFs again.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":69,"Q_Id":71140089,"Users Score":1,"Answer":"One of the possible ways to solve this problem is to find the section you want to replace using \"regex\". Then using one of the libraries for pdf editing (such as \"pdfplumber\") in python to replace this section.\nErrors you are getting are possible to be handled. If it does not bother privacy I can take a look at one of these PDFs and provide a more detailed solution.","Q_Score":0,"Tags":"javascript,python,perl,pdf","A_Id":71140209,"CreationDate":"2022-02-16T10:27:00.000","Title":"Replacing text in PDF","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So i don't have any code to show because this isn't a code issue.\nI have my pathing for Python set to this:\nC:\\Users\\USERNAME\\AppData\\Local\\Programs\\Python\\Python310;C:\\Users\\stone\\AppData\\Local\\Programs\\Python\\Python310\\Scripts\nbut in command prompt it still paths:\nC:\\Users\\USERNAME>\nand delivers a \"errno 2\" error whenever I try to run a file. The only way I have gotten files to actually launch is to move the .py folders to the username folder.","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":42,"Q_Id":71146543,"Users Score":-1,"Answer":"I had this issue before in the past and what I ended up doing is reinstalling python and making sure to hit the \"add to path\" option. Sorry I don't have a better way but that is what worked for me.","Q_Score":0,"Tags":"python,path","A_Id":71146581,"CreationDate":"2022-02-16T17:27:00.000","Title":"Python Pathing Issue","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm reading that using Redis Pipeline could improve performance by sending a batch of commands to the Redis server rather than sending separate messages one by one which could add up in latency time. In this way, there is a rough correlation between the number of separate commands that you have in a pipeline batch and how much you improve in speed. My question is that, is there an overhead or a downside to using Redis Pipeline that would make it not worth it in certain situations, especially when there are just a few simple commands that are being executed not so often? I understand the actual improvement in these cases would be very marginal, but I'm wondering if using Pipeline could worsen the execution time actually by introducing some sort of overhead?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":45,"Q_Id":71149506,"Users Score":0,"Answer":"The overhead of pipeline is that Redis needs to queue replies for these piped commands before sending to client, i.e. cost memory. So, normally, you'd better not create a huge pipeline.\nIn your case, since your pipeline only has a few simple commands, it's not a problem.","Q_Score":0,"Tags":"python,redis,query-optimization,py-redis","A_Id":71151071,"CreationDate":"2022-02-16T21:29:00.000","Title":"Is it any downside or overhead to Redis Pipeline for executing small set of commands?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"How are you guys?\nSo to get straight to the point I wanted to create a Discord bot using Python but the thing is that when I want to install the discord module using pip by typing pip install discord but since I'm using a PC without admin rights I have an error saying that it can't launch this program (pip)\nSo I'm here to ask if anyone knows how can I install the Discord module in python without pip ?\nThanks in advance!\n~Sami","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":72,"Q_Id":71164527,"Users Score":0,"Answer":"It depends on which IDE you are using\nFor example, you can download pycharm if you don't already have it and you can download the package from pycharm itself.\nHow you can do that is going to file \u279c Settings \u279c Project \u279c Python Interpreter \u279c and click the + sign over the package label and there you will be able to search for any package you want like discord.py","Q_Score":0,"Tags":"python,module,pip,discord,discord.py","A_Id":71164657,"CreationDate":"2022-02-17T19:48:00.000","Title":"How can I add the Discord module in python without using pip?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have tried to pip install two modules recently (ta and python-binance) however when I try to import both modules I get an error message(e.g ModuleNotFoundError: No module named 'ta').\nI'm new to python and coding in general so it' probably a simple fix but I can't figure out what I am doing wrong.\nAny help??","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":71173591,"Users Score":0,"Answer":"Do you run it with your system default python installation?\nMaybe you run it with another version\/installation\/venv as the system default.\nBecause if you use pip install ... you install it for the python version that is in your environment variables","Q_Score":0,"Tags":"python,installation,module,pip","A_Id":71173633,"CreationDate":"2022-02-18T12:35:00.000","Title":"Module not being found","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to run a face detection model in Unity. It gets input from the webcam, then spits out a face. But trying to make this work with C# has been an absolute nightmare. And despite all my suffering, I still haven't been able to make it work!\nIf I could use python, I'd be able to get it done easily. So, obviously, I want to find a way to get a python script working in Unity. But IronPython is the only thing I've been able to find, and it's outdated.\nI need either knowledge of how to make IronPython work in spite of being outdated, or some other method. Please.","AnswerCount":3,"Available Count":2,"Score":-0.0665680765,"is_accepted":false,"ViewCount":640,"Q_Id":71179346,"Users Score":-1,"Answer":"You can just run your python script on playtime and let it create some data in files. Then read the files using C# and display data in Unity.","Q_Score":1,"Tags":"python,unity3d","A_Id":71183873,"CreationDate":"2022-02-18T20:11:00.000","Title":"How do to use a python script in Unity?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to run a face detection model in Unity. It gets input from the webcam, then spits out a face. But trying to make this work with C# has been an absolute nightmare. And despite all my suffering, I still haven't been able to make it work!\nIf I could use python, I'd be able to get it done easily. So, obviously, I want to find a way to get a python script working in Unity. But IronPython is the only thing I've been able to find, and it's outdated.\nI need either knowledge of how to make IronPython work in spite of being outdated, or some other method. Please.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":640,"Q_Id":71179346,"Users Score":0,"Answer":"Unity not supported python, But you Can write Python Code and run it by Socket programing, Create Server with python and send data,in C# Connect to server and use data sended with python.","Q_Score":1,"Tags":"python,unity3d","A_Id":72337608,"CreationDate":"2022-02-18T20:11:00.000","Title":"How do to use a python script in Unity?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am developing an application on a remote server.\nI'm using Python and am connected via ssh with the specific extension.\nI start debugging and everything seems to proceed normally but suddenly debugging stops and there is no reason (error or warning).\nCan anyone suggest me where to look for the reason or how to trace the problem?\nThe script, executed outside VSCode, runs smoothly.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":35,"Q_Id":71213332,"Users Score":0,"Answer":"in the end I found a possible cause and, therefore, the solution.\nThere is a problem with the sequence of imports and module import for MariaDB. By moving this import to the head, the problem was solved.","Q_Score":0,"Tags":"python,debugging,visual-studio-code,ssh,exit","A_Id":71430912,"CreationDate":"2022-02-21T21:39:00.000","Title":"VSCode Python SSH - Debug aborted without errors or warnings","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a script that I run locally on my laptop, which polls a server and if certain criteria are met, it sends an email. I guess like a heartbeat app of sorts.\nThe server is a Raspberry Pi, it has a public IP address which is all working fine.\nId like to host the python script on Heroku, so that it can run without my laptop having to be on the local network or always running.\nDoes anyone have experience of Heroku to show me how I can have the script hosted and running constantly?\nMy other query is that free tiers of Heroku go to sleep after 30 mins, so would essentially stop the script until getting an http request and spin up the instance once again.\nTrying to find some form of elegant solution.\nMany thanks for any advice you can give,\nAll the best,\nSimon","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":28,"Q_Id":71214164,"Users Score":1,"Answer":"Different approachs would be:\n1- Cloud Functions\n\nCreate lambda function in a cloud provider with your python code (free tier elegible)\nTrigger that function every once in a while\n\n2- Get VM on Cloud\n\nGo to AWS, GCP, etc\nGet a free tier VM\nRun server from there","Q_Score":0,"Tags":"python,heroku","A_Id":71214221,"CreationDate":"2022-02-21T23:21:00.000","Title":"Heroku - Python integration","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"If I create a variable file (var.py) and start my robot test:\n\nrobot --variablefile var.py[:set1] .\\test_this.robot\n\nHow can I use this variables in my other file (settings.py) what is called from Robot Framework test?\nThe goal is to start test and enter the environment I want to use (get from var.py file) and use that selection in settings.py\nDo I need to pass the selection with parameter when calling settings.py file or can I use\/read the var.py file directly from settings.py?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":116,"Q_Id":71217198,"Users Score":0,"Answer":"I solved this by using this in .robot\nRun Keyword If '${VAR}' == 'a' Import Variables ${CURDIR}\/var_a.py\nAnd this in .py\nBuiltIn().get_variable_value('${DBHOST}')","Q_Score":0,"Tags":"python,robotframework","A_Id":71231831,"CreationDate":"2022-02-22T07:09:00.000","Title":"Variable file usage with Robot Framework and Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to make the switch from AWS Lambda warmup (calling the function every 5 minutes) to provisioned concurrency as I was told it's a better way to avoid cold starts.\nNevertheless, when using provisioned concurrency, my script is going through all packages imports, which makes the latency quite important. For the same lambda function in two different environments, one using warmup and one using provisioned concurrency, the one using warmup executes in less than 1s when the other one takes almost a minute.\nAll of my imports are of course outside of the function handler, and the provisioned concurrency seems to be correctly enabled for my Lambda. To enable it I just added this line in my .yml file:\nprovisionedConcurrency: 3\nAm I missing something or provisioned concurrency is not handling libraries imports when creating containers?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":174,"Q_Id":71226694,"Users Score":1,"Answer":"How is the lambda invoked?\nprovisioned concurrency is set on lambda alias\/version (can't be set on $LATEST). In serverless framework, provisionedConcurrency: 3 will configure provisioned concurrency on lambda alias \"provisioned\" (this is the default and can't be cahnged), with 3 instances.\nSo whoever calling your lambda (api gateway \/ other lambda \/ sqs \/ sns \/ etc) need to invoke the alias instance.\nIf you are not invoking the alias version, you are just invoking $LATEST which is not provisioned...\nInvoke the alias by attaching it to end of function arn: rn:aws:lambda:us-west-2:123456789012:function:my-function:provisioned or by adding qualifier parameter in relevant field","Q_Score":1,"Tags":"python,aws-lambda","A_Id":71228446,"CreationDate":"2022-02-22T18:40:00.000","Title":"AWS Lambda provisioned concurrency still results in cold start","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am running a Python program using the excellent EasyOCR module. It relies on PyTorch for image detection and every time I run it, it produces a warning: \"Using CPU. Note: This module is much faster with a GPU.\" for each iteration.\nWhat can I add to my code to stop this output without stopping other output? I don't have a GPU so that is not an option.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":207,"Q_Id":71266936,"Users Score":-1,"Answer":"I think there is a command line parameter --gpu=false. Have you tried that?","Q_Score":1,"Tags":"python,easyocr","A_Id":71267125,"CreationDate":"2022-02-25T13:55:00.000","Title":"Stop printing warning message \"Using CPU. Note: This module is much faster with a GPU.\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Python script, which connects to a data feed in the early hours of each morning, downloads a JSON data file, then moves it from where it saved it to a dedicated folder.\nWhen the script is run from the command line on the Linux Centos7 server, all works perfectly. When run through Cron (either on schedule or a run now through the Plesk Cron screen) it errors out. Having commented out the os.rename(startfile, sendfile) line the script runs perfectly in Cron.\nI thought it was todo with permissions, but if I get the same script to open a text file in the eventual destination directory that I am trying to move the datafile to, write 'JSON file downloaded ok' and close the file - that runs perfectly under CRON, so I dont think it can be permissions.\nI have run os.path.isfile(StartFile) on the datafile after downloaded (and got TRUE) and run os.path.isdir(EndFile) and got TRUE, so I know the paths are correct. I have replaced os.rename with os.replace and the same thing happens.\nWhen the script downloads it, it goes into the \/root\/ folder, as CRON runs as root. When the script exits with an error, the file is there and visible in \/root\/ and I can manually do mv file.gz to \/path\/to\/folder\/file.gz and it moves fine.\nJust CRON is having some issue with the Python file movement commands - can anyone offer any advice, I just dont know where to check next!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":33,"Q_Id":71272253,"Users Score":1,"Answer":"Thanks to @kpie in the above comments, the answer (although I suppose it is a workaround rather than a solution) was to change the working directory with os.chdir(path) before downloading the file.\nThat way the file downloads into the folder I need it in, rather than downloading and then moving it.","Q_Score":1,"Tags":"python,centos7","A_Id":71272321,"CreationDate":"2022-02-25T22:14:00.000","Title":"Python script will not move a downloaded file when run as CRON","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a requirement to Automate scripts on iOS devices using the Robot framework\/Python on the Windows platform.\nWhat are all things I required in order to achieve this task?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":146,"Q_Id":71274928,"Users Score":0,"Answer":"No you can't automate any iOS scripts from windows system . The main requirement for iOSDriver to communicate with appium scripts and to your iOS device requires xcode app . Which is not there onto windows .","Q_Score":0,"Tags":"python,ios,windows,appium,robotframework","A_Id":71292691,"CreationDate":"2022-02-26T07:46:00.000","Title":"Can iOS device automation be performed on a Windows machine using the Robot Framework?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a requirement to Automate scripts on iOS devices using the Robot framework\/Python on the Windows platform.\nWhat are all things I required in order to achieve this task?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":146,"Q_Id":71274928,"Users Score":0,"Answer":"Appium can automate iOS device tests via WebDriverAgent.\nWebDriverAgent can be run through multiple open source multi-platform tools from Windows:\n\ngo-ios\ntidevice\nothers...\n\nYou will need Xcode to first build WDA though before you can deploy it to a device. Once it is installed on the device ( until the signing expires at least ) you can run WDA from any OS ( Mac, Windows, Linux ) using the various tools.","Q_Score":0,"Tags":"python,ios,windows,appium,robotframework","A_Id":71421370,"CreationDate":"2022-02-26T07:46:00.000","Title":"Can iOS device automation be performed on a Windows machine using the Robot Framework?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I try to use the autocomplete using Pylance it is stuck there for some time\nand After Some time like 3 ~ 5 seconds the pop up with auto-complete shows up\nPython Language Server is already set to Pylance\nWhat I've tried so far.\nReinstall Python Extension.\nReinstall VS Code\nRestarted Python Language Server\nReset VS Code\nReinstall Pylance.\nBut None of the above seems to work","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":621,"Q_Id":71290916,"Users Score":0,"Answer":"Its works without problem on my computer, try Clean Uninstall Python and VSC\nmaybe you have some incorrect setting that slows down your computer or VSC performance","Q_Score":1,"Tags":"python,visual-studio-code,autocomplete,pylance","A_Id":71306173,"CreationDate":"2022-02-28T05:28:00.000","Title":"VS Code Pylance works slow with much delay","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using coc.nvim in neovim together with Pylint.\nIf I try to import my own module e.g. src.reverse_linked_list or an installed module like selenium, CoC displays the error message\n[pylint E0401] [E] Unable to import 'xxxxx' (import-error)\ndouble checked that init.py is in my directories\nRunning the code does not lead to any errors\nDoes anyone know how to fix this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":161,"Q_Id":71291601,"Users Score":0,"Answer":"The python path need to be the same when running pylint inside neovim vs when running the code. The import using src.reverse_linked_list is suspicious in this regard, src is not generally used in the import.","Q_Score":0,"Tags":"python,pylint,neovim","A_Id":71292862,"CreationDate":"2022-02-28T07:10:00.000","Title":"PyLint not recognizing modules but code runs fine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"From the docs :\n\ncppyy is an automatic, run-time, Python-C++ bindings generator, for\ncalling C++ from Python and Python from C++.\n\n(Emphasis mine)\nI don't see any instructions for doing the same, however, so is it possible to call Python via C++ using cppyy?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":114,"Q_Id":71303671,"Users Score":0,"Answer":"I'm pretty sure cppyy only allows you to call C++ via Python, not vice versa. You could use Python.h, or use C++ to execute a python file as you would an .exe file, but that would require that the computer can run python files.","Q_Score":1,"Tags":"c++,python-3.x,interop,cppyy","A_Id":71303949,"CreationDate":"2022-03-01T04:16:00.000","Title":"How to call Python from C++?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to create a python program for my Casio fx-9750GIII calculator that computes the molar mass of a given chemical formula. To do this I need more methods for strings from curses.ascii such as isalpha. Unfortunately I don't know how modules work on a non-networked device. Do I just need to download a file and put it on the calculator for an import statement to work or is there something else I need to do?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":66,"Q_Id":71315099,"Users Score":0,"Answer":"As the commenter Lecdi said, it is a native python string method, I just made the mistake of typing isalpha() without a string beforehand.","Q_Score":0,"Tags":"python,python-3.x,calculator","A_Id":71316096,"CreationDate":"2022-03-01T22:00:00.000","Title":"Python Modules on a Calculator","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm building a basic Instagram bot, and it got me wondering, how could I get to auto-run at a certain time, or when a certain condition is satisfied (eg. when there's a new file in a folder)?\nHelp much appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":26,"Q_Id":71342166,"Users Score":1,"Answer":"make a while loop and check your condition each time, suggest you to put some kind of sleep (eg. asynco.sleep() or time.sleep()) and if the condition is true then run the bot","Q_Score":0,"Tags":"python,selenium,selenium-webdriver,automation,bots","A_Id":71343448,"CreationDate":"2022-03-03T18:37:00.000","Title":"How can I get bot to auto-run at a certain time, or when a certain condition is satisfied?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to borb, which seems to me a very promising Python package.\nTrying to load a small sample of PDF documents, just to put hands on, I've found that borb can open some of them without problems; in some cases I got messages such as \"Unable to process XMP meta-data\"; yet in other cases I got assertion errors.\nThus, before posting specific issues, I'm looking for information about current limitations of borb, with reference to PDF versions, and on tools I could use first to detect files to be considered invalid PDF documents. Thanks.\nI'm using borb release v2.0.20, just cloned from GitHub, and Python 3.6.5 on Windows 10.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":73,"Q_Id":71342333,"Users Score":3,"Answer":"Disclaimer: I am Joris Schellekens, author of the aforementioned library borb.\nThe problem is that the PDF spec (ISO-32000) leaves some room for interpretation at various points throughout. That means some PDF libraries will interpret the spec in a given way, and produce documents that may not always be compliant according to other tools.\nborb tends to be very strict when it comes to PDF parsing. As soon as an error is detected, it will throw the stacktrace right back at you. Whereas other PDF software (e.g. Adobe Reader) tend to be much more forgiving in terms of what they accept as input PDF documents.\nAlthough I certainly understand your frustration at being unable to process what you perceive to be \"perfectly good PDF documents\", I assure you that processing them might lead to even more issues.\nI know for instance that there are cases where Adobe Reader tries to correct a bad PDF document, and as a result ends up corrupting the signatures in the document (very undesirable).\nIf you experience issues, and you can share the PDF, feel free to log a ticket on the GitHub repository.\nFrom the top of my head, the current limitations of borb are:\n\nsignatures\nencrypted PDF documents\nXREF not found\nsome images with transparent pixels","Q_Score":0,"Tags":"python-3.x,pdf,borb","A_Id":71363191,"CreationDate":"2022-03-03T18:51:00.000","Title":"What are known limitations of borb related to PDF versions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a testing telegram bot with some commands, but the username is not what I want.\nBut I found that the username of my bot is unable to change, thus I need to create a new telegram bot.\nIs there any method to copy all the existing commands of old bot to the new bot, instead of create all the commands again in the new bot?\nOr is there any method to change the username of the old bot?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":71351039,"Users Score":0,"Answer":"With my experience unfortunatly I say no, is not possible to copy commands from others bot and is not possible change the username of the bot, is possible only change the name of it.\nThis answer refers to the Bot API 5.7 (the latest release at the moment)","Q_Score":0,"Tags":"telegram,telegram-bot,python-telegram-bot,py-telegram-bot-api","A_Id":71353921,"CreationDate":"2022-03-04T11:54:00.000","Title":"is that possible to copy all the commands of previous telegram bot to a new bot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"[Never worked with a RPi before, absolute noob on that field]\nI want to make a desktop\/mobile app to access a program on a RaspberryPi. The only task of the app is to send a command and display the received response on an UI. It's meant only for private use, but it should also work outside my local network. So as long as I have mobile internet on the phone it should be possible to access the program with the app.\nCan I achieve this without using any kind of public website? I saw some tutorials that used Flask and other frameworks to do sth similar, but I want the access to be restricted to the app. There shouldn't be any URL I could type in my browser, that gives me access to a login page or sth like that.\nIf you know the specific term for what I am describing here or even better an article\/tutorial that features it, that would be very helpful.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":33,"Q_Id":71352651,"Users Score":1,"Answer":"You need two things for that:\n\nMake your Raspi visible to the outside world. That can typically be done by configuring port forwarding in your router. Note that this might impose a certain security risk.\n\nMake sure you have a global DNS name for your internet access. Since the IP of your router may change frequently (depending on your ISP), you need a URL or rather, a DNS entry. There exist public DNS services that can assign a DNS entry to a dynamic IP (typically for a fee). Many routers support a protocol to configure such services.\n\n\nAfter that, you can program an app that uses the given DNS entry to talk to your Pi.\nSo no, without a public URL, this is not possible, at least not over the long term. You might be able to go with the public IP of your router, but then your app may fail from one day to the next.","Q_Score":0,"Tags":"python,raspberry-pi,webserver","A_Id":71355505,"CreationDate":"2022-03-04T14:08:00.000","Title":"RaspberryPi access without public URL possible?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Here I go again on another tangent youve been so kind to help me with.\nOK...\nCall a PHP script hosted on Heroku (working fine)\nI would like that PHP script call a python script that sends an email. (Ive got the python part working fine and dont like my chances of rewriting it all in PHP)\nSo...\nOne heroku instance of PHP?\nSecond heroku instance of Python?\nThree I dont bother as Im too confused.\nHeroku has a web worker, which works when i call it using a scheduler, but I would like to call it on request.\nPossible im sure it is, dont get it no I dont.\nAny helpers??\nThanks people :)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":71366834,"Users Score":0,"Answer":"Solved it. Used multiple buildpacks on Heroku, one for PHP and the other Python. The PHP as a web process, which does a simple exec to the main python code. Worked a treat. Hopefully that helps someone work out a similar issue.","Q_Score":0,"Tags":"python,php,heroku","A_Id":71376643,"CreationDate":"2022-03-06T00:08:00.000","Title":"Python\/PHP Heroku integration","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"The documentation of coverage.py says that Many people choose to use the pytest-cov plugin, but for most purposes, it is unnecessary. So I would like to know what is the difference between these two? And which one is the most efficient ?\nThank you in advance","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":448,"Q_Id":71380024,"Users Score":1,"Answer":"pytest-cov uses coverage.py, so there's no different in efficiency, or basic behavior. pytest-cov auto-configures multiprocessing settings, and ferries data around if you use pytest-xdist.","Q_Score":0,"Tags":"python,coverage.py,pytest-cov","A_Id":71388807,"CreationDate":"2022-03-07T10:59:00.000","Title":"Coverage.py Vs pytest-cov","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hello dears Stack Overflow Community, I'm Firas and I'm doing an apprenticeship in System integration, and I have a project to build Co2 Sensor with raspberry Pi, so I was planning to connect it with azure so I can analyze the data there and maybe set a trigger alarm to notify me per Email or ms team channel when the co2 concentration in the room become high, but my problem is when I calculated the price in Azure, the estimated price was high (around 139 Euro per month).\nDoes anyone here have experience in those type of projects and is there other way to implement the project \"in cheaper way\", I will be very thankful if someone can guide me and give me suggestions and solutions.\nThank you very much in advance","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":71429240,"Users Score":0,"Answer":"Why don't you deploy an \"alarming system\" on RPI itself?\n(If you don't want to use rpi, I highly recommend Scaleway Stardust as a solution. It's only about 2.5 EUR per month)","Q_Score":0,"Tags":"python,azure,azure-iot-hub","A_Id":71429346,"CreationDate":"2022-03-10T18:44:00.000","Title":"Raspberry PI and co2 sensor (CCS811)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"So you know how all coding languages usually have a terminal command to run it, like this:\npython3 main.py\nAnd then it runs whatever is in 'main.py'? I'm trying to make something similar to that, except it's for txt files, so when you run:\nCUSTOM greeting.txt\nIt will tell Python to read everything in greeting.txt, so if 'Hello' is in greeting.txt, and you run CUSTOM greeting.txt, it will print out 'Hello' in terminal. Any help is appreciated!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":27,"Q_Id":71473284,"Users Score":0,"Answer":"In your example case, alias CUSTOM=cat in your shell to have cat do the heavy lifting, but in general, yeah, just like Python or any other program can read command line arguments, so could your hypothetical interpreter.\nIf you were to implement your language in Python, I'd tell you to look at sys.argv...","Q_Score":0,"Tags":"python,shell","A_Id":71473334,"CreationDate":"2022-03-14T19:34:00.000","Title":"Is there a way to make your own custom terminal command via .sh and .py?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to create my first Twitter bot using Python.\nIts job is to check twitter for new tweets that meet a certain condition, and then to retweet that post.\nHowever, the program keeps finding old posts that meet that condition, but I'm only interested in tweets posted AFTER the bot starts.\nIs there something I can do about this?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":113,"Q_Id":71483626,"Users Score":1,"Answer":"Streaming with Twitter API v1.1 or v2 will only return new real-time Tweets.","Q_Score":0,"Tags":"python,twitter,bots,streaming,tweepy","A_Id":71486570,"CreationDate":"2022-03-15T14:05:00.000","Title":"How can I stream only NEW tweets with tweepy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to create my first Twitter bot using Python.\nIts job is to check twitter for new tweets that meet a certain condition, and then to retweet that post.\nHowever, the program keeps finding old posts that meet that condition, but I'm only interested in tweets posted AFTER the bot starts.\nIs there something I can do about this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":113,"Q_Id":71483626,"Users Score":0,"Answer":"I found a way to do this.\n1a. I used datetime module to get my current system time\n1b. I converted this to a string and pulled only the date and time\n2a. I collected the tweet timestamp for each tweet \"tweet.created_at\"\n2b. I converted this to a string and pulled only the date and time\n3. For each tweet that was found by Stream service, I checked to see if it was older than my current date.\n4. If it was, I skipped it and went to the next.\nFrom my search, I think this is the only way to do this.","Q_Score":0,"Tags":"python,twitter,bots,streaming,tweepy","A_Id":71485554,"CreationDate":"2022-03-15T14:05:00.000","Title":"How can I stream only NEW tweets with tweepy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"As a physics student, I have a questions I would like to ask you about program runtime.\nI'm doing a small project about algorithm optimization, my toy code is written on jupyternotebook, but when I use %%time and %%timeit in cell to test cpu time and wall time of my code, I found the following results\nCPU times: total: 2min 16s\nWall time: 24.2s\nThe huge gap between these two times makes me wonder, my confusion is\n\nWhich should I use as the standard to measure the speed of the algorithm, although I know that it is not reasonable to use python to measure the speed of the code\nWhy the time gap between these looks so big?\n\nReally looking forward to any insights from kind people on this issue","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":121,"Q_Id":71510202,"Users Score":1,"Answer":"First, what is Wall time : it's the total time needed to run the cell.\nSecondly, the CPU time is the time spend by the CPU, counting the different cores.\nFor example, if I have a cell that require a wall time of 1 second. If this cell uses during the entire time 2 cores, we will get a CPU time of 2s.\nFor your second question, what your results seems to indicate is that you are using along your calculus an average of 5.6 cores. And you are probably using some modules that uses numba to parallelize as it's the most commonly found in physics.\nComing back to your first question, I would advice your to run your cell with the profiler using %prun this way you will know where your program spend the more time and which parts needs to be optimize.","Q_Score":1,"Tags":"python,jupyter-notebook,cpu-time,wall-time","A_Id":71510628,"CreationDate":"2022-03-17T09:49:00.000","Title":"Problem about cpu time and wall time in jupyternotebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"As a physics student, I have a questions I would like to ask you about program runtime.\nI'm doing a small project about algorithm optimization, my toy code is written on jupyternotebook, but when I use %%time and %%timeit in cell to test cpu time and wall time of my code, I found the following results\nCPU times: total: 2min 16s\nWall time: 24.2s\nThe huge gap between these two times makes me wonder, my confusion is\n\nWhich should I use as the standard to measure the speed of the algorithm, although I know that it is not reasonable to use python to measure the speed of the code\nWhy the time gap between these looks so big?\n\nReally looking forward to any insights from kind people on this issue","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":121,"Q_Id":71510202,"Users Score":1,"Answer":"1 - CPU times can be subdivided into several times, if you don't know exactly how CPU time was subdivided you should use wall time aka Elapsed real-time.\n2 - They can be many reasons for the huge gap: CPU time contains: Idle time, waiting time for systems resources to be available, etc... whereas wall time if only : finish date - starting date","Q_Score":1,"Tags":"python,jupyter-notebook,cpu-time,wall-time","A_Id":71510682,"CreationDate":"2022-03-17T09:49:00.000","Title":"Problem about cpu time and wall time in jupyternotebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a project that requires the python 3.10 version but am having some difficulty accessing the files on that version. These files have the '.tiff' extension and contain metadata information about multispectral bands like resolution, band number, etc. I was able to import the files using the rasterio module in 3.9 version but couldn't get it to work on 3.10 and couldn't find another module perform the task. I would appreciate any advice on this, thanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":58,"Q_Id":71514462,"Users Score":0,"Answer":"Try using : pip install whatever_you_want\nIn the shell. It resets the package and it should work.\nlike: if you want to install \u2018Replit\u2019 just do pip install replit in the command shell","Q_Score":0,"Tags":"python,raster","A_Id":71514591,"CreationDate":"2022-03-17T14:55:00.000","Title":"Import raster files into Python 3.10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"import pytesseract\nimport PIL\nfrom PIL import Image\npytesseract.pytesseract.tesseract_cmd = r'C:\\Program Files\\Tesseract-OCR\\tesseract.exe'\nIm trying that code alone with many other ways to type the pile path as in double '\\' etc but I still continue to get the error:\nModuleNotFoundError: No module named 'PIL'","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":37,"Q_Id":71540797,"Users Score":1,"Answer":"pip install --upgrade --force-reinstall Pillow\nresolved my issue","Q_Score":0,"Tags":"python,python-imaging-library,python-tesseract","A_Id":71541175,"CreationDate":"2022-03-19T18:13:00.000","Title":"Why do I get an error trying to use pytesseract?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm doing some linear optimization on a matrix that takes up 16GB of memory using the spicy.optimize.linprog method. However, my computer only has 8GB of RAM. I already consider the option of simply getting more RAM but besides that what other thing could I do to allow the program to still run.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":56,"Q_Id":71552179,"Users Score":1,"Answer":"Make sure to use scipy.sparse to store the matrix. Almost all LP matrices are very sparse.","Q_Score":0,"Tags":"python,optimization,memory,scipy,linear-programming","A_Id":71555132,"CreationDate":"2022-03-21T02:16:00.000","Title":"Linear Programing of 16GB of data on 8GB of RAM","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Monit not invoking python script <--> OS is CentOS. first line in python script is \"#!\/usr\/bin\/env python3\" when i tried to invoke python script from my terminal its working but monit is not able to trigger the script.\nI tried to call python script from shell script in monit but no luck. even i tried adding PATH variable as second line to shell script.\nany help will be appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":17,"Q_Id":71597506,"Users Score":0,"Answer":"Issue is with PATH environmental variable, like cron, monit is only taking subset of values from PATH variable instead of all values. So after explictly adding $PATH variable after shell interpreter, issue got resolved","Q_Score":0,"Tags":"python-3.x,monit","A_Id":71665032,"CreationDate":"2022-03-24T05:36:00.000","Title":"Monit not invoking python script <--> OS is CentOS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I currently have a silly problem, because I wanted to switch from Iterm to Hyper, which seems interesting to me with plugins.\nPS: I'm on mac M1\nHowever, when I try to run hyper i... I get these 2 stupid errors:\n\/opt\/homebrew\/bin\/hyper: line 4: \/usr\/bin\/python: No such file or directory\n\/opt\/homebrew\/bin\/hyper: line 8: .\/MacOS\/Hyper: No such file or directory\nFor python, it is installed, except that it is called python3 and not python, the problem is that thanks to SIP, I can't create from simlink which is called 'python'.\nFor the second error, I don't know what it is.\nThanks in advance to anyone","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":85,"Q_Id":71694519,"Users Score":0,"Answer":"I had the same error. It turned out my path to python is \/usr\/bin\/python3 and I changed that in \/opt\/homebrew\/bin\/hyper: line 4","Q_Score":0,"Tags":"python,hyperterminal","A_Id":71707645,"CreationDate":"2022-03-31T14:39:00.000","Title":"2 errors appear when I want to use Hyper CLI","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a simple python project to water my plants, it works with a Raspberry and RaspberryPi os lite.\nIn the project I have a package named app with a __main__.py to launch it, I just type python -m app in the terminal and it works fine.\nI tried to make a crontab with * * * * * \/usr\/bin\/python \/home\/pi\/djangeau\/app\nNothing happens, whereas if I launch a simple python test script it does.\nThe cron log gives me that error : 'No MTA installed, discarding output' , not sure this is useful to solve the problem.\nI hope I was clear enough. Thank you for your answers. Vincent","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":20,"Q_Id":71696609,"Users Score":0,"Answer":"Finally I figured out:\nFor exemple that command in bash : python -m app\nis equivalent to this one for a crontab :\n* * * * * cd \/home\/pi\/djangeau && \/usr\/bin\/python -m app\nJust replace the correct path and stars by the schedule you want","Q_Score":0,"Tags":"cron,python-3.9,raspberry-pi-os","A_Id":71707728,"CreationDate":"2022-03-31T17:07:00.000","Title":"Crontab and python project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I was wondering if using Locust as a library is more efficent than the original way as you don't have to make system calls for a new process this way thus reducing the initial delay at startup. I need to run thousands of separate loadtests for my app so it does make a difference.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":46,"Q_Id":71697282,"Users Score":0,"Answer":"Yes it is more efficient. Starting Python, parsing all the imported dependencies etc takes some time.\nHow much faster is anyones guess though, and running thousands of individual load tests is not something I\u2019ve seen anyone do, so I think you\u2019ll have to test it yourself.\nBut if you are adding\/removing replicas between tests, wont that be slower than restarting Locust anyway?\nYou can also run Locust in GUI mode and trigger a test by just sending an HTTP request to the \/swarm endpoint, that should not have any significantly bigger start up time than library use.","Q_Score":0,"Tags":"python,load-testing,locust","A_Id":71698044,"CreationDate":"2022-03-31T18:07:00.000","Title":"Performance using Locust with a locustfile vs as a library","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am sending and recieving packets between two boards (a Jeston and a Pi). I tried using TCP then UDP, theoritically UDP is faster but I want to verify this with numbers. I want to be able to run my scripts, send and recieve my packets while also calculating the latency. I will later study the effect of using RF modules instead of direct cables between the two boards on the latency (this is another reason why I want the numbers).\nWhat is the right way to tackle this?\nI tried sending the timestamps to get the difference but their times are not synched. I read about NTP and Iperf but I am not sure how they can be run within my scripts. iperf measures the trafic but how can that be accurate if your real TCP or UDP application is not running with real packets being exchanged?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":77,"Q_Id":71723297,"Users Score":0,"Answer":"It is provably impossible to measure (with 100% accuracy) the latency, since there is no global clock. NTP estimates it by presuming the upstream and downstream delays are equal (but actually upstream buffer delay\/jitter is often greater).\nUDP is only \"faster\" because it does not use acks and has lower overhead. This \"faster\" is not latency. Datacam \"speed\" is a combo of latency, BW, serialization delay (time to \"clock-out\" data), buffer delay, pkt over-head, and sometimes processing delay, and\/or protocol over-head.","Q_Score":0,"Tags":"python,tcp,udp,ntp","A_Id":71924115,"CreationDate":"2022-04-03T05:42:00.000","Title":"What is the right way to measure server\/client latency (TCP & UDP)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am sending and recieving packets between two boards (a Jeston and a Pi). I tried using TCP then UDP, theoritically UDP is faster but I want to verify this with numbers. I want to be able to run my scripts, send and recieve my packets while also calculating the latency. I will later study the effect of using RF modules instead of direct cables between the two boards on the latency (this is another reason why I want the numbers).\nWhat is the right way to tackle this?\nI tried sending the timestamps to get the difference but their times are not synched. I read about NTP and Iperf but I am not sure how they can be run within my scripts. iperf measures the trafic but how can that be accurate if your real TCP or UDP application is not running with real packets being exchanged?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":77,"Q_Id":71723297,"Users Score":0,"Answer":"While getting one-way latency can be rather difficult and depend on very well synchronized clocks, you could make a simplifying assumption that the latency in one direction is the same as in the other (and no, that isn't always the case) and measure round-trip-time and divide by two. Ping would be one way to do that, netperf and a \"TCP_RR\" test would be another.\nDepending on the network\/link speed and the packet size and the CPU \"horsepower,\" much if not most of the latency is in the packet processing overhead on either side. You can get an idea of that with the service demand figures netperf will report if you have it include CPU utilization. (n.b. - netperf assumes it is the only thing meaningfully consuming CPU on either end at the time of the test)","Q_Score":0,"Tags":"python,tcp,udp,ntp","A_Id":72481274,"CreationDate":"2022-04-03T05:42:00.000","Title":"What is the right way to measure server\/client latency (TCP & UDP)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a set of Python scripts running in a vendor's SaaS environment that limits some of the features of Python (due to how they're running our scripts under the covers, in some kind of custom interactive environment).\nFor example, generators and lambdas are not valid.\nThere is also a non-Pythonic include statement with the syntax @include \"Filename\" that is preprocessed by the vendor like a C-include, where it just copy-pastes the referenced Python file into the referencing script.\nI'd like to be able to lint my code and have it both:\n\nunderstand and ignore the @include statements\nunderstand how to modify Pylint's behavior to catch generators and lambdas\n(optionally) understand system-specific global variables that are outside of the scope of the file being linted but always available at runtime in the SaaS\n\nIs there any way to do this by modifying Pylint?\nBonus points if your solution does not modify the files you're linting (ie. un\/comment out the @include).","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":35,"Q_Id":71740531,"Users Score":0,"Answer":"It looks like you created a language of your own on top of python.\nParsing it is not possible currently in pylint. The only thing you could do is catch lambdas with \"bad builtin\" once you remove the @include (once it's python again). You could also create a custom checker to forbid generator. Everything else look like months of work on astroid (the AST used by pylint) and a whole project by itself.","Q_Score":1,"Tags":"python,pylint","A_Id":71747165,"CreationDate":"2022-04-04T16:19:00.000","Title":"Allow lint to process and\/or ignore non-valid python statements","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible?\nI want to create a command for my discord bot that makes the bot offline for everyone. I want to type that command in any discord server and then the bot just goes offline. This is much easier than going into your files or terminal to press ctrl+c. Is a command like this possible to even make? And if so, can I please know how to add that command? I want to add some admin commands to my bot and this is definitely a great addition to the list. Thanks -","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":121,"Q_Id":71752045,"Users Score":0,"Answer":"If I'm understanding what you're trying to do here, you can just add a command that exits the bot.py program by making a call to something like sys.exit(). This would just terminate the program running the bot, making the bot go offline.","Q_Score":0,"Tags":"python,discord,discord.py,command,bots","A_Id":71752227,"CreationDate":"2022-04-05T12:45:00.000","Title":"How do you create a command that makes the bot go OFFLINE in discord.py","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm making a bot in discord.py, and I'm getting to the stage of making more complex commands and making my easier commands better and more flexible.\nMy most recent endeavor is my \/say command. I'm making it able to do tts message and spoilers, but I can't find anything on the latter. Is it as simple as the tts or is it more complex?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":69,"Q_Id":71769943,"Users Score":1,"Answer":"You can mark your text as spoiler by putting <||||> around it. Example: \u201d<||hi||>\u201d","Q_Score":0,"Tags":"python,discord,discord.py","A_Id":71770036,"CreationDate":"2022-04-06T15:55:00.000","Title":"Spoiler messages in discord.py","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a stepper motor controller that I can command through a USB COM on windows. The manufacturer provided a software but I want to create my own on python (In fact, I want to include the control of the stepper into a python code that control another device using the stepper). The problem is that I don't have any information about the commands to send to the controller to move the motor. I want to know if there is a way to read the command sent to the controller using the manufacturer software (like move the motor and read the command sent) and then use that command to write my own code on python ? I want to know if my idea is pure fantasy or if this can actually be done ? Thanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":40,"Q_Id":71814391,"Users Score":0,"Answer":"I think it's a bit hard since the manufacturer already has its own software meaning their software already bind with the firmware of the controller.\nOne way to do that is you have to look for the way to communicate with the firmware between python and your controller. Who know to do this? the manufacturer. If you have a basic of electrical engineering I think its possible but still hard.","Q_Score":1,"Tags":"python,windows,libusb,pyusb,stepper","A_Id":71814721,"CreationDate":"2022-04-10T06:53:00.000","Title":"Communication with a stepper motor controller through a USB COM?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Could not find a working python interpreter. Please make sure one of the following is in your PATH: python python3 python3.8 python3.7 python2.7 python2\nI installed python 3.10.4\nPath is set in environment variables. Still not working.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2679,"Q_Id":71858814,"Users Score":2,"Answer":"It is working now. We have to set paths in both user variables and system variables. Then restart the PC.","Q_Score":2,"Tags":"python,firebase,unity3d,firebase-realtime-database","A_Id":71861674,"CreationDate":"2022-04-13T14:00:00.000","Title":"Could not find a working python interpreter. Unity, Firebase","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to block a Twitter user using Python scripting and the Tweepy API. I am able to extract users, IDs, followers and tweets with no problem. When I try to call api.create_block(screen_name = '')\nI get an exception\n401 Unauthorized\n(and that user is not blocked). I have been googling but only found old posts referring to my Windows time being not in sync. I synced the time and no improvement. I also tried blocking by ID but no luck.\nCan anybody help ?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":40,"Q_Id":71860303,"Users Score":0,"Answer":"I am using OAuth 2.0 which does not allow separate read or write permissions. I tried with refreshed credentials but still the same.\nI did enable OAuth 1.0a and regenerated credentials (again) and now I can block users, Thanks !","Q_Score":0,"Tags":"python,block,tweepy,http-status-code-401,unauthorized","A_Id":71874964,"CreationDate":"2022-04-13T15:45:00.000","Title":"Python Tweepy block user returns 401 Unauthorized","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When i run my python script from terminal i get error due to missing env variable. i can fix by this using export and setting it. But there are other python scripts that are running fine as cron jobs that require this as well. And i see this env variable being set in cron tab. So my question is if env variable set in cron is available for scripts run by user\/root from cli? Running env command as root doesn\u2019t show this variable.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":55,"Q_Id":71880095,"Users Score":0,"Answer":"Environment variables are private to each process, not global. When a new process is started it inherits its initial environment from its parent. Your terminal shell isn't started by cron so it doesn't inherit the env vars you've set in your crontab.\nYour OS may provide a standard mechanism for setting env vars for all processes (e.g., your terminal which then starts your CLI shell). What I prefer to do is create a file named ~\/.environ that I then source in my ~\/.bashrc and cron jobs.","Q_Score":0,"Tags":"python,shell,cron,environment-variables","A_Id":71889044,"CreationDate":"2022-04-15T04:29:00.000","Title":"python script doesn\u2019t pick up environment variable that is set in crontab","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to understand how memory is managed when python is embedded in C# using python.net. Python is executed in C# using the py.GIL (global interpreter lock), essentially C# calls the python interpreter and executes the python code. What I don't understand is how is memory allocated and deallocated for python objects.\nI couldn't find anything online and any type of help will be appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":48,"Q_Id":71892964,"Users Score":2,"Answer":"C# PyObject is holding a Python object handle (which are pointers into C heap). Internally Python objects count references to themselves.\nIn C# you can either force releasing the handle by calling PyObject.Dispose, in which case Python object refcount is decreased immediately, and if at this point it reaches 0, Python object will be destroyed and deallocated (from C heap).\nAlternatively, wait until PyObject instance is collected by .NET garbage collector. When that happens, the Python object handle is added to an internal queue, which is periodically emptied when you create new PyObjects (e.g. PyObject constructor will go check that queue, and release all handles in it).\nThis applies to Python.NET 2.5 and the upcoming 3.0.","Q_Score":1,"Tags":"python.net,python-embedding","A_Id":71897349,"CreationDate":"2022-04-16T10:14:00.000","Title":"Memory Management while embedding python in C# using python.net","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I enter\npython --version\nit gives:\nbash: python: command not found\nbut when I enter\nsudo apt-get install python\nit gives:\npython is already the newest version (2.7.16-1).\nWhen trying to locate the python files, they appear mostly in \/var\/lib\/dpkg\/info\/ or in \/home\/pi\/.local\/bin\/, therefore are present in the system, however they do not appear where they would normally be found in \/usr\/local\/bin.\nThe same thing goes for the pip, python3 and pip3 files.\nHow do I fix this so that I can use the python command?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":45,"Q_Id":71918706,"Users Score":1,"Answer":"To install python to the newest version run sudo apt-get install python3\nYou then need to run python3 for linux based systems so python3 --version should work.","Q_Score":0,"Tags":"python,installation,pip,raspberry-pi","A_Id":71936570,"CreationDate":"2022-04-19T01:29:00.000","Title":"Python installed on raspberry pi, but not accessible in \/usr\/local\/bin","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I\u2019m download the lastest version of Delphi 11.1 and all is Ok, but when I try to debug project in MAC Monterey 12.3.1 using PAServer 22, I have an error in PAServer Terminal window, it said that Framework Python can\u2019t be found in System\/library\/Frameworks\/.., I install Python 2.7 but it\u2019s not installed in System\/... is installed in Library\/... and PaServer can\u2019t find it.\nHave you any Solutions for that problem?\nThank you.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":251,"Q_Id":71944001,"Users Score":0,"Answer":"Finally I have the solution, use:\nsudo install_name_tool -change '\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/Python' \/Library\/Frameworks\/Python.framework\/Versions\/2.7\/Python liblldb.3.8.0.dylib\nI change the dylib that crash, with new path for Python.","Q_Score":1,"Tags":"python,delphi,macos-monterey,paserver","A_Id":72048605,"CreationDate":"2022-04-20T17:42:00.000","Title":"PAServer 22 is not working in Mac Monterey, it use dylib that link with framework Python 2.7 and not exist in \/System\/library\/Frameworks of Monterey","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"How can I quickly download audio from YouTube by URL or ID and send it to Telegram bot? I've been using youtube-dl to download audio, save it on hosting and after that send it to user. It takes 1-2 minutes to do that. But other bots (like this one @LyBot) do this with the speed of light. How do they do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":45,"Q_Id":71950060,"Users Score":2,"Answer":"As it says in their documentation \"I send audio instantly if it has already been downloaded through me earlier. Otherwise, the download usually takes no more than 10 seconds.\"\nThey probably store a file the first time its downloaded by any user so that it can be served instantly for subsequent requests.","Q_Score":1,"Tags":"python,youtube,telegram,telegram-bot","A_Id":71950107,"CreationDate":"2022-04-21T06:51:00.000","Title":"How can I quickly download and send audio from youtube?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"As CTT is a windows application , I couldn't find a way to make api calls to it , is there a way to open and run it ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":20,"Q_Id":71993926,"Users Score":1,"Answer":"Read the documentation for the CTT, you'll see it has a CLI that allows it to be run as part of a (Windows-based) build\/CI environment.","Q_Score":1,"Tags":"python,opc-ua,opc","A_Id":72006102,"CreationDate":"2022-04-25T02:30:00.000","Title":"Is there a way to call the OPC complaince test tool using python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"When iam running the test case it will open browser and the process will continue...my task was to get browser performance from developer tool record that performance until the test case run and download it as json file...can anyone help me","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":15,"Q_Id":71995824,"Users Score":0,"Answer":"There are no details to the setup, but in general:\n\nTake current time after the Test-Setup\nRun Test\nTake current time before the Test-Teardown\nCompute the difference between the times and export it to JSON, database or a monitoring solution.\n\nYou could write an abstract test case which implements this and use it for all the tests that require time measurements.","Q_Score":0,"Tags":"javascript,python,html","A_Id":71996678,"CreationDate":"2022-04-25T07:23:00.000","Title":"how to fetch browser performance when we run test cases using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a designer and I code only a little bit. I would like to know how I could use the output of the Twitter API (which I master) to use them on Unity. Which programming language would be the best? The goal is for me to do real-time creation on Unity.\nThanks in advance for your help! :)","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":38,"Q_Id":72019704,"Users Score":1,"Answer":"I believe you can have your twitter bot communicate with unity by using files. So you can write in a file then read the content with C# during runtime.","Q_Score":1,"Tags":"unity3d,twitter,twitterapi-python","A_Id":72043963,"CreationDate":"2022-04-26T19:46:00.000","Title":"Twitter API to Unity","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on Program, api application to python of telegram, in version 2, filter edited has replaced with a decorator of his own, @clinet.on_edited_message,\nthe problem is that I want to invert is action, and get only not edited messages, with filter is easy, add ~ in the beginning, but how do I do that in a decorator? thanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":31,"Q_Id":72044152,"Users Score":0,"Answer":"As the Release Notes for Version 2 describe, @app.on_edited_message() only filters edited messages. If you want non-edited messages, use @app.on_message() instead.","Q_Score":0,"Tags":"python,python-decorators,pyrogram","A_Id":72044245,"CreationDate":"2022-04-28T13:01:00.000","Title":"Invert the action of an decorator in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wrote a Python script which writes its output into a txt file.\nThen I included that file in my html\/php website. - works good so far.\nOnly remaining problem: I can't execute the .py file automatically while opening the site.\nI know that this isn't the best solution\n doesn't seem to work","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":25,"Q_Id":72046706,"Users Score":1,"Answer":"I used the commands chown -R www-data:www-data and chmod -R 755 . I'm not sure which command solved my problem, but at least its working.","Q_Score":0,"Tags":"python,php,sql,web,execute","A_Id":72047249,"CreationDate":"2022-04-28T15:47:00.000","Title":"executing .py in html\/php","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to create MS Teams chat-bot without using MS Bot Framework.\nHowever, in the official document, there was only an example of using the MS Bot Framework.\nI want to develop this process through message processing through FastAPI and my own AI logic.\nIs there a guide for proper usage?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":63,"Q_Id":72093935,"Users Score":1,"Answer":"If you're only looking to send the odd notification to a user you can do this via Graph as Conrad said (there are reasons why this might not be the best solution and taking the bot approach is usually the better option - being able to send a notification from an \"app\" rather than a user with rich adaptive cards, for example)\nThe main thing to remember here is that a \"bot\" is just an api endpoint and the \"bot framework sdk\" largely exists to simplify the process of parsing and processing the messages that are sent on that endpoint (and some additional complexities around auth with the Azure bot service, etc). The interaction between Teams and your bot is also not request\/response it's actually request\/request and the SDK does a reasonable job of abstracting this so you don't have to worry about it.\nHaving said that, as long as you have an api endpoint that will accept the messages being sent from Teams (and proxied through the bot service) you don't have to use the sdk, plus it's all open source so you can inspect the framework to see what it's doing... I'd highly recommend using it though as it really does make your life a lot easier and some of those message structures aren't very well documented... the bottom line is that it's not trivial, but it is possible!","Q_Score":0,"Tags":"python,microsoft-teams,fastapi","A_Id":72223142,"CreationDate":"2022-05-03T01:16:00.000","Title":"Can I create a Teams bot without using Bot Framework?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a SMS daemon for sending and receiving SMS. I'm using a (slightly modified) version of python-gsmmodem-new as my GSM-Library.\nThe problem I encountered was that with every Message a Delivery Report seems to be requested.\nThe strange thing is, the reports are seemingly disabled at modem initialization. I double checked the code, it's using the command\nAT+CSMP=17,167,0,0\nfor initialization, which should be alright. After consulting the GSM Documentation I learned that for Delivery Reports Bit 5 has to be set, which is 32 in decimal, so the code for Delivery reports has to be AT+CSMP=49,167,0,0.\nIs there something I could have missed?\nAs my Service Provider charges 25 cents per Report and there are roughly 800 Message per Month this is quite costly, and i can't really charge this to the customer :).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":20,"Q_Id":72112860,"Users Score":0,"Answer":"I solved it. The CSMP-setting was correct, but for whatever reason i had to set the modem into text mode with AT+CMGF=1 for it to work properly.","Q_Score":0,"Tags":"python,sms","A_Id":72118980,"CreationDate":"2022-05-04T12:18:00.000","Title":"AT Command to disable delivery reports","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to debug pytest tests in Visual Studio 2022. I have the tests showing up in test explorer and when I run them they execute, however when I set a breakpoint and try to debug the test the breakpoints show the warning symbol and when I hover over it, it informs me that the breakpoint will not be hit because symbols are not loaded. The test does actually run, I just can't figure out how to get it to load whatever it needs to in order for me to debug.\nIt's python so there's no module to inspect in the modules window to tell it to load symbols for and nothing is compiled so I don't know where symbols would even be. Is there something that needs to be configured in the pyproject (besides setting the test framework to pytest)? Debugging in my other python projects just worked out of the box. Is there a setting for loading symbols for your own python code? If so, does anyone know where or why it would be disabled for pytest tests while testing?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":27,"Q_Id":72135205,"Users Score":0,"Answer":"It turns out this was a bug in VS. Simply updating to the latest version resulted in everything magically working as expected.","Q_Score":0,"Tags":"python,debugging,pytest,visual-studio-2022","A_Id":72178245,"CreationDate":"2022-05-06T01:24:00.000","Title":"Cannot debug pytest tests in Visual Studio 2022 -- symbols not loaded for my python code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am wondering if there is a way to get the list of method names that are modified along with modified lines and file path from git commit or if there are any better solution for python files\nI have been going through few answers in stackoverflow where the suggestion was to edit the gitconfig file and .gitattributes but I couldn't get the desired output","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":28,"Q_Id":72143427,"Users Score":0,"Answer":"Git has no notion of the semantics of the files it tracks. It can just give you the lines added or removed from a file or the bytes changed in binary files.\nHow these maps to your methods is beyond Git's understanding. However there might be tools and\/or scripts that will try and heuristically determine which methods are affected by a (range of) commits.","Q_Score":0,"Tags":"python,git,github,gitlab,gitlab-ci","A_Id":72152645,"CreationDate":"2022-05-06T14:49:00.000","Title":"Get method names and lines from git commit - python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hy, I have a simple question, how can I join a new telegram channel with its public ID only in telethon via python?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":72152091,"Users Score":0,"Answer":"No, you can't. You can join a public channel by its username.","Q_Score":0,"Tags":"python,telethon","A_Id":72474778,"CreationDate":"2022-05-07T11:36:00.000","Title":"How to join a telegram channel with only channel id in telethon?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"TLDR\nI am making a REST Session management solution for industrial automation purposes and need to automatically log into devices to perform configurations.\nNOTE:\nThese devices are 99% of the time going to be isolated to private networks\/VPNs (i.e., Will not have a public IP)\nDilemma\nI am being tasked with creating a service that can store hardware device credentials so automated configurations (& metrics scraping) can be done. The hardware in question only allows REST Session logins via a POST method where the user and (unencrypted) password are sent in the message body. This returns a Session cookie that my service then stores (in memory).\nThe service in question consists of:\n\nLinux (Ubuntu 20.04) server\nFastAPI python backend\nSQLITE3 embedded file DB\n\nStoring Credentials?\nMy background is not in Security so this is all very new to me but it seems that I should prefer storing a hash (e.g., bcrypt) of my password in my DB for future verification however there will not be any future verification as this is all automated.\nThis brings me to what seems like is the only solution - hashing the password and using that as the salt to encrypt the password, then storing the hashed password in the DB for decryption purposes later. I know this provides almost 0 security given the DB is compromised but I am at a loss for alternate solutions. Given the DB is embedded, maybe there is some added assurance that the server itself would have to be compromised before the DB itself is compromised? I don't know if there is a technical \"right\" approach to this, maybe not, however if anyone has any advice I am all ears.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":26,"Q_Id":72154730,"Users Score":0,"Answer":"You should consider using a hardware security module (HSM). There are cloud alternatives (like AWS Secrets manager, an encrypted secrets repository based on keys stored in an actual HSM, AWS KMS). Or if your app is not hosted in a public cloud, you can consider buying an actual HSM too, but that's expensive. So it all comes down to the risk you want to accept vs the cost.\nYou can also consider building architecture to properly protect your secrets. If you build a secure secrets store service and apply appropriate protection (which would be too broad to describe for an answer here), you can at least provide auditing of secret usage, you can implement access control, you can easily revoke secrets, you can monitor usage patterns in that component and so on. Basically your secrets service would act like a very well protected \"HSM\", albeit it might not involve specialized hardware at all. This would not guarantee that secrets (secret encryption keys, typically) cannot ever be retrieved from the service like a real HSM would, but it would have many of the benefits as described above.\nHowever, do note that applying appropriate protection is the key there - and that's not straightforward at all. One approach that you can take is model your potential attackers, list ways (attack paths) for compromising different aspects of different components, and then design protections against those, as long as it makes sense financially.","Q_Score":0,"Tags":"python,database,sqlite,security,microservices","A_Id":72163403,"CreationDate":"2022-05-07T17:07:00.000","Title":"Storing decryptable passwords for automatied usage","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"i have a file for my discord bot which i run on boot and now i also made a react.js app and i also want this to run on boot. But when i put:\ncd \/home\/pi\/kickzraptor-site && npm run start\nalso in my .bashrc file, only the first one gets run because its an infinite loop i think. How can i run both on startup? Thanks! (This is the line already at the bottom of my bashrc file)\necho Running bot.py scipt...\nsudo python3 \/home\/pi\/bot.py","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":25,"Q_Id":72165603,"Users Score":1,"Answer":"Fastest way (not recommended) is to add & at the end of the command so that the program doesn't block for further processes. sudo python3 \/home\/pi\/bot.py &\nRecommended way is to create a systemd service that runs during or after the boot is completed (depending on its configuration). This method is also good for error handling and it provides more ability on the program.","Q_Score":0,"Tags":"python,reactjs,terminal,raspberry-pi","A_Id":72167532,"CreationDate":"2022-05-08T22:48:00.000","Title":"How can i run multiple infinite files on boot of raspberry pi?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm just learning learning python and don't know many things. At the moment I'm building a telegram bot that can help you to find appropriate text to read in foreign lang.\nThe core function I want to implement is:\nThe bot suggest you the text to read based on you your vocabulary. (when you mark a text as \"read\", all the words are added to your dictionary. like that bot collects info)\nFor example you are user A, you know 500 words, and you want to get the text from the bot database where you know at least 75% of words or at least 90% of words.\nRight now I have the database of user words and texts. How should I approach indexing, that whould tell me how many words user know from each text?\nObviously, I can compare the list of user words with the list of words from each text at every bot start. But I'm not sure if it is the most efficient way. Each time indexing 100+ texts feels like a strange idea.\nCould you please suggest me where can I read about similar problems? Or how can i search it? I don't even know how to google it...","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":18,"Q_Id":72173449,"Users Score":0,"Answer":"You can use database like Elasticsearch that allows you to do full-text search. And when you'll query with user words, it will also give you confidence value, with which you can decide which text has better matching.","Q_Score":0,"Tags":"python,algorithm","A_Id":72174811,"CreationDate":"2022-05-09T14:14:00.000","Title":"How to approach a search\\comparison problem for the large database?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm just learning learning python and don't know many things. At the moment I'm building a telegram bot that can help you to find appropriate text to read in foreign lang.\nThe core function I want to implement is:\nThe bot suggest you the text to read based on you your vocabulary. (when you mark a text as \"read\", all the words are added to your dictionary. like that bot collects info)\nFor example you are user A, you know 500 words, and you want to get the text from the bot database where you know at least 75% of words or at least 90% of words.\nRight now I have the database of user words and texts. How should I approach indexing, that whould tell me how many words user know from each text?\nObviously, I can compare the list of user words with the list of words from each text at every bot start. But I'm not sure if it is the most efficient way. Each time indexing 100+ texts feels like a strange idea.\nCould you please suggest me where can I read about similar problems? Or how can i search it? I don't even know how to google it...","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":18,"Q_Id":72173449,"Users Score":0,"Answer":"You don't need to process every text at every bot start.\nProcess every text once.\nThen write the results of all the processing to a file. When the bot starts, recover the data by reading that data file.","Q_Score":0,"Tags":"python,algorithm","A_Id":72174569,"CreationDate":"2022-05-09T14:14:00.000","Title":"How to approach a search\\comparison problem for the large database?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"At some point, I need to view the history on a specific topic 'topicName'. How can i do this in python?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":32,"Q_Id":72290084,"Users Score":1,"Answer":"Short answer: You don't\n(The MQTT protocol requires the broker to only stores messages for known clients that are currently offline and have requested high QOS subscription, otherwise it doesn't keep any state, and client libraries won't keep history for you)\nLonger answer:\nThe only way to see the history of messages published to a topic is to set a client up to subscribe to that topic and store them somewhere (e.g. in a database) and then query that store. (Some brokers have plugin support that can do this)","Q_Score":0,"Tags":"python,python-3.x,mqtt,paho","A_Id":72291732,"CreationDate":"2022-05-18T13:25:00.000","Title":"How view history by topic in paho-mqtt?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The \"Exists\" keywords is it assertive?\nI added this keyword in my test (the objective is failed test, because i put a different image of the displayed screen), but the status is passed!\nWhich of these keywords is better to validate?\n\"Exists\" or \"Screen Should Contain\"?\nIs there a keyword where I validate the text presented on the screen with the text I send?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":36,"Q_Id":72307893,"Users Score":1,"Answer":"I'm prefer to use keyword Screen Should Contain because different image","Q_Score":0,"Tags":"python,automation,robotframework,sikuli","A_Id":72428474,"CreationDate":"2022-05-19T16:15:00.000","Title":"\"Exists\" keyword with false positive result - Robot Framework with Sikuli","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to open files from asynchronous processes and I've noticed two different modules that could be used: aiofiles and aiofile. However, I don't seem to find information about pros and cons between the two.\nWould anyone have information about their main differences? Is either of them more widely use than the other?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":47,"Q_Id":72315463,"Users Score":1,"Answer":"They are doing mostly the same things, currently the aiofiles lib supports a little bit more stuff than aiofile like temp files.\nCurrently the usage for aiofile:\n\nDownloads last month: 91,971 (pypistats.org)\n\nand for aiofiles:\n\nDownloads last month: 4,732,892 (pypistats.org)\n\nPersonally, I would use the aiofiles because of the stats and the additional features.","Q_Score":0,"Tags":"python-asyncio","A_Id":72320376,"CreationDate":"2022-05-20T07:59:00.000","Title":"AIOfile VS AIOfiles","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm building a testing suite using Python Pytest library,\nmy challenge is that I want to run the test on remote windows machines without the overhead of deploying my python code on those remote machines.\nCurrent Solution:\nUsing Jenkins I'm cloning the tests repository from bit bucket to the remote machine , and then using a PowerShell command through WINRM triggering the execution of the pytest script on the remote machine.\nDesired Solution:\nThe pytest code\/repository will reside on a machine (local\/cloud) and will execute on remote windows machines (possibly in parallel on multiple machines)\nI've investigated the paramiko\/factory packages but they both require the code to be present on the remote machines.\nAnyone encountered similar requirement ? implemented something similar?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":44,"Q_Id":72337410,"Users Score":0,"Answer":"you can try a pub-sub mechanism with aws ssm","Q_Score":0,"Tags":"python,pytest,remote-execution","A_Id":72337656,"CreationDate":"2022-05-22T12:02:00.000","Title":"Execution of python code on remote machines","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"So I've been trying to make a program using Python that refreshes my Discord user token once every five minutes, but most of the tutorials online are about refreshing your Oauth2 access token, so I am currently very confused. Can anyone help me on the modules and functions to use, or are the Oauth2 access token and user token same things. Thanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":26,"Q_Id":72341799,"Users Score":0,"Answer":"Your Discord Token change when changing the password of your account so you will need to change your password every 5 minutes using some api calls and get the current token from another specific api call. you can find the api call urls and the data you need to post \/ get in the browser devconsole.","Q_Score":0,"Tags":"python,discord,python-requests-html","A_Id":72364161,"CreationDate":"2022-05-22T22:49:00.000","Title":"How to refresh a Discord user token with python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using the message_callback_add()-method of PahoMQTT to filter the messages by topic and would like to be a bit more specific.\nExample topic to get the color of a banana: \nfruits\/banana\/color, syntax: fruits\/+\/+.\nI'd like to listen only to the fruits banana and apple. Currently I filter it manually, but I'd prefer to have a syntax like: fruits\/\/+.\nDoes something like that exist? I only know about wildcard (#) and single level (+) placeholders.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":16,"Q_Id":72393695,"Users Score":0,"Answer":"Nope\nMQTT wildcards only match whole topic levels and you can not pass optional matches. The Paho library uses the same rules that the broker would use to match topics.\nYou will need to do topic matching in the message callback.","Q_Score":1,"Tags":"python,mqtt,paho","A_Id":72394667,"CreationDate":"2022-05-26T14:45:00.000","Title":"More explicit single level MQTT topics with PahoMTT?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to use previously developed Perl code in my new python script I am writing. The issue I am running into is that I cannot import the Perl files into the python code using import because they are all written in Perl. Is there a way I can bypass this and still use the perl code somehow with my python code to not have to rewrite 50+ perl programs.\nAn Example\nin a perl file, I could have something that defines an object car that has the color red, make nissan, and model altima, and I need to be able to implement that into my python code.","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":40,"Q_Id":72396983,"Users Score":4,"Answer":"You cannot reasonably combine Perl and Python code directly. While there are some ways to achieve interoperability (such as writing glue code in C), it will be far from seamless and probably take more effort than rewriting all the code.\nWhat I try to do in that situation is to wrap the old code with a simple command-line interface. Then, the Python code can run the Perl scripts via subprocess.run() or check_output(). If complex data needs to be transferred between the programs, it's often simplest to use JSON. Alternatively, wrapping the old code with a simple REST API might also work, especially if the Perl code has to carry some state across multiple interactions.\nThis works fine for reusing self-contained pieces of business logic, but not for reusing class definitions.","Q_Score":0,"Tags":"python,perl","A_Id":72397639,"CreationDate":"2022-05-26T19:21:00.000","Title":"How to use Perl objects and Methods in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a bytearray that I'm trying to compress - is it typically base 64 encode first and then gzip compress or vice versa, gzip compress and base64 encode the result?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":24,"Q_Id":72397267,"Users Score":1,"Answer":"gzip compress, then base64. To reverse, un-base64, then gunzip.","Q_Score":0,"Tags":"python-3.x,base64,gzip","A_Id":72399187,"CreationDate":"2022-05-26T19:46:00.000","Title":"Base 64 and gzip order?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a repo on GitHub with a software written in one language, but I have decided to convert (reprogram) to another language (Python). The structure of the program will thus be different and in principle everything is replaced. When the first version of the new program is ready I would like to continue with the same repo-name to keep the same url-link. I'd also like to keep the old code available for reference, but maybe as an archived repo with another name. So far I have been the only contributor to the project.\nWill this plan work:\n\nif current repo is called 'my_repo'\nRename current repo to 'my_repo_old'\nCreate new 'my_repo' with the new code\n\nDoes this sound as the correct way to do this? Is there any pitfalls here? Would you recommend another approach?\nThankful for any advise.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":18,"Q_Id":72405430,"Users Score":0,"Answer":"Yes, that looks correct.\nYou can also make a organization, fork your code there, and push your python code to old repo that way both project can have same name but will be under different url but still tied to your account.","Q_Score":0,"Tags":"python,git,github,repository","A_Id":72405649,"CreationDate":"2022-05-27T12:25:00.000","Title":"Replace content of repo","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My problem's in the final stage of the deploying process,\nwhen i click deploy branch, it says ther's an error like the following:\nERROR: Could not find a version that satisfies the requirement email-tp==0.1.0 (from versions: none)\nERROR: No matching distribution found for email-tp==0.1.0\nrequirements.txt file contain:\npython-telegram-bot\nsecure-smtplib\nemail-to == 0.1.0\nssl\nthe problem happens with email-to and ssl packages\ncan any one help me with that please?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":17,"Q_Id":72498890,"Users Score":1,"Answer":"It looks like you have a typo in your requirements.txt. As the error says, you're trying to install email-tp==0.1.0 instead of email-to==0.1.0.\nAs a tip, you may want to freeze your projects using pip freeze > requirements.txt to avoid this kind of complications.","Q_Score":0,"Tags":"python,heroku,telegram-bot","A_Id":72499163,"CreationDate":"2022-06-04T10:13:00.000","Title":"Deploying telegram bot with heruko problem","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Okay, so this is kind of a stupid question but I tried to understand it myself and I just got even more confused. I am using the Spotipy library to play music (controlled by my raspberry pi) on my computer using the specific device id. Now I want to implement the same thing but be able to play directly on my Raspberry Pi. I have found something called Raspotify, which allows me to use my rpi as a spotify connect speaker. I wasn't able to find it in the devices list though, and I'm now wondering if it is even possible to control a connect speaker?\nIf not, are there any other ways to play music using the spotipy api on my rpi? Help is greatly appreciated, I tried figuring it out by myself but I just got even more confused.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":138,"Q_Id":72535699,"Users Score":1,"Answer":"I now found the answer myself. You can control Spotify Connect speakers using Spotipy, but for me the Spotify API had some trouble finding the device. It then just started working even though I didn't change anything. So for anyone else wondering, a spotify connect speaker acts like a normal device with device id and everything :)","Q_Score":0,"Tags":"python,raspberry-pi,spotify,spotipy","A_Id":72565878,"CreationDate":"2022-06-07T18:00:00.000","Title":"Is a Spotify Connect Speaker able to be controlled by Spotipy?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to send an email (using template) to customer but I don't want to create said email in record chatter as well.\nRight now I use the method send_mail() from mail.mail_template.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":94,"Q_Id":72560061,"Users Score":0,"Answer":"If you are planning to send email via Odoo core Email wizard, then it is not possible because the \"composition_mode\" field is required and default value is comment.\nBut if you can achieve it with a new custom button, type=object. On the button click, the method will trigger in the background, fetch an email template and send it.","Q_Score":0,"Tags":"python,python-3.x,odoo,odoo-14","A_Id":72580263,"CreationDate":"2022-06-09T12:13:00.000","Title":"How to prevent emails from being created in record chatter after sending email to customer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Environment\nPythonnet version: 3.0.0a2 PRE-RELEASE\nPython version: 3.10.5\nOperating System: Windows 10\n.NET Runtime: .Net core 6.0 and 5.0\nDetails\nHave created a simple program to\n\nAdd 2 numbers\nRead XML from File\nConvert Base64 Encode\nUsed PythonNet CLR to import the dll and access all the above methods\n\nOn .NET core 6.0:\n\nAdd 2 numbers worked like charm\nRead XML and Covert Base64 threw error\nSystem.TypeLoadException: Could not load type 'System.Text.Encoding' from assembly 'System.Text.Encoding, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.\nat DllExport.XMLReader(String filePath)\n\nOn .NET core 5.0 :\nAdd 2 numbers worked\nRead XML worked\nConvert Base64 did not work and threw error\nSystem.TypeLoadException: Could not load type 'System.Convert' from assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.\nat ReusableLibariesConsole.Program.Base64_Encode(Byte[] data)\nWe have set the .NET version to 2.0\nthen all 3 errors disappeared however further methods such as Encryption did not work again\nSystem.TypeLoadException: Could not load type 'System.Security.Cryptography.PasswordDeriveBytes' from assembly 'System.Security.Cryptography.Csp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.\nat DllExport.EncryptionManagerClass.Encrypt(String inputData, String password, Int32 bits)\nWe tried lot of fixes such as setting CPU to x64, changing target framework and nothing worked.\nPlease let us know if you need further information","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":94,"Q_Id":72572500,"Users Score":0,"Answer":"I happened to have been battling with a similar issue about a week ago\nwith the error: System.TypeLoadException: Could not load type 'System.Data.Dataset' form assembly 'System.Data.Common', Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\nTo resolved this I downgraded the .NET version to 4.8","Q_Score":1,"Tags":"python,c#,.net","A_Id":72938493,"CreationDate":"2022-06-10T10:06:00.000","Title":"Load C# from Python: Unable to Load the .NET dependencies while accessing the methods","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently came across the Google Coral dev board mini in search of a ML microcontroller platform for a robotics and speech recognition project. I realized that there are minimal tutorials on creating projects from scratch for the dev board mini but a ton of example projects. The problem with these example projects is that it gets imported through a git clone through the Mendel linux terminal, which doesn't really tell me how to create my own project and where to compile and code it. To make things more clear I will use the ESP32 dev board as an example:\nTo write a program (C++) on a ESP32 dev board that controls the I\/O pins, I used PlatfromIO to compile and flash the microcontroller. What IDE can be used to perform the same functionality on the Google-Coral dev board mini? Does there exist an article about this?\nSorry if my question seems obvious, but I feel that I spent too much time searching for the solution. Thanks in advance! :)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":89,"Q_Id":72573384,"Users Score":0,"Answer":"The Google Coral dev board mini is a single board computer running a full Linux operating system, whereas the ESP32 is a microcontroller which does not run an OS, it is only flashed with a single C++ program. The difference is the same as a Raspberry Pi and an Arduino. Since the Coral dev board has a full OS, you can plug a monitor, mouse, and keyboard into it and develop code directly on it. Or you can use your PC to ssh into the coral board to copy files over and remotely run commands. Through these ways you can use any IDE you want.","Q_Score":0,"Tags":"python,google-coral","A_Id":73831913,"CreationDate":"2022-06-10T11:14:00.000","Title":"How does one run a blink LED program on Google-Coral dev board mini and what IDE is recommended?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a Python file on a Unix server, that will run 18 hours a day. The file will be run with Cron each day. The file has A while True loop with sleep. Assuming there is no uncaught exception, can this file run for this long? or how long can it run?\nI have a background in PHP, and know there is a maximum execution time, is there a such thing in Python?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":155,"Q_Id":72586647,"Users Score":0,"Answer":"Yeah, no problem. Python files are interpreted without such configuration in mind, so the process will run as long as you need it to.","Q_Score":0,"Tags":"python,infinite-loop","A_Id":72586668,"CreationDate":"2022-06-11T17:47:00.000","Title":"How long can a Python file run without crashing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been looking for a bit and I can not find a way to run unittest's in parallel is there a library that gives you the same output but runs the tests in parallel?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":74,"Q_Id":72589741,"Users Score":1,"Answer":"The pytest testing framework has a plugin called pytest-xdist that runs tests in parallel.\nNote that:\n\npytest supports running Python unittest-based tests out of the box.","Q_Score":0,"Tags":"python,python-unittest","A_Id":72589914,"CreationDate":"2022-06-12T05:39:00.000","Title":"How to run unittest in parallel?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So one of our servers has v2.6 installed. I\u2019ve checked and most of the scripts that runs in this server are unix scripts. There are few python scripts but I\u2019m not sure if it\u2019s still being used. They are not in cron. I don\u2019t know their users as well.\nNow I want to install another version which is v3.10. In short there will be two versions in the server \u2014 v2.6 and 3.10.\nMy question is \u2014 is there a chance that those scripts running in v2.6 will encounter any issues once we install v3.10?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":27,"Q_Id":72600473,"Users Score":2,"Answer":"If these scripts explicitly point to your python 2.x interpreter (with a shebang), then no, you won't have any issues.\nHowever, if your question is : 'will my scripts written for python 2.x run without issue within python 3.10', then the answer is it depends.\nSome python2 will run perfectly fine with python3.\nNote that even if you install python3.10 on let's say Ubuntu, then python will still refer to your python2 installation by default.","Q_Score":1,"Tags":"python,python-3.x","A_Id":72600623,"CreationDate":"2022-06-13T09:21:00.000","Title":"Install 2 python versions linux","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I get the following error when trying to import the librosa library into my python project and running it in the global python environment:\n\nTraceback (most recent call last): File\n\"\/Library\/Frameworks\/Python.framework\/Versions\/3.9\/lib\/python3.9\/site-packages\/soundfile.py\",\nline 142, in \nraise OSError('sndfile library not found') OSError: sndfile library not found\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last): File\n\"Bloompipe\/Synthesis_Module\/bloompipe_synthesis\/testSynthesis.py\",\nline 6, in \nfrom LSD.lucidsonicdreams import LucidSonicDream File \"Bloompipe\/Synthesis_Module\/bloompipe_synthesis\/LSD\/lucidsonicdreams\/init.py\",\nline 1, in \nfrom .main import * File \"Bloompipe\/Synthesis_Module\/bloompipe_synthesis\/LSD\/lucidsonicdreams\/main.py\",\nline 15, in \nfrom .AudioAnalyse import * File \"Bloompipe\/Synthesis_Module\/bloompipe_synthesis\/LSD\/lucidsonicdreams\/AudioAnalyse.py\",\nline 3, in \nimport librosa.display File \"\/Library\/Frameworks\/Python.framework\/Versions\/3.9\/lib\/python3.9\/site-packages\/librosa\/init.py\",\nline 209, in \nfrom . import core File \"\/Library\/Frameworks\/Python.framework\/Versions\/3.9\/lib\/python3.9\/site-packages\/librosa\/core\/init.py\",\nline 6, in \nfrom .audio import * # pylint: disable=wildcard-import File \"\/Library\/Frameworks\/Python.framework\/Versions\/3.9\/lib\/python3.9\/site-packages\/librosa\/core\/audio.py\",\nline 8, in \nimport soundfile as sf File \"\/Library\/Frameworks\/Python.framework\/Versions\/3.9\/lib\/python3.9\/site-packages\/soundfile.py\",\nline 162, in \n_snd = _ffi.dlopen(_os.path.join( OSError: cannot load library '\/Library\/Frameworks\/Python.framework\/Versions\/3.9\/lib\/python3.9\/site-packages\/_soundfile_data\/libsndfile.dylib':\ndlopen(\/Library\/Frameworks\/Python.framework\/Versions\/3.9\/lib\/python3.9\/site-packages\/_soundfile_data\/libsndfile.dylib,\n0x0002): tried:\n'\/Library\/Frameworks\/Python.framework\/Versions\/3.9\/lib\/python3.9\/site-packages\/_soundfile_data\/libsndfile.dylib'\n(no such file)\nProcess finished with exit code 1\n\nI installed the libsndfile library with homebrew and also for a virtual conda environment. When trying to run the program in the conda environment it produces the following error:\n\nTraceback (most recent call last): File\n\".conda\/envs\/bloompipe_synthesis\/lib\/python3.9\/site-packages\/soundfile.py\",\nline 143, in \n_snd = _ffi.dlopen(_libname) OSError: cannot load library '.conda\/envs\/bloompipe_synthesis\/bin\/..\/lib\/libsndfile.dylib':\ndlopen(.conda\/envs\/bloompipe_synthesis\/bin\/..\/lib\/libsndfile.dylib,\n0x0002): Library not loaded: @rpath\/libvorbis.0.4.9.dylib Referenced\nfrom:\n.conda\/envs\/bloompipe_synthesis\/lib\/libsndfile.1.0.31.dylib\nReason: tried:\n'.conda\/envs\/bloompipe_synthesis\/lib\/libvorbis.0.4.9.dylib'\n(no such file),\n'.conda\/envs\/bloompipe_synthesis\/lib\/libvorbis.0.4.9.dylib'\n(no such file),\n'.conda\/envs\/bloompipe_synthesis\/lib\/libvorbis.0.4.9.dylib'\n(no such file),\n'.conda\/envs\/bloompipe_synthesis\/lib\/libvorbis.0.4.9.dylib'\n(no such file),\n'.conda\/envs\/bloompipe_synthesis\/lib\/python3.9\/site-packages\/..\/..\/libvorbis.0.4.9.dylib'\n(no such file),\n'.conda\/envs\/bloompipe_synthesis\/lib\/libvorbis.0.4.9.dylib'\n(no such file),\n'.conda\/envs\/bloompipe_synthesis\/bin\/..\/lib\/libvorbis.0.4.9.dylib'\n(no such file), '\/usr\/local\/lib\/libvorbis.0.4.9.dylib' (no such file),\n'\/usr\/lib\/libvorbis.0.4.9.dylib' (no such file)\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last): File\n\"Bloompipe\/Synthesis_Module\/bloompipe_synthesis\/testSynthesis.py\",\nline 6, in \nfrom LSD.lucidsonicdreams import LucidSonicDream File \"Bloompipe\/Synthesis_Module\/bloompipe_synthesis\/LSD\/lucidsonicdreams\/init.py\",\nline 1, in \nfrom .main import * File \"Bloompipe\/Synthesis_Module\/bloompipe_synthesis\/LSD\/lucidsonicdreams\/main.py\",\nline 15, in \nfrom .AudioAnalyse import * File \"Bloompipe\/Synthesis_Module\/bloompipe_synthesis\/LSD\/lucidsonicdreams\/AudioAnalyse.py\",\nline 3, in \nimport librosa.display File \".conda\/envs\/bloompipe_synthesis\/lib\/python3.9\/site-packages\/librosa\/init.py\",\nline 209, in \nfrom . import core File \".conda\/envs\/bloompipe_synthesis\/lib\/python3.9\/site-packages\/librosa\/core\/init.py\",\nline 6, in \nfrom .audio import * # pylint: disable=wildcard-import File \".conda\/envs\/bloompipe_synthesis\/lib\/python3.9\/site-packages\/librosa\/core\/audio.py\",\nline 8, in \nimport soundfile as sf File \".conda\/envs\/bloompipe_synthesis\/lib\/python3.9\/site-packages\/soundfile.py\",\nline 162, in \n_snd = _ffi.dlopen(_os.path.join( OSError: cannot load library '.conda\/envs\/bloompipe_synthesis\/lib\/python3.9\/site-packages\/_soundfile_data\/libsndfile.dylib':\ndlopen(.conda\/envs\/bloompipe_synthesis\/lib\/python3.9\/site-packages\/_soundfile_data\/libsndfile.dylib,\n0x0002): tried:\n'.conda\/envs\/bloompipe_synthesis\/lib\/python3.9\/site-packages\/_soundfile_data\/libsndfile.dylib'\n(no such file)\nProcess finished with exit code 1\n\nThe thing is that in both cases it is looking for the .dylib files in the wrong directories. My homebrew installation is in \/opt\/homebrew\/lib and has the files libsndfile.dylib and libsndfile.1.dylib in it and also the libvorbis.dylib file. When trying to run on the global python environment it is looking for those files in \/Library\/Frameworks\/Python.framework\/Versions\/3.9\/lib\/python3.9\/site-packages\/_soundfile_data\/ though.\nMy conda installation is in \/opt\/anaconda3\/lib and has the files libsndfile.dylib, libsndfile.1.0.31.dylib and libsndfile.1.dylib in it and also the libvorbis.dylib and libvorbis.0.4.9.dylib file. When trying to run on the conda python environment it is looking for those files in .conda\/envs\/bloompipe_synthesis\/lib\/python3.9\/site-packages\/_soundfile_data\/.\nIn both cases when looking in those site-packages directories, the _soundfile_data folder doesn't exist even when activating the hidden files. I don't know why that doesn't exist.\nI tried executing:\n\nexport CPATH=\/opt\/homebrew\/include\nexport LIBRARY_PATH=\/opt\/homebrew\/lib\nexport PYTHONPATH=\/opt\/homebrew\/lib\n\nTo include the paths into the python path when running\nThen I printed the path variables with import sys and print(sys.path), this was the output for my global python:\n\n['Bloompipe\/Synthesis_Module\/bloompipe_synthesis',\n'Bloompipe\/Synthesis_Module\/bloompipe_synthesis',\n'\/Library\/Frameworks\/Python.framework\/Versions\/3.9\/lib\/python39.zip',\n'\/Library\/Frameworks\/Python.framework\/Versions\/3.9\/lib\/python3.9',\n'\/Library\/Frameworks\/Python.framework\/Versions\/3.9\/lib\/python3.9\/lib-dynload',\n'\/Library\/Frameworks\/Python.framework\/Versions\/3.9\/lib\/python3.9\/site-packages',\n'opt\/homebrew\/lib']\n\nAnd for the conda environment I tried:\n\nconda develop .conda\/envs\/bloompipe_synthesis\/lib\nconda develop \/opt\/homebrew\/lib\nconda develop \/opt\/anaconda3\/lib\n\nThen the sys.path output is:\n\n['Bloompipe\/Synthesis_Module\/bloompipe_synthesis',\n'.conda\/envs\/bloompipe_synthesis\/lib\/python39.zip',\n'.conda\/envs\/bloompipe_synthesis\/lib\/python3.9',\n'.conda\/envs\/bloompipe_synthesis\/lib\/python3.9\/lib-dynload',\n'.conda\/envs\/bloompipe_synthesis\/lib\/python3.9\/site-packages',\n'.conda\/envs\/bloompipe_synthesis\/lib',\n'\/opt\/homebrew\/lib',\n'\/opt\/anaconda3\/lib']\n\nWeirdly, python is still not looking in those directories when executing the librosa import.\nFinally, I tried adding the path to the homebrew installation manually by putting sys.path.append(\"\/opt\/homebrew\/lib\") in the beginning of the python file. It still produces the exact same errors.\nSo my question is, why does the _soundfile_data directory not exist in my site-packages folders for the global python and the conda environment and why doesn't it include the .dylib files for libsndfile?\nSecondly, why does:\n\nexport LIBRARY_PATH=\/opt\/homebrew\/lib\nexport PYTHONPATH=\/opt\/homebrew\/lib\n\nnot do that those paths appear when printing the sys.path content?\nThirdly, why does python not find the libsndfile.dylib files with the conda environment, even though I added the homebrew and the conda installation of libsndfile to the sys path with the conda develop command?\nMy python3.9 is installed in \/usr\/local\/bin\/python3.9 and my conda python3.9 environment is installed in \/.conda\/envs\/bloompipe_synthesis\/bin\/python\nI'm on a new mac with Mac OS Monterey.\nAny help is greatly appreciated!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":664,"Q_Id":72623930,"Users Score":0,"Answer":"As far as I know it only works with python 3.6 and 3.7 (lucidsonicdreams), although I didn't have success on 3.6.\nI had to create a virtual environment through conda and run code through Jupyter notebook. conda install tensorflow==1.15 (will not work with higher versions), python==3.7, pip install lucidsonicdreams in your new python 3.7 environment.\nMake sure module versions line up with your Nvidia CUDA drivers or lucidsonicdreams won't work.","Q_Score":0,"Tags":"python,anaconda,pythonpath,librosa,libsndfile","A_Id":74643934,"CreationDate":"2022-06-14T22:10:00.000","Title":"Python linking to wrong library folder - sndfile library not found","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Hi I am having a really weird issue with a simple python script.\nI created it in one folder, A, and have later copied it to a new folder B.\nHowever when I add folder B as a project folder in Atom and run the script, it behaves as if it is still located in folder A.\nI can find no references to folder A, nothing in the script for sure and can't see anything in file properties that should give this result??\nRunning os.path.realpath() gives me the old folder A, and any output files I generate while running the script in folder B gets saved to folder A.\nAm I missing a \"magic\" way of copying python scripts to new locations?\nHope someone can help :)\n-Thomas\nedit: just realised it might be important that I am using Atom with the Hydrogen plugin to run the script and I have added folder B as a projekt folder.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":23,"Q_Id":72656518,"Users Score":0,"Answer":"\/etc\/profile.d would add it to every user's path\n~\/.bashrc would just be your own\nyou can always do \"$ source ~\/.bashrc\" to re-read the config files.","Q_Score":0,"Tags":"python,path,os.path,working-directory","A_Id":72656624,"CreationDate":"2022-06-17T08:36:00.000","Title":"copy python script to new location wont update path","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am currently deploying some code on a fleet of raspberry pi systems. The systems all have python 3.7.x installed but one of my team's custom libraries has some python 3.8 features (a few walrus operators, etc). I need to modify my library to remove all of the 3.8 features so that the code runs on these machines. I am not able to update the python version on them. Is there a script or tool that exists to batch check if a file or folder of files is compatible with python 3.7? I'm thinking something similar to how flake8 or black can check for issues.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":72,"Q_Id":72661685,"Users Score":3,"Answer":"Run a static analysis tool, like pylint or mypy, and make sure that it's running on the appropriate version of Python. One of the first things these tools do is parse the code using the Python parser, and they'll report any SyntaxErrors they find.","Q_Score":2,"Tags":"python,python-3.x","A_Id":72662635,"CreationDate":"2022-06-17T15:32:00.000","Title":"How to parse Python files to see if they are compatible with Python 3.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"The title really says it all. Files in my PYTHONPATH are not recognized when I run scripts (ModuleNotFoundError: No module named ), but they are when I open the interactive prompt in the command line. I'm running ubuntu 22.04. What could be causing this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":27,"Q_Id":72665661,"Users Score":0,"Answer":"I had a similar problem that was caused by python cache directories in a parent directory of my script. I deleted them and now the path works as expected.","Q_Score":0,"Tags":"python,linux,ubuntu,path,pythonpath","A_Id":72673963,"CreationDate":"2022-06-17T23:34:00.000","Title":"Pythonpath only recognized in interactive teminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a aiogram dispatcher instance. Its async function start_polling() is meant to continuously request Telegram API server for updates. I don't think it really matters because the following, imo, applies to all coroutines. I want to run the coroutine in the background so I can do other things in the thread.\ndispatcher.start_polling() This throws an error of 'coroutine never awaited'\nasyncio.get_event_loop().run_until_complete(dp.start_polling()) This takes the thread\nI also tried create_task and run_forever but those also freeze the thread.\nI came here from JavaScript so I expected the first code to run the coroutine in 'background' because that's what async is for as I understand. I guess using threads are not an option because that's what I'm trying to avoid using async.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":318,"Q_Id":72675371,"Users Score":0,"Answer":"After some researching I'm back with an understanding of asyncio basics. Turns out you can't have async and sync code together, because global sync code will block async flow, instead in global of thread you gotta run asyncio.run(main_func()) and in main_func you should write create_task or gather, depending on the need of result and cooperation. So, no awaits means no async. Awaits give time for other functions to execute.","Q_Score":0,"Tags":"python,asynchronous,async-await,python-asyncio,coroutine","A_Id":72705834,"CreationDate":"2022-06-19T08:30:00.000","Title":"How to run an asyncio coroutine in background?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm building a pyd file via pybind11. There's no python-only code in the project (not even in the final wheel). I'm packing this prebuilt pyd into a wheel package. It's all working well so far, but I've got one small issue. Every time I want to use the functions from the pyd file (which is actually the primary \"source\" of code) I have to type the following: from python_lib_name.pyd_name import pyd_exported_class example: from crusher.crusher import Shard. This looks pretty lame, is there any way to prevent this and let the developer simply use the from crusher import Shard syntax?\nAlso, I'm not sure what information to provide, obviously, I wouldn't like to throw the whole project at you unnecessarily. I'm glad to provide any details by editing.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":215,"Q_Id":72677322,"Users Score":-1,"Answer":"One way to make a pyd file simply importable is to use the Python interpreter's -m flag. For example, if your file is called foo.pyd and is located in the current directory, you can import it by running the following command:\npython -m foo\nThis will cause the Python interpreter to load the module from foo.pyd and then execute its contents as if they were written in a normal .py file. You can also use this technique to import modules that are located in different directories; just specify the path to the module as an argument to -m.\nAnother way to make a pyd file simply importable is to convert it into a normal .py file.","Q_Score":0,"Tags":"python,python-3.x,setuptools,python-wheel","A_Id":72677354,"CreationDate":"2022-06-19T13:39:00.000","Title":"How to simply call a PYD from a wheel installed package?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to fetch Twitter data from multiple Tweet IDs using Twitter API?\nIt is showing\n{\"errors\":[{\"message\":\"You currently have Essential access which includes access to Twitter API v2 endpoints only. If you need access to this endpoint, you\u2019ll need to apply for Elevated access via the Developer Portal. You can learn more here: https:\/\/developer.twitter.com\/en\/docs\/twitter-api\/getting-started\/about-twitter-api#v2-access-leve\",\"code\":453}]}\nIs there any way to fetch with only having essential access ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":27,"Q_Id":72680181,"Users Score":0,"Answer":"As said try applying for elevated access via the Developer portal.\nAs soon as you get the access, you'll be able to fetch the data from Twitter API's itself.","Q_Score":1,"Tags":"python,twitter,twitterapi-python","A_Id":72680197,"CreationDate":"2022-06-19T20:35:00.000","Title":"Fetch Twitter ID","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have tried using the command line to run the import, I have reinstalled python, I've checked my interpreter, I have spent hours of searching, and nothing works. I have tried using pip install -U discord-py-interactions and pip install -U discord-py-slash-command but neither of them have worked. It just keeps saying ModuleNotFoundError: No module named 'discord_slash'. Does anyone have any idea what's going on? Thanks for any help.","AnswerCount":1,"Available Count":1,"Score":-0.3799489623,"is_accepted":false,"ViewCount":506,"Q_Id":72748847,"Users Score":-2,"Answer":"Try with pip install discord-py-slash-command","Q_Score":0,"Tags":"python,discord,discord.py","A_Id":74963103,"CreationDate":"2022-06-24T19:55:00.000","Title":"discord-py-slash-command import problems, cant use discord_slash","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"After I used Codeartifact for installing a package once,\npip stopped trying public Pypi and prompts for my codeartifact credentials every time.\n\nI have checked the .pypirc and it does not contain anything regarding CodeArtifact\n\nCan somebody please suggest what could be the problem or direct me on the right way to investigate it myself?\n\n\nI am not a great specialist of pip and usually install\nmy packages only through the IDE plugins (which seem to work just fine),\nBut this is problematic when running scripts that contain pip install's.\nThanks in Advance!\n-- EDIT : I edited pip.conf as well to specifically point to the public pypi. Didn't help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":305,"Q_Id":72770814,"Users Score":0,"Answer":"What was the edit on the pip.conf I had the same issue and by changing the pip.conf from awsartifact to :\ntrusted-host = pypi.python.org pypi.org files.pythonhosted.org\nIt worked","Q_Score":4,"Tags":"python,pip,pypi,aws-codeartifact","A_Id":74015621,"CreationDate":"2022-06-27T10:44:00.000","Title":"Pip doesnt recognise public pypi after codeartifact used once","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to run a python script called process.py\nIt did the job when i type through the terminal such as python3.9 \/home\/pi\/Program\/process.py\nThen I set it up into crontab with the idea so it can run automatically every 5 PM with format like this --> 0 17 * * 1-5 python3.9 \/home\/pi\/Program\/process.py , but it doesn't work as i type it manually in the terminal\nPlease help, i have been going through this issue for hours and cannot find the solution","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":65,"Q_Id":72772071,"Users Score":1,"Answer":"If python3.9 is not in \/bin it'll crash.\nAlso, cron runs with sh, for specifying bash you should run bash python3.9 \/home\/pi\/Program\/process.py\n\nTry providing it a full path, like \/usr\/local\/bin\/python3.9 \/home\/pi\/Program\/process.py\n\nRun sudo tail -f \/var\/log\/syslog | grep -C 5 cron to see what was the exact error and continue from there.\n\n\n\nsyslog can also be under \/val\/log\/messages","Q_Score":0,"Tags":"python,cron,raspberry-pi","A_Id":72772702,"CreationDate":"2022-06-27T12:24:00.000","Title":"Python script can be run manually in my Raspberry Pi 4, but it cannot be executed automatically every 5 PM through crontab","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm maintinaing a library of python code. All bar one of the modules in the library runs through pylint with no problems.\nFor this one module pylint returns error F0010.\n.py:1: [F0010(parse-error), ] error while code parsing: Wrong or no encoding specified for .py\nI've stared at the code for hours and I can't see quite what's so special about it. There is nothing that jumps out at me as being different in any substantial way to the other modules in the library. File names, headers, footers are all very similar, PEP8 etc etc.\nDoes anyone have any hints for debugging this error?\nIf nothing else I'd like to have a pylint score for it so I can justify its existence in its current form, and I really don't want to rewrite it from scratch to appease pylint.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":189,"Q_Id":72787158,"Users Score":1,"Answer":"Turns out I've managed to fix the problem.\nWhoever edited it last saved it as ANSI rather than UTF-8.\nThanks for the pointers, as its not somethign I would have thought of checking. I found this out when I was looking to see what it was actually encoded as, in response to the comments above. I'd have assumed it was UTF-8 as all the other files in the library are UTF-8, in fact everything here is utf-8, apart from this one file...\nNow to up its pylint score a bit.","Q_Score":1,"Tags":"python-3.x,pylint","A_Id":72793741,"CreationDate":"2022-06-28T13:17:00.000","Title":"Pylint Wrong or no encoding specified","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We would like to bring one of our layout algorithms, which is implemented in Python, to Cytoscape. As Cytoscape apps are written in Java, I was wondering whether some of you has an idea on how to easily bring it to Cytoscape without rewriting the Algorithm in Java.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":34,"Q_Id":72792896,"Users Score":0,"Answer":"I believe Dexter already reached out to you, but the easiest path would be to use a REST service of some sort, either a local one or one on a remote server.\n-- scooter","Q_Score":1,"Tags":"python,java,networking,cytoscape","A_Id":72818436,"CreationDate":"2022-06-28T20:38:00.000","Title":"Bringing Python layout algorithm to Cytoscape","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"My domain name is 'example.com' and I need to create subdomain for every store created in that site like 'store1.examaple.com', 'store2.examaple.com'.\nCode for every subdomain is the same.\ncurrently my project is deployed on pythonanywhere and I already have custom domain.\nSo is it possible to dynamically create multiple subdomain in pythonanywhere same as Shopify ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":116,"Q_Id":72797334,"Users Score":2,"Answer":"On PythonAnywhere you would need separate web app for each subdomain. You could use API to create them programmatically.","Q_Score":1,"Tags":"python,django,shopify,subdomain,pythonanywhere","A_Id":72798643,"CreationDate":"2022-06-29T07:23:00.000","Title":"Create subdomains like Shopify in pythonanywhere","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I came across an issue with performance testing of payments-related endpoints.\nBasically I want to test some endpoints that make request themselves to a 3rd-party providers' API.\nIs it possible from Locust's tests level to mock those 3rd-party API for the endpoints I intend to actually test (so without interference with the tested endpoints)?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":220,"Q_Id":72802596,"Users Score":0,"Answer":"I actually skipped the most important part of the issue, namely I am testing the endpoints from outside of the repo containing them (basically my load test repo calls my app repo). I ended up mocking the provider inside of the app repo, which I initially intended to avoid but turned out to be only reasonable solution at the moment.","Q_Score":0,"Tags":"python,testing,performance-testing,load-testing,locust","A_Id":73148442,"CreationDate":"2022-06-29T13:52:00.000","Title":"Performance testing with Locust with mocking 3rd party API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I came across an issue with performance testing of payments-related endpoints.\nBasically I want to test some endpoints that make request themselves to a 3rd-party providers' API.\nIs it possible from Locust's tests level to mock those 3rd-party API for the endpoints I intend to actually test (so without interference with the tested endpoints)?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":220,"Q_Id":72802596,"Users Score":1,"Answer":"If I understand correctly, you have a service you'd like to load\/performance test but that service calls out to a third-party. But when you do your testing, you don't want to actually make any calls to the third-party service?\nLocust is used for simulating client behavior. You can define that client behavior to be whatever you want; typically it's primary use case is for making http calls but almost any task can be done.\nIf it's your client that makes a request to your service and then makes a separate request to the other third-party service for payment processing, yes, you could define some sort of mocking behavior in Locust to make a real call to your service and then mock out a payment call. But if it's your service that takes a client call and then makes its own call to the third-party payment service, no, Locust can't do anything about that.\nFor that scenario, you'd be best off making your own simple mock\/proxy service of the third-party service. It would take a request from your service, do basic validation to ensure things are coming in as expected, and then just return some canned response that looks like what your service would expect from the third-party. But this would be something you'd have to host yourself and have a method of telling your service to point to this mock service instead (DNS setting, environment variable, etc.). Then you could use Locust to simulate your client behavior as normal and you can test your service in an isolated manner without making any actual calls to the third-party service.","Q_Score":0,"Tags":"python,testing,performance-testing,load-testing,locust","A_Id":72803668,"CreationDate":"2022-06-29T13:52:00.000","Title":"Performance testing with Locust with mocking 3rd party API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"so I have a lot (thousands of single scripts) that use the same library (self-developed) by importing *.\nIs there a way for me to see\/print the execution time for each script without modifying every single script, probably define at the library but expecting it to print before the code ends?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":32,"Q_Id":72824590,"Users Score":-1,"Answer":"You can't put time recording inside the library.\nYou will either have to put it inside each and every script.\nMay I ask how are you calling these 1000s of scripts? you can put the timer wherever it is you're calling these scripts from","Q_Score":0,"Tags":"python,python-3.x","A_Id":72824777,"CreationDate":"2022-07-01T05:06:00.000","Title":"Show execution time for every script that imports a specific module (without defining it inside the script)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What aspects do (and do not) effect the speed at which a computer can read files? Say for example, Python reading a CSV.\nI am guessing cores do not matter. I am guessing even threads don't matter. But perhaps the ghz matter?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":68,"Q_Id":72843917,"Users Score":2,"Answer":"Maybe?\nWe are missing too much information to reach a conclusion. For a large file, you will likely be constrained by the slowest step in the parsing process. That could be reading from the disk, accessing RAM, parsing the raw data on the CPU or a large number of other things. The number of cores might matter. Without knowing how the CSV parser is implemented, we can't be sure though. Maybe it breaks the CSV into chunks so it can be parsed by multiple cores.\nThe bottom line is if you want a definite answer you need to profile the application you have questions about. We can make as many guesses as we want, but at the end of the day profiling the program is the only way to know for sure.","Q_Score":0,"Tags":"python,cpu","A_Id":72843956,"CreationDate":"2022-07-03T04:28:00.000","Title":"Does a more powerful CPU read files faster (ex: a CSV?)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What aspects do (and do not) effect the speed at which a computer can read files? Say for example, Python reading a CSV.\nI am guessing cores do not matter. I am guessing even threads don't matter. But perhaps the ghz matter?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":68,"Q_Id":72843917,"Users Score":2,"Answer":"That depends on what's limiting the read operation.\nMost things are either I\/O bound or CPU bound.\nBasically: If the CPU is giving instructions to fetch data and move it around, but the data has to come from the network or a (slow) disk, a faster CPU won't help as the program (and the CPU) spends most of its time waiting for data to arrive.\nIf, on the other hand, the program itself gives the CPU so much work that a slow CPU can't keep up, then a faster CPU does speed things up.","Q_Score":0,"Tags":"python,cpu","A_Id":72843954,"CreationDate":"2022-07-03T04:28:00.000","Title":"Does a more powerful CPU read files faster (ex: a CSV?)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to create a measurement device which can be controlled with a smart phone.\nMy situation\n\nThe places where I'm using the device don't have any internet connection available.\nThe measurement device uses a Raspberry PI, which creates a local WiFi network to communicate with the smart phone.\nThere is a Python webserver running on the RPI.\nThe smart phone has a PWA installed to send commands to the RPI's webserver.\nThe PWA is hosted on GitHub Pages (uses HTTPS by default).\nAfter installation the PWA is supposed to work without an internet connection (just uses the RPI WiFi).\n\nMy goal is to successfully send requests to the Python webserver on the RPI by using the PWA on my smart phone.\nMy issue\nWhen fetching the Python webserver within the PWA, I receive a Mixed Content error because the PWA is hosted on HTTPS (and also requires HTTPS) but the Python server is not.\nWhen I tried using a self signed certificate created with OpenSSL, I receive a ERR_CERT_AUTHORITY_INVALID error.\nI tried to use Let's Encrypt, but CertBot requires an actual domain. I only have an IP adress, which is the RPI's IP within its own WiFi network.\nWhat should I do?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":79,"Q_Id":72847986,"Users Score":0,"Answer":"I fixed my issue by registering a free .tk domain pointing to 127.0.0.1 (localhost) and using Certbot from Let's Encrypt to create a SSL Certificate.\nTo validate the domain with Certbot I've used the TXT record validation.\nIn order to make use of the domain without an internet connection I've added a DNS record with the same .tk domain pointing to localhost inside the dnsmasq config file of the RPI.\nMy python webserver then uses the cert file to establish serving over HTTPS so the SPA on my mobile device won't throw an error when requesting data.","Q_Score":0,"Tags":"python,ssl,wifi,progressive-web-apps","A_Id":73015304,"CreationDate":"2022-07-03T15:59:00.000","Title":"SSL issue when trying to communicate with Python webserver on Raspberry PI by using a Progressive Web App","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Ranorex 10 version is used.\nFor tests with the exact work flow, ranorex spy is sometimes able to find the element and the other times it only keeps searching and the script gets timed out.\nTried providing the whole path instead of just the automation id, it didn't work.\nCan anything else be done?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":197,"Q_Id":72860714,"Users Score":0,"Answer":"Do you try to test a desktop app or a webbrowser app?\nWithout further information it is difficult to examine the problem, unfortunately.\nBut it can be helpful checking following things:\n\nFor a webbrowser app, please check the ranorex browser extension\nplease check your root path (of the element). maybe for some reasons it changes from time to time and the element cannot be found. Try to make the path more unspecific\nCheck your whitelist in ranorex","Q_Score":0,"Tags":"python,automation,ui-automation,ui-testing,ranorex","A_Id":72908597,"CreationDate":"2022-07-04T18:21:00.000","Title":"Finding elements using Ranorex spy is inconsistent","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I assume that lifelines.CoxPHFitter is using a Likelihood-ratio test (or is it using Wald?) to calculate p-values when testing for significance. But I have to be sure: is there an official source where I can find what test are used? (I was not successful searching threw the documentation of lifelines)\nIs lifelines.CoxPHFitter using the same test while performing a univariate and multivariate Cox Regression?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":123,"Q_Id":72880136,"Users Score":1,"Answer":"The CoxPHFitter computes p-values using the chi-squared test. The reference is in \"Survival Analysis by John P. Klein and Melvin L. Moeschberger, Second Edition\", page 256","Q_Score":0,"Tags":"python,statistics,survival-analysis,cox-regression,lifelines","A_Id":72972340,"CreationDate":"2022-07-06T08:23:00.000","Title":"lifelines.CoxPHFitter - how are the p-values calculated?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"While I have been writing programs since high school (that's really old school to some of you) I am still quite new to [Micro]Python.\nI understand this question may have been answered elsewhere, but no suitable MicroPython solutions have shown up in my searches (solutions are usually Arduino or full Python).\nCurrent device and firmware:\nThonny IDE\nESP32 Lilygo TTGO T-Display\nThis model has a display and battery charger\/monitor circuit onboard (reading it is another matter) - from Aliexpress.\nLilygo's documentation for MicroPython is non-existant.\nMicroPython v1.18-128-g2ea21abae-dirty on 2022-02-12\nTTGO T-Display driver included, russhughes version from github\nBesides a salvaged flat lithium battery and using USB connection, no other devices added.\nNo datetime module in firmware (so no datetime.datetime.now() options)\nutime seems to use the time from the COMPUTER(!!) to report time values (8 element tuple) when I use it in Thonny and not from the ESP32 (the tuple should all start at 0).\nAnd forget using help('[object name]'), it treats the term as a string and reports all the stringy things you can do (help('modules') is the only one that works otherwise \"object [term] is of type str\") <- I've tried with and without the quotes.\nI am wanting to get the standalone uptime since the ESP32 started running the MicroPython program (I.E. 0 seconds starting point) so I can time how long the battery will last - I can't seem to find a reliable coding to read the battery charge (no two seem to fully agree on a method, appears to be great discussion on accuracy, and mostly in Arduino\/C code). Lilygo's Arduino\/C battery code is hidden in their demo firmware - both shipped and flashable from github, so no translation from that (at least by me).\nI want to display the uptime on the tft display, serial monitor, and save it to a file every minute so I can retrieve it on next boot. The main program is a webserver (modified codemee github ESPWebServer). Once I have a decent average time, I can use that for a safe shutdown time.\nIf there is a transferable version of datetime.py (udatetime.py?) that I could put on the local file system and import, I think that this would be the best option but any option that lets me time the uptime is welcomed.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":393,"Q_Id":72894861,"Users Score":0,"Answer":"@nekomatic: When I used utime while Thonny was running, the tuple that was reported was based on the time from my computer (that day's information as of the time of processing)\nAs I stated earlier, I am quite new to [Micro]Python. I didn't know about machine.RTC.\nhelp() is quite useless on the several firmwares I have tried ('offical' MicroPython and the variants that include various drivers). help('modules') lists the modules but help('[module name]') is treated as asking about a string, so no information is given about the modules. Without the quotes, it generates an error.\nThanks to your link, I added\nimport machine\nrtc = machine.RTC()\nprint(rtc.datetime())\nand it works (reports the ESP32's time relative to January 1st 2000), but rtc.now() generates an error\nprint(rtc.now())\nAttributeError: 'RTC' object has no attribute 'now'\nThis is a start and thank you.\nNote: after repetitive reruns\/restarts, the information returned flip flops between the ESP32 and the PC (sometimes starts with (2000, 1, 1), others (2022, 7, 8) as of today). So as a standalone it should be only the ESP32's datetime info as it can't access the computer's data.)\nAlso appears time.time() is available.\nNow to figure out how to call a write to file function every minute without sched, threading, and other useful full Python modules.","Q_Score":0,"Tags":"timer,micropython","A_Id":72916625,"CreationDate":"2022-07-07T08:49:00.000","Title":"Micropython: Get time since bootup\/program start","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am testing an aiohttp app with web.run. I instantiate an imported class just after the import declaration and the a value of this instance is changed by data channel( for instance.changevalue() function). It works well for a single user. But when I test this from two users( mobile and laptop at the same time), The changed value from one device is reflected on the other device.\nIs this because of aiohttp running in standalone? or I am doing something wrong with my class instance?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":12,"Q_Id":72895956,"Users Score":0,"Answer":"It worked after I used gunicorn to manage more than one process.","Q_Score":0,"Tags":"python,aiohttp,class-instance-variables","A_Id":72953769,"CreationDate":"2022-07-07T10:06:00.000","Title":"aiohttp instance variable values shared by different users?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an AES encrypted file in python. Lets call it encrypted.exe.\nI have the key for the encryption. I can then use python to decrypt my file (Cipher module in python) and obtain decrypted.exe. I then save the file (using write). Later I can run the file by clicking on it or through a cmd or powershell.\nWhat I want to do is be able to run the decrypted.exe without saving it. For instance I thought about, decrypting with my AES key then loading it in the RAM and run it from there.\nI don't know how to do it nor if it is possible with python.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":72928096,"Users Score":0,"Answer":"I would say you can, but it\u2019s more than overhead. It\u2019s really complex task, so I would recommend to save file to hard drive, than use subprocess or os library to execute it, then delete it.","Q_Score":1,"Tags":"python,memory","A_Id":72928156,"CreationDate":"2022-07-10T11:20:00.000","Title":"Run an encrypted program without saving it with python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a small python program that tries to find images similar enough to some already in a database (to detect duplicates that have been resized\/recompressed\/etc). I am using the imagehash library and average hashing, and want to know if there is a hash in a known database that has a hamming distance lower than, say, 3 or 4.\nI am currently just using a dictionary that matches hashes to filenames and use brute force for every new image. However, with tens or hundreds of thousands of images to compare to, performance is starting to suffer.\nI believe there must be data structures and algorithms that can allow me to search a lot more efficiently but wasn\u2019t able to find much that would match my particular use case. Would anyone be able to suggest where to look?\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":105,"Q_Id":72973529,"Users Score":1,"Answer":"Here's a suggestion. You mention a database, so initially I will assume we can use that (and don't have to read it all into memory first). If your new image has a hash of 3a6c6565498da525, think of it as 4 parts: 3a6c 6565 498d a525. For a hamming distance of 3 or less any matching image must have a hash where at least one of these parts is identical. So you can start with a database query to find all images whose hash contains the substring 3a6c or 6565 or 498d or a525. This should be a tiny subset of the full dataset, so you can then run your comparison on that.\nTo improve further you could pre-compute all the parts and store them separately as additional columns in the database. This will allow more efficient queries.\nFor a bigger hamming distance you would need to split the hash into more parts (either smaller, or you could even use parts that overlap).\nIf you want to do it all in a dictionary, rather than using the database you could use the parts as keys that each point to a list of images. Either a single dictionary for simplicity, or for more accurate matching, a dictionary for each \"position\".\nAgain, this would be used to get a much smaller set of candidate matches on which to run the full comparison.","Q_Score":3,"Tags":"python,algorithm,data-structures,hash","A_Id":72973870,"CreationDate":"2022-07-13T23:00:00.000","Title":"More efficient data structure\/algorithm to find similar imagehashes in database","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently installed python3 on my vps, I want to enable it as default, so that when I type\npython I get python 3. I think the problem is its installed in \/usr\/local\/bin instead of \/usr\/bin\/ typing python on the terminal access python2 typing python3 returns bash: python3: command not found \nMost answers I have seen is a bit confusing as I am not a centos expert.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":355,"Q_Id":72979838,"Users Score":0,"Answer":"for a simple fix, you can use alias\nadd the alias to your .bashrc file\nsudo vi ~\/.bashrc\nthen add your alias at the bottom\nalias python=\"python3.9\"\nSo that when you type python you'll get python 3","Q_Score":0,"Tags":"python,centos,vps","A_Id":74793748,"CreationDate":"2022-07-14T11:33:00.000","Title":"How to make python 3.9 my default python interpreter on centos","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am running a code with uses authlib module and it runs fine with all dependency met but when I try to automate it through bmc control-m it gives module not found error. Any help would be really appreciated.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":55,"Q_Id":73000588,"Users Score":0,"Answer":"Are you using the same userid for the Control-M job as when running directly? Also, verify the running mode of the Control-M Agent - does it run as root or via a fixed userid?","Q_Score":0,"Tags":"python-3.x,cryptography,modulenotfounderror,control-m,authlib","A_Id":73001788,"CreationDate":"2022-07-15T23:59:00.000","Title":"Authlib module not found on bmc control-m","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running a code with uses authlib module and it runs fine with all dependency met but when I try to automate it through bmc control-m it gives module not found error. Any help would be really appreciated.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":55,"Q_Id":73000588,"Users Score":1,"Answer":"So the issue is resolved I installed the authlib and cryptography modules by running the shell as administrator on prod server.","Q_Score":0,"Tags":"python-3.x,cryptography,modulenotfounderror,control-m,authlib","A_Id":73029303,"CreationDate":"2022-07-15T23:59:00.000","Title":"Authlib module not found on bmc control-m","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to develop a program to allow communication between my windows PC and a Raspberry Pi via bluetooth. Things have been moving smoothly on the Pi, but on my PC I cannot seem to get the bluetooth module to work correctly and I haven't seen anyone with the same error message I am getting.\nI have pybluez installed, but when I try to import the bluetooth module I get the following error message: module 'socket' has no attribute 'BTPROTO_RFCOMM'. I get this error message when all I run is import bluetooth.\nI also tried using sockets but I get the error: module 'socket' has no attribute 'AF_BLUETOOTH'.\nI am wondering if I am missing something that is causing my socket module to not work.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":262,"Q_Id":73027625,"Users Score":0,"Answer":"I solved the problem by making a virtual environment and using conda install pybluez just in the environment. This also only worked in certain python versions for me: 2.7 and > 3.9. I canonly run the code from the command line, but works fine now!","Q_Score":0,"Tags":"python,bluetooth,windows-10","A_Id":73125329,"CreationDate":"2022-07-18T19:26:00.000","Title":"Importing bluetooth module to python environment on windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am doing very large data processing (16GB) and I would like to try and speed up the operations through storing the entire file in RAM in order to deal with disk latency.\nI looked into the existing libraries but couldn't find anything that would give me the flexibility of interface.\nIdeally, I would like to use something with integrated read_line() method so that the behavior is similar to the standard file reading interface.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":311,"Q_Id":73043238,"Users Score":0,"Answer":"Homer512 answered my question somewhat, mmap is a nice option that results in caching.\nAlternatively, Numpy has some interfaces for parsing byte streams from a file directly into memory and it also comes with some string-related operations.","Q_Score":0,"Tags":"python,python-3.x,caching,in-memory","A_Id":73073721,"CreationDate":"2022-07-19T20:38:00.000","Title":"Python in-memory files for caching large files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a module TestEndToEndDemo.py in a Python package tests\/.\nWhen I run pytest tests\/*, the module is collected twice and each test within it run twice because of that, but when I run pytest tests\/TestEndToEndDemo.py, the tests are executed only once.\nThere is one @pytest.fixture function used for dependency injection, and two @staticmethod test cases.\nThe tests\/ module contains an empty init.py file.\nPytest --version 7.1.2\nPython3 --version 3.10.4","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":74,"Q_Id":73059007,"Users Score":0,"Answer":"SOLVED:\npytest tests instead of pytest tests\/* removed the duplicates.","Q_Score":0,"Tags":"python,pytest","A_Id":73068966,"CreationDate":"2022-07-20T23:06:00.000","Title":"Pytest collects a module twice with regex '*' argument","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a fork my_foo of a third-party package foo. All I did was add three lines of Python to foo's setup.py, since foo does not pass the correct flags to gcc.\nWhat's the best way to use the fork my_foo in my package bar? Should I create a subpackage bar.my_foo? Should I upload my_foo to PyPI and do install_requires = [\"my_foo\"] in the setup.py of bar? Is there some way to install a package from PyPI with a custom setup.py?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":73070433,"Users Score":0,"Answer":"If the foo library is very popular and will be updated, install it with pip, if not, use the source code","Q_Score":0,"Tags":"python,python-3.x,python-packaging","A_Id":73076033,"CreationDate":"2022-07-21T17:29:00.000","Title":"How should I use a third-party package in my package if I need to edit the third-party package's `setup.py`?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What does hashed mean when applied to a path in linux or Mac bash?\nWhen I use the command in bash:\n\n\n\ntype python3\nI get:\npython3 is hashed (\/usr\/local\/bin\/python3)\n\n\n\nWhat does hashed mean. Sometimes I get hashed and sometimes just the path line.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":154,"Q_Id":73072290,"Users Score":2,"Answer":"Theoretically, every time you type a command name like foo that doesn't include a \/, the shell looks at each directory in your PATH variable to find a command named foo to execute.\nThis is somewhat time-consuming and redundant (your commands don't really move much), so the shell only performs the full PATH lookup once, and caches the result. Typically, it uses a hash table so that command names can be looked up quickly, so \"python3 is hashed (\/usr\/local\/bin\/python3)\" is short for\n\npython3 was found in the hash table and mapped to the path \/usr\/local\/bin\/python3\n\nThe difference between foo is bar and foo is hashed (bar) is that in the former, foo hasn't been executed yet; type itself does not store the result in the hash table on a successful lookup.","Q_Score":1,"Tags":"python,linux,path","A_Id":73072314,"CreationDate":"2022-07-21T20:29:00.000","Title":"What does hashed mean","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"What does hashed mean when applied to a path in linux or Mac bash?\nWhen I use the command in bash:\n\n\n\ntype python3\nI get:\npython3 is hashed (\/usr\/local\/bin\/python3)\n\n\n\nWhat does hashed mean. Sometimes I get hashed and sometimes just the path line.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":154,"Q_Id":73072290,"Users Score":2,"Answer":"It's a performance thing; instead of searching the whole path for the binary every time it is called, it's put into a hash table for quicker lookup. So any binary that's already in this hash table, is hashed. If you move binaries around when they're already hashed, it will still try to call them in their old location.\nSee also help hash, or man bash and search for hash under builtin commands there.","Q_Score":1,"Tags":"python,linux,path","A_Id":73072320,"CreationDate":"2022-07-21T20:29:00.000","Title":"What does hashed mean","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Im trying to write a script:\nenv PYTHONPATH=$PYTHONPATH: $Dir\/scripts find * -name \u2018*.py' -exec pylint (} \\\\; | grep . && exit 1\nThe code is finding all scripts in the root directory instead of using the environmental variables I set. Any help on writing this code to only look for files in the directory I set as a value in PYTHONPATH.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":245,"Q_Id":73074234,"Users Score":0,"Answer":"There\u2019s no space between the PYTHONPATH value, it was a typo mistake, I want to run the command on a CLI instead of a script.","Q_Score":0,"Tags":"python,linux,shell","A_Id":73087742,"CreationDate":"2022-07-22T01:39:00.000","Title":"env command not working with find command","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm developing a simple bot for myself.\nI prompt the user with some inline buttons, which execute some functions on the backend. Since some functions take a little longer to execute, may I graphically show that the button tap was recorded, perhaps with a loading icon? Otherwise, the user might think something went wrong and keep on tapping.\nI'm working on Python with python-telegram-bot v20.0a2.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":327,"Q_Id":73094987,"Users Score":1,"Answer":"the official TG clients will display a loading icon by default until you call answer_callback_query. So you can just delay calling that method until after your backend is done. IIRC after some timeout the icon will vanish on it's own, too, though, if your computation takes too long.","Q_Score":2,"Tags":"python,telegram-bot,python-telegram-bot","A_Id":73095126,"CreationDate":"2022-07-24T00:12:00.000","Title":"Is there a way to display a loading icon on an inline button for telegram bot?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Pycharm to create a simple program that uses snap7 lib. to read a S7-1200 PLC, it works correctly when i run it with Pycharm but when i try to run it with an .exe file it prompts this error message:\nTraceback (most recent call last):\nFile \"main.py\", line 1, in \nModuleNotFoundError: No module named 'snap7'\nthe snap7.dll and .lib are both in sys32 folder aswell as in environment variables PATH route.\nboth the python file and my PC are x64 so i used the x64 version of the DLL and lib files.\nWhat am i missing?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":98,"Q_Id":73102473,"Users Score":0,"Answer":"How did you install the snap7 library?\npy -m pip install python-snap7 is the way i installed it. I never had any problems with it.","Q_Score":0,"Tags":"python,snap7","A_Id":73952223,"CreationDate":"2022-07-24T22:20:00.000","Title":"Snap7 module not found with python .exe","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"How can I get root access on android phone without having to use the SDK tools..is it possible to try it with python and Ubuntu terminal...I have searched online it only suggests other tools like Fastboot which also comes with SDk , ADB...\nCan anyone give me some guidelines where to start?\nand what python packages will be helpful? Kivy framework how helpful it will be..as it is cross platform...PS:I want to learn about Mobile Forensics","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":71,"Q_Id":73114025,"Users Score":0,"Answer":"I am now working with emulator from android Studio it is safer and convenient this way as using a emulator by default root access is given. ADB comes with lots of features and it is also easy to connect python scripts with the virtual device. My host machine is Windows OS I don't even need to use VM.","Q_Score":0,"Tags":"android,python-3.x,ubuntu,bootloader","A_Id":73770590,"CreationDate":"2022-07-25T18:51:00.000","Title":"To get root access using on android phone and unlocking the bootloader","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to access the google sheet of other account like that of my colleague based on my service account?\nI am trying to automate google sheets with Python but most of my sheets are not in one account but on other accounts. I was wondering if I could interact with all of them based on one service account? I am using gspread library for my automation.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":81,"Q_Id":73121204,"Users Score":0,"Answer":"You can access the Google Spreadsheet(s) of your colleague if they have been shared with you or are all contained in a folder that has been shared with you. Depending on what you would like to do, most likely you need an editor permission.\nIn the same way, your service account can access the Google Spreadsheet(s) of your colleague if they have been shared with or are all contained in a folder that has been shared with your service account.","Q_Score":2,"Tags":"python,google-sheets,google-sheets-api,gspread","A_Id":73121899,"CreationDate":"2022-07-26T09:47:00.000","Title":"Get access of google sheets of other account","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When using Scapy's sniff method, what is the difference between using a filter at the sniff call level and filtering in the callback method passed to the sniff call ? Is a filter more performant, for instance because it is passed to libpcap, but does that make a significant difference? Or are both more or less the same and more a question of personal preference?\nNote: I'm using Scapy 2.45 on Linux with Python3 to sniff wireless packets.\nThank you !","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":72,"Q_Id":73155330,"Users Score":0,"Answer":"If you're using the filter= keyword argument from sniff, you're passing a BPF filter. This string filter is compiled into a C object by libpcap, then passed to the socket. It is then used by the kernel directly, i.e. it is much, much more performant than filtering in the callback.\nThis actually matters a lot when you're on heavy-loads: if you receive for instance 1 Go\/s of packets, Scapy can't dissect that fast enough, so the socket it is using to receive those packets will have its buffer filled, and tons of packets will be dropped. On the other hand, if you're using a BPF \"kernel-level\" filter, only the filtered packets reach Scapy: that is a much more manageable packet stream.\nIf you are not experiencing issues with packet drops though (low rates... etc), it comes down to preference.","Q_Score":0,"Tags":"python,scapy","A_Id":73301068,"CreationDate":"2022-07-28T15:25:00.000","Title":"Advantages of Scapy sniff's filter, versus filtering in packet handling method?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have correctly pip installed the module, but I am still getting an error and I am not sure why.\nMy Code:\n21:from Crypto.Cipher import AES\n22:from PIL import ImageGrab\n23:from win32crypt import CryptUnprotectData\nError is:\nFile \"main.py\", line 21, in \nModuleNotFoundError: No module named 'Crypto'\n(I am an amateur btw)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":101,"Q_Id":73229097,"Users Score":0,"Answer":"if you are working on a chromebook this happens and to my knowledge theres no good workaround","Q_Score":2,"Tags":"python","A_Id":73229114,"CreationDate":"2022-08-04T00:17:00.000","Title":"Module not found error but I have pip installed the module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i can create with python outlook emails and send them. Im Using","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":74,"Q_Id":73254580,"Users Score":0,"Answer":"On a general note, no mail server (certainly not Exchange Server) will let you spoof the sender name and address (unless you were given an explicit permisison) for the obvious security reasons.\nYou can send on behalf of another Exchange user (if you have the permission) by setting the MailItem.SentOnBehalfOfName property. You can also create secondary Exchange \/ POP3\/SMTP \/ IMAP4\/SMTP accounts in Outlook and send through these accounts by setting the MailItem.SendUsingAccount property to an Account object from the Application.Session.Accounts collection.","Q_Score":0,"Tags":"python,email,outlook,pywin32,win32com","A_Id":73261740,"CreationDate":"2022-08-05T19:39:00.000","Title":"Python email create","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am developing a Python program where speed is critical, and one of its core components is reading JPEG natural images, with resolutions between 128 X 128 and 512 X 512, from disk. Currently, I utilize jpeg4py, a libjpeg-turbo-based library that is, in my experience, faster than its competitors (e.g., PIL or OpenCV). However, according to a few preliminary experiments I conducted, by saving those images' array representations as pure raw data in binary format, the reading speed is accelerated by roughly 25% (the dataset's storage size ends up enlarging by nearly an order of magnitude, but that is not an issue for my application.).\nPreviously, I assumed the overhead introduced by JPEG's decoding scheme is made up for by the fact that the files being loaded are smaller and thus fewer bytes are read, but it appears I was wrong? Perhaps my findings would vary on different hardware? In that case, what would the maximal gap between the two methods be, e.g., is it circa 30%, or are more dramatic figures, such as 200%, possible?\nPlease note that the chief metric important to my usage is reading speed, and other considerations are secondary. Also, if there are faster alternatives for achieving my goal, I would very much appreciate it if you could mention them.\nThank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":77,"Q_Id":73279524,"Users Score":1,"Answer":"Perhaps my findings would vary on different hardware?\n\nYes. This is a common problem. There is a tread-off between the decompression speed and the reading from the storage device and the speed of the operation is dependent of the processor, the jpeg library performance, and the storage device speed. In fact, it is even more complex since the compression ratio can theoretically have an impact on the decompression speed and the size of the file. Additionally, the operating system can put the file in an in-memory cache so that the reads\/writes are very cheap.\nA solution to such problem is to adapt the compression ratio regarding the target storage device. NVMe SSD are often very fast so it is a good idea not to enable compression on such device unless space is a problem. SATA SSD are slower but still quite fast so the compression method need to be efficient. HDD are generally slow and so data often needs to be compressed so for reads\/writes to be faster (note that some compression methods are still so slow that it decrease performance: for example, this is generally the case for the PNG file format that typically use the deflate decompression algorithm). Note that the processor and memory should theoretically taken into account but this is hard to estimate their performance without running a benchmark on the machine (some libraries use benchmark-based auto-tunning approach to improve performance).","Q_Score":0,"Tags":"python,image,performance,jpeg,binaryfiles","A_Id":73281304,"CreationDate":"2022-08-08T14:28:00.000","Title":"Reading Images As JPEG VS Raw Data","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've started running a Python script that takes about 3 days to finish. My understanding is that Linux processes make a copy of a python script at the time they're created, so further edits on the file won't impact the running process.\nHowever, I just realized I've made a mistake on the code and the processes running for over 2 days are going to crash. Is it possible to edit the copy of the python script the process loaded?\nI'm basically trying to figure out if there's a way to fix the mistake I've made without having to restart the script execution.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":33,"Q_Id":73284997,"Users Score":1,"Answer":"No, you can't. The interpreter byte compiles your source code when it initially reads it. Updating the file won't change the byte code that is running.","Q_Score":1,"Tags":"python,linux,process","A_Id":73285057,"CreationDate":"2022-08-08T23:21:00.000","Title":"Can I edit the copy of the python script a process is running?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Is it possible to define a class which has attributes that are visible and accessible by only specific type of class and maybe even only specific instance of a specific type of class.\nExample:\nI would like to define a class (class A) which hold and controls some resources. There will be another class (class B) which has some data\/state information and that would need to use resources hold by class A. So user API would be to define only one class A and then multiple class B instances which they can add\/register to class A instance. Is it possible to make it so that some attributes and methods of class B instances are only visible\/accessible by class A instance and not by the user? E.g. if there is a an attribute holding some datetime value then only class A instance could access that, but user directly can't.\nEDIT:\nI know I can make those attributes and methods 'private' and in that way kind of achieve what I want. But this goes against the concept of private attributes\/methods (they are still used externally by some). Also, I am hoping that maybe there is a more elegant (pythonic) way of achieving this.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":226,"Q_Id":73286504,"Users Score":2,"Answer":"No, it's not possible to do this. Either an attribute can be accessed or it can't. Other than private attributes, which can only be accessed within the same class (unless you mangle the name by hand), there's no access control based on where the attribute reference is.","Q_Score":0,"Tags":"python,class,attributes","A_Id":73287328,"CreationDate":"2022-08-09T04:20:00.000","Title":"Can there be class attributes accessible only by specific class instance [Python]","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I made a script for telegram that changes the avatar every minute when it starts, the following error appears\nAttempt 1 at connecting failed: ConnectionRefusedError: [Errno 111] Connect call failed ('149.154.167.51', 443)\nAttempt 2 at connecting failed: ConnectionRefusedError: [Errno 111] Connect call failed ('149.154.167.51', 443)\nAttempt 3 at connecting failed: ConnectionRefusedError: [Errno 111] Connect call failed ('149.154.167.51', 443)\nAttempt 4 at connecting failed: ConnectionRefusedError: [Errno 111] Connect call failed ('149.154.167.51', 443)\nAttempt 5 at connecting failed: ConnectionRefusedError: [Errno 111] Connect call failed ('149.154.167.51', 443)\nAttempt 6 at connecting failed: ConnectionRefusedError: [Errno 111] Connect call failed ('149.154.167.51', 443)\nTraceback (most recent call last):\nFile \"\/home\/ainurfast\/clocks\/main.py\", line 13, in \nclient.start()\nFile \"\/home\/ainurfast\/.local\/lib\/python3.9\/site-packages\/telethon\/client\/auth.py\", line 133, in start\nelse self.loop.run_until_complete(coro)\nFile \"\/usr\/local\/lib\/python3.9\/asyncio\/base_events.py\", line 642, in run_until_complete\nreturn future.result()\nFile \"\/home\/ainurfast\/.local\/lib\/python3.9\/site-packages\/telethon\/client\/auth.py\", line 140, in _start\nawait self.connect()\nFile \"\/home\/ainurfast\/.local\/lib\/python3.9\/site-packages\/telethon\/client\/telegrambaseclient.py\", line 525, in connect\nif not await self._sender.connect(self._connection(\nFile \"\/home\/ainurfast\/.local\/lib\/python3.9\/site-packages\/telethon\/network\/mtprotosender.py\", line 127, in connect\nawait self._connect()\nFile \"\/home\/ainurfast\/.local\/lib\/python3.9\/site-packages\/telethon\/network\/mtprotosender.py\", line 253, in _connect\nraise ConnectionError('Connection to Telegram failed {} time(s)'.format(self._retries))\nConnectionError: Connection to Telegram failed 5 time(s)","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":59,"Q_Id":73312457,"Users Score":1,"Answer":"The mtproto protocol for telegram does not work from a free account on PythonAnywhere. You can use the HTTP protocol or upgrade your account.","Q_Score":0,"Tags":"pythonanywhere,telethon","A_Id":73362470,"CreationDate":"2022-08-10T20:38:00.000","Title":"I tried to deploy my scipt on PythonAnywhere but got following exception","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"A known way:\n\ncall balanceOf to get the number of tokens owned by the address call\nCall tokenOfOwnerByIndex in a loop to get each owned token ID.\n\nBut what I'm very confused about is what to do when the ERC721 contract has not included tokenOfOwnerByIndex function","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":228,"Q_Id":73317165,"Users Score":0,"Answer":"tokenOfOwnerByIndex is what most token will provide for you to enumerate in, but you could use Transfer event on that contract to do that also","Q_Score":0,"Tags":"python,ethereum,smartcontracts,nft,web3py","A_Id":73367892,"CreationDate":"2022-08-11T07:54:00.000","Title":"How to get the tokenids of certain ERC721 tokens for a adress? using Web3py","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am measuring battery voltage using a Raspberry Pi GPIO and displaying it on a local web app. Currently, my process is to save the voltage reading and the timestamp as a JSON file on the disk and then read the JSON file using the Javascript fetch API from the local web app (the JSON file is saved on the local web app directory).\nI was wondering if there was a more efficient \/ better way of achieving this.\nI am using python 3 to read the battery voltage and generate the JSON file.\nThe local web app runs on a Node + Express server.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":66,"Q_Id":73345615,"Users Score":0,"Answer":"If you want the data to be persistent, saving it to the disk is the way to go.\nYou might want to consider storing the data in a database, and using the database API to retrieve the data instead of reading a JSON file, though.","Q_Score":0,"Tags":"python,node.js,raspberry-pi3","A_Id":73345642,"CreationDate":"2022-08-13T15:39:00.000","Title":"Efficient way to show sensor data on local web app","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using pycharm\/python 3.8. I am working on a branch let's call it: Working_branch1. I have some tests that I need to run, usually when I run them they test the version of my code: code.py located \\directory_name\\code.py. However since few days, every time I run these tests they are testing instead another version of my code of the same folder located in Lib\\site-packages\\directory_name-py3.8.egg\\code.py.\nThe tests are failing since it's an older version of the code.\nCan someone please let me know what's this .egg directory and how can I force my tests to run on my actual code version instead ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":50,"Q_Id":73358227,"Users Score":0,"Answer":"site-packages is where Python stores installed packages for a given environment. The tests are running on the version installed in your environment, which means you probably installed it at some point. Your options are either to uninstall it, or to reinstall the updated version.","Q_Score":0,"Tags":"python,pandas,pycharm","A_Id":73358756,"CreationDate":"2022-08-15T07:59:00.000","Title":"What's the .egg folder in pycharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a function which send images to the email\nThe requirements is, i have only two images the first one i need to send as a attachments and another one in the body .\nUsing alternative in the MIMEmultipart it sending the both images as a documents and i have tried using two multipart that is also not helping. let me know how to approach the issue and also let me know whether it is possible or not\nAny idea would be appreciated","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":360,"Q_Id":73397859,"Users Score":0,"Answer":"You can use HTML to embed the wanted image in the body.\nSome e-mail clients interpret this still as an attachment. Maybe check, how other clients interpret your solution.","Q_Score":2,"Tags":"python,mimemultipart","A_Id":73399120,"CreationDate":"2022-08-18T05:29:00.000","Title":"Sending images through email","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently coding on python3 and have a while True loop where it will run indefinitely so I have to force stop it for it to end. For further details, I am creating a system that automatically detects the humidity in a box, and starts a fan, once it reaches a high enough humidity. When I force stop my program, I would like it to run a command, specifically GPIO.output(21, GPIO.LOW), this will cause the fan to turn off. Any ideas? (I'm currently using a raspberry pi 3 to code this all on)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32,"Q_Id":73423997,"Users Score":0,"Answer":"Capture an input to break out of your loop instead of manually closing the program, then put GPIO.output(21, GPIO.LOW) after the loop. Or if you are set on manually ending the program perhaps manually start a separate program right after that only runs that single command?","Q_Score":0,"Tags":"python,python-3.x","A_Id":73424057,"CreationDate":"2022-08-20T04:01:00.000","Title":"How do I run automatically run a command once my program ends?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to find a way to pin comments in YouTube automatically. I have checked YouTube API v3 documentation but it does not have this feature. Is there any idea?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":177,"Q_Id":73444163,"Users Score":0,"Answer":"To initialize the automatic mechanism, you first need to open your web-browser Web Developer Tools Network tab, then pin an ad hoc comment, you should notice a XHR request to perform_comment_action endpoint. Right-click this request and copy it as cURL. Notice the last field actions in the JSON encoded --data-raw argument. Decode this base64 encoded field and modify the first plaintext argument Ug...Ag to the comment id you want to pin and re-encode the field in base64 and then execute the cURL request and that's it!\nNote that there is no need to modify any other parameter for pinning a comment on another video than the ad hoc comment is posted on.","Q_Score":0,"Tags":"python,api,youtube,comments","A_Id":74672468,"CreationDate":"2022-08-22T11:12:00.000","Title":"How to pin Youtube comments with python automatically","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"could you please share a well-structured tutorial or guide to implement multi-objective optimization in Pyomo?\nI just found some Q&A which was a bit vague","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":129,"Q_Id":73462717,"Users Score":0,"Answer":"As far as I know, Pyomo does not have special facilities to handle multi-objective models. So there this nothing special to learn, and you can use any Pyomo text or tutorial.\nYou will need to formulate your problem in terms of single objective models. Arguably, the most popular schemes are a weighted objective or a lexicographic method. The last approach will require you to solve a number of models. Although the concepts may require a bit of thought, these methods are not difficult to implement.","Q_Score":0,"Tags":"python,optimization,pyomo","A_Id":73466316,"CreationDate":"2022-08-23T17:13:00.000","Title":"Multi-objective optimization in pyomo","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Python script that should have slightly different behaviour if it's running inside a Kubernetes pod.\nBut how can I find out that whether I'm running inside Kubernetes -- or not?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":188,"Q_Id":73475423,"Users Score":1,"Answer":"An easy way I use (and it's not Python specific), is to check whether kubernetes.default.svc.cluster.local resolves to an IP (you don't need to try to access, just see if it resolves successfully)\nIf it does, the script\/program is running inside a cluster. If it doesn't, proceed on the assumption it's not running inside a cluster.","Q_Score":0,"Tags":"python,kubernetes","A_Id":73476045,"CreationDate":"2022-08-24T14:58:00.000","Title":"How can a Python app find out that it's running inside a Kubernetes pod?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"How can I read pdf in python? I know one way of converting it to text, but I want to read the content directly from pdf.\nCan anyone explain which module in python is best for pdf extraction?\nI tried to use PyPDF2 package but it gives me inconsistent results. Also, i would like a lot to have a way to get the tables, the images, and remove the headers and the footers at least consistently, it doesn't need to happens 100% of the times. Thanks for your answers, i just need to find the right library. Thanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":25,"Q_Id":73475903,"Users Score":1,"Answer":"From another post that asked pretty much the same:\nThe answer depends if the question is general or specific to a single form. Your approach is reasonable for the general case, but there will be variability. If you have a pdf form that is a single form or report that has been created with different data at each iteration consider converting the form from pdf to postscript then see if you can parse the postscript.\nTwo utilities do this: pdf2ps and pdftops Try each. This approach may benefit if you know some postscript. With some luck the needed fields may be simple text strings. Worth a try.","Q_Score":1,"Tags":"python","A_Id":73475926,"CreationDate":"2022-08-24T15:30:00.000","Title":"Best way to get text of a pdf file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I mean when anybody can check how backend work, but nobody can change the backend.\nThat's for purpose to prove users that there is no any cheating on server.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":20,"Q_Id":73507809,"Users Score":0,"Answer":"When you say\n\nwhen anybody can check how backend work\n\ndo you mean anyone can look at the code of the backend? That's certainly possible, and it can be done without compromising the security of the application.\nThere are plenty of secure backends and libraries that are published in open source repositories.\nAssuming that you don't share private keys or other sensitive data, and your backend is built with modern security principles in mind, it should be possible to allow others to read the backend without risking the safety of your application\/data.","Q_Score":0,"Tags":"python,httprequest,backend","A_Id":73507871,"CreationDate":"2022-08-27T01:37:00.000","Title":"Is it possible to create OPEN BACKEND? for example written on python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"how to fix 404 error in github.io in new repositories? I tried the new, public, changed mode, nothing helps. there is a python script in the repositories to collect information, maybe there are some restrictions on github for python scripts?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":75,"Q_Id":73510640,"Users Score":0,"Answer":"There is one possible reason for it, GitHub pages isn't enabled. To solve this, Repo Settings -> Github Pages section -> Select the main branch. If it is already there, then wait for some time and refresh your site again.","Q_Score":0,"Tags":"python,github,http-status-code-404,github-pages","A_Id":73511153,"CreationDate":"2022-08-27T11:34:00.000","Title":"how to fix 404 error in github.io in new repositories?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is encapsulation get achieved when we declare all variables of the instance or class private? What if I have to keep some variables of class public and some private? Is it still an encapsulation?\nIs it necessary to keep all the variables private for encapsulation? Suppose I have a class \"Employee\", the variables of the class are Employee_name, Employee_salary, Employee_pincode and the methods of the class include \"get Employee_salary\", \"set Employee_salary\", \"get Employee_pincode\", \"set Employee_pincode\".I want to keep the Employee_name as public and Employee_salary, Employee_pincode as private. Is it still an encapsulation? What if I keep all the variables of the class public? Is it an encapsulation? Please clear my confusion. Thanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":73510752,"Users Score":0,"Answer":"In OOP (Object Oriented Programming, of which Encapsulation is one of the Four Pillars), variables are either referred to as fields or properties. Fields are private variables whereas properties are public variables (accessible outside the class).","Q_Score":0,"Tags":"python,private,encapsulation,public","A_Id":73510800,"CreationDate":"2022-08-27T11:51:00.000","Title":"Is encapsulation get achieved when we declare all variables of the instance or class private?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm using coverage3.8, version 5.3 with C extension.\nI used command: coverage3.8 run --parallel-mode xxx.py and used htop to check the CPU usage. Then I found the CPU usage is off the chart.\nI wonder if there is a variable\/option that can set\/limit how many CPU nodes that coverage3.8 can use?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":41,"Q_Id":73524201,"Users Score":2,"Answer":"--parallel-mode just tells coverage to name the data files with a unique number so that more than one can be created at once. It doesn't cause processes to spawn. Your program must be doing that. What does your program do?","Q_Score":0,"Tags":"python,code-coverage,coverage.py","A_Id":73542018,"CreationDate":"2022-08-29T04:42:00.000","Title":"coverage in parallel used all cpu resource","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created a python script to handle my Firebase Cloud Messaging service. What would be the best course of action in terms of trying to host it?\nExtra Info:\nI've tested that it works but I need it to be running constantly, and not on my own PC.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":24,"Q_Id":73540696,"Users Score":1,"Answer":"try aws lambda\nyou can choose to use it with api gateway or run it as a cronjob or what ever options you need","Q_Score":0,"Tags":"python,firebase-cloud-messaging","A_Id":73541302,"CreationDate":"2022-08-30T10:09:00.000","Title":"I created a python script for my Firebase Cloud Messaging service, now how should I host this?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to get the balances of a custom token on BSC (can be any BSC token \u2013 BUSD, WEJS, APX etc\u2026 you name it). To that end I have the following questions:\n\nIs it possible to get the balances of a token without ABI?\nIf not, is there a way to automatically collect ABI information (like a Saas API)?\n\nPS: I know BSCscan provides ABI for some verified tokens but it does not provide it for many of the traded tokens\u2026","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":215,"Q_Id":73543796,"Users Score":0,"Answer":"Is it possible to get the balances of a token without ABI?\n\nNo, it is not possible, but you don't need the full ABI of each and every token. The most tokens are made basing on some standards (presumably almost all tokens that you want to interact with are BEP20 [aka ERC20] or BEP721 [aka ERC721] compatible). Therefore instead of using their actual ABI - it is enough to use respective standard's ABI for basic and the most needed interaction such as getting balance or transferring tokens.\nTherefore, just search the web for these ABI or simply compile from the libraries (for instance, OpenZeppelin) 'dumb' contracts of respective standards and use their ABI - it would be compatible with all tokens those following the standard (and all token makers, who need\/hope for the third party support of their tokens do follow these standards).\n\nIf not, is there a way to automatically collect ABI information (like a Saas API)?\n\nI'm not aware of this, but as I stated before - you can avoid relying on them. And token standards mechanism was designed with this very purpose.","Q_Score":0,"Tags":"python,blockchain,ethereum,abi,binance-smart-chain","A_Id":73581084,"CreationDate":"2022-08-30T14:04:00.000","Title":"Get balances of a custom token on Binance Smart Chain","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I wrote a simple telegram bot and it works great without conflicting with my firewall. But my question is this, in the firewall I have ports 80 and 443 allowed for my site, but when I write a TCP socket in Python that should work through port 443 or port 80, the OS tells me that I need to run the program from the user's root, but if I start the bot, then the OS does not swear at all about the rights and the bot works quietly. If I still decide to run a socket on port 443 or 80, then the OS replies that these ports are busy.\nSo, please explain to me why the telegram bot does not conflict with processes and ports?\nMy server is Ubuntu 22.04\nP.S. I already asked this question on stackexchange, but as I understand it, they do not understand telegram bots, I hope you can help me.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":239,"Q_Id":73562856,"Users Score":0,"Answer":"You're confusing two things, I think.\nnginx\/apache\/a python server process trying to listen on port 443 or 80 need to be run by root (or another user with elevated privilege levels).\nA python bot trying to talk to a telegram server on port 443 doesn't have that limitations; browsers also don't need to run as root.\nIf this doesn't answer your question you need to be a bit clearer on what you're doing.","Q_Score":0,"Tags":"python,linux,telegram-bot","A_Id":73562996,"CreationDate":"2022-08-31T23:25:00.000","Title":"Why telegram bot doesn't conflict with nginx?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a program running on a raspberry pi zero 2 but at a certain point it just stops, no errors, no program exit, can ctrl+c perfectly fine. It just stops doing anything and I'm not sure why.\nThere is a lot of complicated code that runs before this and it also calls an external library so I don't want to have to scrub through everything (that's a very deep rabbit hole). I just want to know the last line it completed before it got stuck so I can un-stuck it.\nIs there any way to print the last line that was executed when it gets stuck? Maybe I can print the last line that was executed when I press ctrl+C?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":37,"Q_Id":73570413,"Users Score":0,"Answer":"So, quite a simple solution really that I apparently was not aware of. Pressing ctrl+c by default will print the traceback for the last few lines. It did not work for me because I had an exception clause that dealt with any keyboard interrupt. Getting rid of that clause forced my program to crash, now I have a separate issue of finding out what\nready, _, _ = select.select([self.fd, self.pipe_abort_read_r], [], [], timeout.time_left()) means.\nBut in regard to this question I guess it has been solved, thanks to AKX for clarifying.","Q_Score":0,"Tags":"python,debugging,raspberry-pi-zero","A_Id":73571258,"CreationDate":"2022-09-01T13:43:00.000","Title":"How to print the last line Python has been stuck on","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'am trying to make a web bot with Python in IntelliJ, i found a plugin called selenium that makes life a lot better. the only thing is that you can only download the selenium plugin with the IntelliJ Ultimate version. Does anybody know how to use the selenium plugin with the IntelliJ community edition.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":77,"Q_Id":73583192,"Users Score":1,"Answer":"For coding with Python they have PyCharm. IntelliJ is designed for other languages like Java","Q_Score":1,"Tags":"python,selenium,selenium-webdriver,intellij-idea,intellij-plugin","A_Id":73583288,"CreationDate":"2022-09-02T13:17:00.000","Title":"Is selenium only available in IntelliJ on the Ultimate version","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'am trying to make a web bot with Python in IntelliJ, i found a plugin called selenium that makes life a lot better. the only thing is that you can only download the selenium plugin with the IntelliJ Ultimate version. Does anybody know how to use the selenium plugin with the IntelliJ community edition.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":77,"Q_Id":73583192,"Users Score":0,"Answer":"Currently i installed Selenium and its working. First i installed Pycharm and installed selenium in the terminal of pycharm by typing \"pip install selenium\", and after that i installed PyPI source archive by typing \"python3 setup.py install\". Then i needed the right webdriver voor my Google Chrome.\nIts running perfectly.","Q_Score":1,"Tags":"python,selenium,selenium-webdriver,intellij-idea,intellij-plugin","A_Id":73744132,"CreationDate":"2022-09-02T13:17:00.000","Title":"Is selenium only available in IntelliJ on the Ultimate version","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I am generating reports with Python and Ninja in the ASCIIDoc format.\nBut from within my app I need to convert them into PDF and upload them to another system.\nI have seen that there are multiple HowTo for command line that involve ASCIIDoctor or other tools, but they always are invoked at OS level by starting a program or running a docker container and writing the output to a file.\nIsn't there a way to perform those action within my app and get the PDF as a string that I can use for the upload?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":40,"Q_Id":73591022,"Users Score":0,"Answer":"You can certainly use the available tools to generate a PDF, which you could then read into memory as an opaque string that could be uploaded as needed.\nIf your question is: how do I generate and upload a PDF without installing any other tools?\nThen the answer is that you'd have to implement the PDF generation logic yourself, rather than using tested tooling.","Q_Score":0,"Tags":"python,pdf,asciidoc","A_Id":73628854,"CreationDate":"2022-09-03T09:15:00.000","Title":"ACIIDOC to PDF in Python without need for files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I'm building an application that can run user-submitted python code. I'm considering the following approaches:\n\nSpinning up a new AWS lambda function for each user's request to run the submitted code in it. Delete the lambda function afterwards. I'm aware of AWS lambda's time limit - so this would be used to run only small functions.\nSpinning up a new EC2 machine to run a user's code. One instance per user. Keep the instance running while the user is still interacting with my application. Kill the instance after the user is done.\nSame as the 2nd approach but also spin up a docker container inside the EC2 instance to add an additional layer of isolation (is this necessary?)\n\nAre there any security vulnerabilities I need to be aware of? Will the user be able to do anything if they gain access to environment variables in their own lambda function\/ec2 machine? Are there any better solutions?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":73596976,"Users Score":0,"Answer":"Any code which you run on AWS Lambda will have the capabilities of the associated function. Be very careful what you supply.\nEven logging and metrics access can be manipulated to incur additional costs.","Q_Score":0,"Tags":"python,amazon-web-services,security,amazon-ec2,aws-lambda","A_Id":73597751,"CreationDate":"2022-09-04T05:25:00.000","Title":"Strategies to run user-submitted code on AWS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am creating a Discord token generator but I have to verify an account with a phone number, my question Is there a way to verify a Discord account by email or phone for free using Python? (clearing cookies or set incognito browser mode doesn't work :( )\nNote: I use a random email","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":216,"Q_Id":73600306,"Users Score":0,"Answer":"I wouldn't advise stealing others discord accounts, but heres a few tips, but non development related. Python cannot generate phone number and discord gives you warnings saying that you need to verify if they suspect an alternative account. If you simpy clear your cookies before logging into another account using the token, you won't be prompted at all to verify a phone number","Q_Score":0,"Tags":"python,discord,verification","A_Id":73602823,"CreationDate":"2022-09-04T14:45:00.000","Title":"How to verify a Discord account by email or phone for free using Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Given a pair of latitude and longitude values (coordinate), a country name (e.g. United States) and a radius (e.g. 10 km), I would like to check if the coordinate is located close to the border of the country (i.e. if (parts of) the border is located within the predefined radius).\nMy current approach is just an approximation and needs to call costly geocoding APIs:\nUsing the radius, I'm \"sketching\" an artificial circle around the coordinate (not a full circle, but e.g. 16 points arranged in a circle) and check for each of the points via Geocoding API, if it is located in the predefined country.\nIs there a smarter way to do this in Python?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":94,"Q_Id":73632870,"Users Score":0,"Answer":"Create a 10km buffer around the country border and then check if the point is within that polygon.\nAny GIS tool or package will provide you with tools to do this. I would recommend PostGIS as it is robust and fast.","Q_Score":0,"Tags":"python,geolocation,geospatial,geocoding,reverse-geocoding","A_Id":73634068,"CreationDate":"2022-09-07T09:13:00.000","Title":"Check if coordinate (lat\/lng) is located close to the boarder of predefined country","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I can't find a way to ban or kick a user from a group chat using the pyTelegramBotAPI library","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":262,"Q_Id":73633805,"Users Score":0,"Answer":"If I were you, I would create a blacklist. I would enter the user.id I want to block there. Then I would check \"if the message is sent by a user who is on the blacklist, then this message should be deleted.\" Simply and without external means...","Q_Score":0,"Tags":"python,telegram,py-telegram-bot-api,telebot","A_Id":74052602,"CreationDate":"2022-09-07T10:18:00.000","Title":"How to ban a telegram chat user using a telebot?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to know if 3ds max supports Unity's animation file .anim? I am trying to create like a program that makes it easier to animate and then you can get that animation file and import it to 3ds max. I have an idea to make a unity WRITE the python script of an animation but there should be an easier way of doing that.\nIs there any way of importing animation from unity3d to 3ds max? Maybe we could convert .anim to some other extensions that 3ds max supports.\nLooking forward to hear your ideas. Thank you.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":180,"Q_Id":73650928,"Users Score":2,"Answer":"yes, you can export unity animations to 3ds max. You can even do multiple at once using a so-called FBX file.","Q_Score":1,"Tags":"python,c#,unity3d,animation,3dsmax","A_Id":73651363,"CreationDate":"2022-09-08T14:40:00.000","Title":"Unity animation (.anim) to 3ds max","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently learning Python and I am wondering if I can build an application that can detect other devices using WiFi or nearby Bluetooth scanning.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":25,"Q_Id":73672482,"Users Score":2,"Answer":"Its possible to list the devices listening on wifi, but not their location.","Q_Score":2,"Tags":"python,windows","A_Id":73672650,"CreationDate":"2022-09-10T14:13:00.000","Title":"Is it possible to make an app that detects other devices location using Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way for me to put python files (micropython to be specific) on the raspberry pi pico without using software like thonny where it does it for you, Is there a way to do it with bootsel?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":603,"Q_Id":73673763,"Users Score":0,"Answer":"With bootsel button you will not reach the storage for python scripts.\nUsing rshell will help. Inside rshell you will also reach REPL.","Q_Score":1,"Tags":"micropython,raspberry-pi-pico","A_Id":74082998,"CreationDate":"2022-09-10T17:16:00.000","Title":"How can I put python files on a raspberry pi pico without using software like thonny","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to run shell script on ec2 instance every day, cronjob has disabled. how can we run script using python boto3.\nDo we have any options to schedule a job in aws ec2 instance without cron","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":117,"Q_Id":73679484,"Users Score":0,"Answer":"You can use Event Bridge with Systems Manager to run a script every day without using cron","Q_Score":0,"Tags":"python,amazon-web-services,boto3","A_Id":73679509,"CreationDate":"2022-09-11T12:58:00.000","Title":"run script everyday on ec2 instance","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"i run flask app FLASK_ENV=development flask run\ni haven't touched locally installed python for 2-3 months\nunexpected behaviour:\n\nserver starts slowly than previously\nusually with FLASK_ENV=development server reloads when files change(after file changed reloading will perform in 40-50 seconds)\n\ni did:\n\nre-install pythons(3.8,3.9)\nre-install wsl(debian, ubuntu)\n\np.s. usually wsl command installs high distributive version, but today 09.12.2022 wsl command installs debian 9???","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":127,"Q_Id":73691871,"Users Score":0,"Answer":"problem have solved through switching to wsl version 1\np.s. reason to post this question - poke the problem for another developers","Q_Score":0,"Tags":"python-3.x,windows-subsystem-for-linux","A_Id":73691951,"CreationDate":"2022-09-12T15:45:00.000","Title":"wsl python works slow","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"How can I load MAGE query modules in Memgraph? Is there a difference if a query module is written in Python or C?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":38,"Q_Id":73701973,"Users Score":2,"Answer":"Query modules can be written using C API ( .so modules), and Python API ( .py modules). Each file corresponds to one query module with one or more procedures within them. The names of these files will be mapped to the query module names. For example, a procedure node_connectivity in nxalg.py will be mapped to nxalg.node_connectivity() in the Cypher query language.\nOnce you start Memgraph, it will attempt to load query modules from all .so and .py files from the default (\/usr\/lib\/memgraph\/query_modules and \/var\/lib\/memgraph\/internal_modules) directories.\nMAGE modules are located at \/usr\/lib\/memgraph\/query_modules and custom modules developed via Memgraph Lab at \/var\/lib\/memgraph\/internal_modules.\nMemgraph can load query modules from additional directories if their path is added to the --query-modules-directory flag in the main configuration file (\/etc\/memgraph\/memgraph.conf) or supplied as a command-line parameter (e.g. when using Docker).\nIf you are supplying the additional directory as a parameter, do not forget to include the path to \/usr\/lib\/memgraph\/query_modules, otherwise queries from that directory will not be loaded when Memgraph starts.\nIf a certain query module was added while Memgraph was already running, you need to load it manually using the mg.load(\"module_name\") procedure within a query:\nCALL mg.load(\"py_example\");\nIf you want to reload all existing modules and load any newly added ones, use mg.load_all():\nCALL mg.load_all();\nYou can check if the query module has been loaded by using the mg.procedures() procedure within a query:\nCALL mg.procedures() YIELD *;","Q_Score":2,"Tags":"python,c,graph-databases,memgraphdb","A_Id":73701974,"CreationDate":"2022-09-13T11:14:00.000","Title":"How can I load MAGE query modules in Memgraph?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am doing unit tests on a python program who, for QA purposes, gets the repository name and the current commit hash from the .git in the directory\nFor my unit tests on that program I would like to have a dummy .git directory in the tests directory. That .git repository would have a single initialization commit and a remote that would not be used\nWhen attempting to add a .git to my tool's repository, git seems to ignore it and indicates that there are no differences in the status and commit\nHow can I add the .git directory to my project repository ? Something like tests\/.git","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":39,"Q_Id":73718245,"Users Score":3,"Answer":"You can't do that. It's inherently forbidden by Git.\nYou can store a tar or ZIP archive that contains the repository, and then have your test routine extract it to a temporary location. If you go that route, I recommend to use an uncompressed archive format, because it allows Git's own compression algorithms to work more efficient.","Q_Score":0,"Tags":"python-3.x,git,unit-testing,python-unittest","A_Id":73718334,"CreationDate":"2022-09-14T14:05:00.000","Title":"How can I add a .git directory to a git repository?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am doing unit tests on a python program who, for QA purposes, gets the repository name and the current commit hash from the .git in the directory\nFor my unit tests on that program I would like to have a dummy .git directory in the tests directory. That .git repository would have a single initialization commit and a remote that would not be used\nWhen attempting to add a .git to my tool's repository, git seems to ignore it and indicates that there are no differences in the status and commit\nHow can I add the .git directory to my project repository ? Something like tests\/.git","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":39,"Q_Id":73718245,"Users Score":0,"Answer":"I think we would need more details about what you want to achieve to provide like the best answer... but I think you should look at git bundle. You can track a bundle file and then use it to regenerate a git repo.","Q_Score":0,"Tags":"python-3.x,git,unit-testing,python-unittest","A_Id":73718463,"CreationDate":"2022-09-14T14:05:00.000","Title":"How can I add a .git directory to a git repository?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to make a python script that would run a server which I can then send a request to from another pc using curl to send a file. So I would send a file from a pc to the server using curl and then server would save that file.\nI tried googling but couldn't seem to find anything like that, but I found that pycurl might be useful. If anyone could show me the direction towards my goal I would appreciate it.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":294,"Q_Id":73736877,"Users Score":0,"Answer":"Sending files is typically just a POST with data. You can make a webserver using something such as flask, and make an endpoint that receives post data, then saves it as a file.\nOn the server, you don't need curl at all, just an HTTP server that accepts requests.","Q_Score":0,"Tags":"python,curl,server,file-transfer","A_Id":73736989,"CreationDate":"2022-09-15T20:09:00.000","Title":"Make a python server receive files sent using curl","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i have a MILP with ~3000 binaries, 300000 continuous variables and ~1MM constraints. I am trying to solve this on the VM how long could it potentially take on a 16 core 128 gig machine? also what are the general limits of creating problems using pulp that cplex solver can handle on such a machine? any insights would be appreciated","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":41,"Q_Id":73738378,"Users Score":0,"Answer":"It is impossible to answer either question sensibly. There are some problems with only a few thousand variables that are still unsolved 'hard' problems and others with millions of variables that can be solved quite easily. Solution time depends hugely on the structure and numerical details of your problem and many other non-trivial factors.","Q_Score":0,"Tags":"python,cplex,pulp","A_Id":73741039,"CreationDate":"2022-09-15T23:33:00.000","Title":"scaling MILP using pulp and cplex","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i have a MILP with ~3000 binaries, 300000 continuous variables and ~1MM constraints. I am trying to solve this on the VM how long could it potentially take on a 16 core 128 gig machine? also what are the general limits of creating problems using pulp that cplex solver can handle on such a machine? any insights would be appreciated","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":41,"Q_Id":73738378,"Users Score":0,"Answer":"The solution time is not just a function of the number of variables and equations. Basically, you just have to try it out. No one can predict how much time is needed to solve your problem.","Q_Score":0,"Tags":"python,cplex,pulp","A_Id":73738627,"CreationDate":"2022-09-15T23:33:00.000","Title":"scaling MILP using pulp and cplex","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"While importing modules in a program a single module is only loaded once and then accessed from sys.modules dictionary. And also when a module is first run a .pyc file is created. Does the former make use of the latter or are they unrelated?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":10,"Q_Id":73741387,"Users Score":0,"Answer":"They are unrelated.\nThe .pyc file is a cached file of the compiled byte code for the script\/application. Since Python does this every time a script is run it keeps it cached until the original .py file is modified and run again in which case the compiler will run again. This reduces the time of successive startups of the same unmodified script\/application as the compiled byte code is already cached. It's quite helpful when running something over and over again but it only runs for a short while.","Q_Score":1,"Tags":"python-3.x,module","A_Id":73747023,"CreationDate":"2022-09-16T07:31:00.000","Title":"Caching in Modules in Python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to use AWS services to implement a real-time email-sending feature for one of my projects. It is like someone uses my app to schedule a reminder from my project and then the email will be sent to them nearby or at the actual time that he scheduled.\nI know the AWS services such as AWS CloudWatch rules (CRONs) and DynamoDB stream (TTL based). But that is not perfect for such a feature. Can anyone please suggest a better way to implement such a feature?\nAny type of guidance is acceptable.\n-- Thanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":29,"Q_Id":73769670,"Users Score":2,"Answer":"Imagine your service at huge scale. At such scale, there are likely to be multiple messages going off every minute. Therefore, you could create:\n\nA database that stores the reminder times (this could be DynamoDB or an Amazon RDS database)\nAn AWS Lambda function that is configured to trigger every minute\n\nWhen the Lambda function is triggered, it should check the database to retrieve all reminders that should be sent for this particular minute. It can then use Amazon Simple Email Service (SES) to send emails.\nIf the number of emails to be sent is really big, then rather than having the Lambda function call SES in series, it could put a message into an Amazon SQS queue for each email to be sent. The SQS queue could then trigger another Lambda function that sends the email via SES. This allows the emails to be sent in parallel.","Q_Score":0,"Tags":"python-3.x,amazon-web-services","A_Id":73772956,"CreationDate":"2022-09-19T07:11:00.000","Title":"Real time email feature using AWS services","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have a question that I would like to solve:\nI have 4 python scripts as follows:\n\nmain.py\n\nscript1.py\nscript2.py\nscript3.py\n\n\n\nScripts 1, 2 and 3 are run invoked in the main.py.\nWhat I need is to be able to easily schedule this main.py to run once a week.\nWhat AWS services would be best for this? From the architecture side I don't know much.\nThank you!","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":238,"Q_Id":73773750,"Users Score":2,"Answer":"You can deploy the script in lambda if your execution time is under 15 minutes plus cloudwatch events for scheduling\nFor execution scripts > 15 minutes, I would suggest using AWS Batch to have the script on schedule on any of the supported compute environment like ECS or EC2","Q_Score":0,"Tags":"python,amazon-web-services,aws-lambda,schedule,aws-event-bridge","A_Id":73774098,"CreationDate":"2022-09-19T13:00:00.000","Title":"What is the best way to schedule a python script with AWS?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have a question that I would like to solve:\nI have 4 python scripts as follows:\n\nmain.py\n\nscript1.py\nscript2.py\nscript3.py\n\n\n\nScripts 1, 2 and 3 are run invoked in the main.py.\nWhat I need is to be able to easily schedule this main.py to run once a week.\nWhat AWS services would be best for this? From the architecture side I don't know much.\nThank you!","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":238,"Q_Id":73773750,"Users Score":2,"Answer":"For something running once per week, you clearly do not want to have any infrastructure running continuously. This leaves AWS Fargate (good for containerization) or AWS Lambda (good for scripts that run in less than 15 minutes).\nBased on the limited information you have provided, AWS Lambda would be a good option since it is simple to schedule.\nYou would need to change the scripts slightly to fit in the AWS Lambda environment. The Lambda 'function' is triggered via a call to a particular function you nominate. Since you have multiple scripts, you would need to determine whether to combine them all into the one Lambda function, or whether to have them each as a separate function and have the 'main' Lambda function call the other Lambda functions.\nAWS Lambda also supports parallel runs by deploying multiple Lambda functions. This could be useful if you have a lot of work to perform, or you can ignore it and just run your code as a 'single thread'.","Q_Score":0,"Tags":"python,amazon-web-services,aws-lambda,schedule,aws-event-bridge","A_Id":73792962,"CreationDate":"2022-09-19T13:00:00.000","Title":"What is the best way to schedule a python script with AWS?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I've been trying to generate a list of voters for several official Telegram polls.\nI studied the documentation of python-telegram-bot but the problem is that I think it requires a bot to join the group and collect the polls information.\nIs there any way to collect the polls data without having to add a bot and use my own account for viewing the polls?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":23,"Q_Id":73782546,"Users Score":1,"Answer":"I was doing similar thing using playwright Python API. All you need to do is store your authentication as a json file. Then you have to use the file using your account. You need some knowledge about HTML and CSS. You can easily get the needed information using beautifulsoup module.","Q_Score":0,"Tags":"python,telegram-api","A_Id":73782595,"CreationDate":"2022-09-20T06:44:00.000","Title":"How to get poll voters of multiple polls in a Telegram group without using any bots?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created one python file recently and then I added login system in it with date validation.\nI obfuscate it by using pyarmor pyarmor obfuscate foo.py and given to my paid users.\nThey run my file and they got one foo.pyc file and then they opened it and they got my all code in binary digits but they can bypass my login system and they can use my file for lifetime. What can I do to hide my python file and foo.pyc? If i will use pyarmor pack foo.py it will converted into .exe file so they can get my source code? they will get .pyc file?\nWhen I try to convert obfuscated python file to exe using pyarmor it shows an error DO NOT pack the obfuscated script, please pack the original script directly if I will try to obfuscate original file directly it will come in decrypted pattern or encrypted pattern?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":70,"Q_Id":73785813,"Users Score":0,"Answer":"Use pyarmor pack foo.py but I am not sure that they can wether decrypt or not.","Q_Score":1,"Tags":"python,python-3.x,pyarmor","A_Id":73785971,"CreationDate":"2022-09-20T11:16:00.000","Title":"pyarmor encryption is not secure?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running a python script inside a kubernetes pod with kubectl exec -it bash.Its a long running script which might take a day to complete.i executed the python script from my laptop inside the kubernetes pod.\nIf i close my laptop,will the script stop running inside the pod?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":277,"Q_Id":73883993,"Users Score":0,"Answer":"If you are running Kubernetes on Cloud, the script will continue until it is finished succefully or throws an error even if you close your laptop,\nOthewise, if you are running local Kubernetes Cluster, for example: with minikube, cluster will shut down and so is your script","Q_Score":1,"Tags":"python,bash,kubernetes,exit","A_Id":73885231,"CreationDate":"2022-09-28T15:21:00.000","Title":"will python script running inside a kubernetes pod exit if my laptop\/system turned off","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"If I import some module and then change its content python uses cache and doesn't see the changes. To sort that out I can remove __pycache__ directory or do sys.modules.pop(\"my_module\"). But I wonder if there're any time after which python cached files are invalidated automatically?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":53,"Q_Id":73884250,"Users Score":0,"Answer":"The problem was, that I was using the same IPython REPL session. So it used the cached file and didn't invalidate it. When I opened new python shell or just run import inside a python file - cache was invalidated every time the content of imported module is changed.","Q_Score":1,"Tags":"python,python-3.x","A_Id":73885132,"CreationDate":"2022-09-28T15:40:00.000","Title":"Is there any TTL of python cache","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a small app hosted on pythonanywhere. Can an outsider get all the sensitive data from my db?\nIs pythonanywhere protecting against attackers?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":21,"Q_Id":73891247,"Users Score":1,"Answer":"Data stored on your PythonAnywhere account is basically as safe as the account itself. So as long as your credentials are not compromised, you can assume that no outsider has access to it. If you have a web app, users have as much access to your data stored on your account, as you expose it via the web app and the code visible in the browser.","Q_Score":0,"Tags":"pythonanywhere","A_Id":73893662,"CreationDate":"2022-09-29T06:38:00.000","Title":"Can an outsider get all the info from a database on pythonanywhere?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to send MQTT messages to FairCom MQ using Paho. What port would I use?\nIn my paho.mqtt.publish() call I understand to set hostname to \"localhost\" or the IP of the machine FairCom MQ is running on but what do I set port to?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":35,"Q_Id":73901490,"Users Score":1,"Answer":"1883 is the default port for MQTT in general. FairCom MQ defaults to this port, so if you have not changed the MQTT port by editing cthttpd.json in the config folder use 1883. I.E.\npaho.mqtt.publish(topic, payload=\"My payload\", qos=0, hostname=\"localhost\", port=1883)","Q_Score":0,"Tags":"python,mqtt,paho,faircom","A_Id":73901541,"CreationDate":"2022-09-29T20:52:00.000","Title":"What port do I use to send MQTT messages to FairCom MQ from Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm a bit new to MicroPython, Scripting languages, etc. So currently, I'm working on a project in which I'm using NUCLEO-G431RB(128kb flash and 32kb ram). STM32G43RB is a low-memory microcontroller. Hence, officially, no MicroPython file firmware file is available for this board.\nAs Micropython is an open-source platform, the code files are available on the website. Therefore, I wanted to know how I could compile Micropython source code with only selected modules (basic hardware peripheral modules) and eliminate all unnecessary modules (Bluetooth, network, etc.).\nMy overall goal is to have a bare minimum stack (which I can upload on the low-memory controller as well) of Micropython so that I can run a basic code dealing with hardware peripherals and like that. Any lead, hint or link would be helpful and much appreciated.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":68,"Q_Id":73962515,"Users Score":1,"Answer":"The key to the answer is py\/mpconfig.h. That file lists all PP symbols which can conditionally enable the core code. In your own port's config file, normally named mpconfigport.h, you then #define MICROPY_SOME_FEATURE 0 to disable the feature.","Q_Score":0,"Tags":"python,stm32,micropython","A_Id":74013352,"CreationDate":"2022-10-05T15:09:00.000","Title":"how to rebuild micropython with selected module?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've looked everywhere for an answer to this question without much luck.\nOn my computer I have a python script running an infinite while loop.\nOn the Raspberry Pi Pico I'm reading a sensor value once a second.\nI'd like to have access to the sensor readings from my computer, (whatever the current sensor reading is).\nI'm not sure if it's best holding the values on some sort of register on the Pico or it's better to post them via serial or MQTT to the computer?\nPotentially I'll be reading the sensor from the computer faster (0.5s) or slower (2s) than it's getting evaluated on the Pico.\nAny ideas of what a good approach to accomplish this is?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":245,"Q_Id":73980553,"Users Score":0,"Answer":"The easiest solution, on the Pico side you open the serial port and print the sensor value every second, on the computer side you open the serial port and read it all the time, so you get the new values as they are sent by the Pico","Q_Score":0,"Tags":"python,serial-port,raspberry-pi-pico","A_Id":74196349,"CreationDate":"2022-10-06T22:18:00.000","Title":"Send data from Raspberry Pi Pico to computer via serial","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"What does it mean to call a module with parameters\npython mymod.py 50?\nWhat does it mean and what will happen?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":74013828,"Users Score":0,"Answer":"You are basically running the file mymod.py by passing parameter from the command line. In this case value of the parameter is 50. The way that parameter will be handled will depend upon the code written inside mymod.py","Q_Score":0,"Tags":"python,module","A_Id":74013913,"CreationDate":"2022-10-10T10:57:00.000","Title":"What does it mean to call a module with parameters \"python mymod.py 50\"?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am creating a bot for a VIP channel, and I have a question. How can I implement a kick through time?\nThe bot has subscriptions for 1, 3, 12 months, how can I make the user get kicked from the group in a month?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":27,"Q_Id":74018644,"Users Score":0,"Answer":"Make a database with users, their subscription plans, when they subscribed.\nThen loop trough the database every day and if (current_date > (when_they_subsribed + their_subscription_plan)): kick(user).\nIf you need any help in coding that then write to me on discord. RobertK#6151","Q_Score":0,"Tags":"python,telegram,telegram-bot","A_Id":74018855,"CreationDate":"2022-10-10T17:29:00.000","Title":"How to kick through time? Telegram Bot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using mailgun to send an email to notify users that their requested download for the data has been completed, with a link to download the file, the file is stored on AWS.\nYour data is ready for download here<\/a>\nSomething like this.\nIs there a way to tell the browser to download the file, instead of opening it in a new tab? I guess it's the problem with MIME type, but how do I set it up","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":22,"Q_Id":74024364,"Users Score":0,"Answer":"Okay, so the file is automatically downloaded if I set the Content-Type to binary\/octet-stream when uploading the file in AWS Bucket.\nI was looking into the opposite side of the puzzle.","Q_Score":0,"Tags":"python,mailgun","A_Id":74039655,"CreationDate":"2022-10-11T07:20:00.000","Title":"How do I Set MIME Type for a download link from Mailgun","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"To test, I have commented out all the .py files within one of my python site-packages and saved the files.\nUpon restart of terminal and ipython, all the old functionality of the package still works somehow. I tested further by copying the site-package folder with a different name, and the new name works. I then delete this folder, after which the new name does not work. I then recopy the folder with a new name but comment out all the code. It still works...\nWhat is going on?!\nEdit: I know it is frowned upon to edit site-packages. I'm just trying to understand what is happening. Please don't lynch me :D","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":13,"Q_Id":74031574,"Users Score":0,"Answer":"Found out why: the init.py file was still referencing the location of the old site-package, so was basically still using the original","Q_Score":0,"Tags":"python,python-3.x,site-packages","A_Id":74032153,"CreationDate":"2022-10-11T16:52:00.000","Title":"Editing Site Package Does Nothing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a LoadTestShape Class. I want to be able to set number of transaction per minute. If I try to set it by specifying user_count it doesn't work because the RPS will vary cpu to cpu .\nIf say I want to set 1000 transaction per minute, how can we achieve that in locust?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":142,"Q_Id":74039932,"Users Score":0,"Answer":"I ended up using constant_throughput to control the number of requests per second.\nFor different time of the day I'd use a different throughput value.\nSimply set the wait_time = constant_throughput(0.1). Based on RPS you want you can either set the value low for less number of requests and more for more RPS.","Q_Score":0,"Tags":"python-3.x,load-testing,locust","A_Id":74111361,"CreationDate":"2022-10-12T09:59:00.000","Title":"How to set transactions per minute in Locust","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing a Python script to load, filter, and transform a large dataset using pandas. Iteratively changing and testing the script is very slow due to the load time of the dataset: loading the parquet files into memory takes 45 minutes while the transformation takes 5 minutes.\nIs there a tool or development workflow that will let me test changes I make to the transformation without having to reload the dataset every time?\nHere are some options I'm considering:\n\nDevelop in a jupyter-notebook: I use notebooks for prototyping and scratch work, but I find myself making mistakes or accidentally making my code un-reproducible when I develop in them. I'd like a solution that doesn't rely on a notebook if possible, as reproducibility is a priority.\nUse Apache Airflow (or a similar tool): I know Airflow lets you define specific steps in a data pipeline that flow into one another, so I could break my script into separate \"load\" and \"transform\" steps. Is there a way to use Airflow to \"freeze\" the results of the load step in memory and iteratively run variations on the transformation step that follows?\nStore the dataset in a proper Database on the cloud: I don't know much about databases, and I'm not sure how to evaluate if this would be more efficient. I imagine there is zero load time to interact with a remote database (because it's already loaded into memory on the remote machine), but there would likely be a delay in transmitting the results of each query from the remote database to my local machine?\n\nThanks in advance for your advice on this open ended question.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":74047401,"Users Score":0,"Answer":"For a lot of work like that, I'll break it up into intermediate steps and pickle the results. I'll check if the pickle file exists before running the data load or transformation.","Q_Score":0,"Tags":"python,pandas,database,jupyter-notebook,airflow","A_Id":74047421,"CreationDate":"2022-10-12T19:58:00.000","Title":"How to efficiently test code that loads a large dataset?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to trigger several lambdas in parallel from another lambda. I'm using aiobotocore and this works fine locally but when I try to run it on AWSLambda, I have an error on the import modules:\nUnable to import module 'lambda_function': cannot import name 'apply_request_checksum' from 'botocore.client' (\/var\/runtime\/botocore\/client.py)\nI have tried to use aioboto3, but as it's a wrapper the same thing happens, I've checked the versions of the packages, they match. I've tried changing the python version, did not work.\nGoogling this specific error did not help either. If you need any precision, please let me know, any hint would be highly appreciated.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":125,"Q_Id":74058094,"Users Score":0,"Answer":"After investigating, it turns out that it was a package version error. The botocore package needed by aiobotocore had to be the exact same version. And since botocore is by default on AWS Lambda, I had to get an older version of Aiobotocore instead.\nBut thanks a lot for the answers !","Q_Score":1,"Tags":"python,amazon-web-services,aws-lambda,botocore","A_Id":74073489,"CreationDate":"2022-10-13T15:10:00.000","Title":"How to run parallel lambdas from another lambda?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have deployed a service in cloud run that takes about 40\/45 minutes to run.\nIt should run everyday but I don't know how to cron it.\nI have tried with cloud scheduler but I received a status DEADLINE_EXCEEDED message.\nCan you recommend another service?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":63,"Q_Id":74073637,"Users Score":0,"Answer":"Sadly, there is no serverless service with a timeout above 30 minutes for now (Cloud Workflows, Cloud Task, Scheduler are limited to 30 minutes max, 10 minutes for PubSub).\nHowever, even if your Cloud Scheduler log in error the invocation (because no answer has been received in the 30 minutes), your process continue to run. You simply doesn't have the retry features (retries on error, timeout, ....)\nIf you want to implement retries, you have complex architecture to build based on Cloud Logging, sinks, PubSub and Cloud Functions\/Cloud Run to be able to re invoke your long running service (in mode \"fire and forget\")","Q_Score":0,"Tags":"python,google-cloud-platform,google-cloud-run,google-cloud-scheduler","A_Id":74074699,"CreationDate":"2022-10-14T18:50:00.000","Title":"How to execute Google Cloud Run service every day?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I can find python version with python --version\nBut I cannot find the location of python executable. Is there a command like python --path? If not, is there a reason why?","AnswerCount":5,"Available Count":2,"Score":0.0798297691,"is_accepted":false,"ViewCount":37,"Q_Id":74102484,"Users Score":2,"Answer":"use 'where python' in your terminal to get the path to it\nedit\nwhere python works for windows and which python works for linux","Q_Score":1,"Tags":"python,windows","A_Id":74102496,"CreationDate":"2022-10-17T19:48:00.000","Title":"Why is there no command line to find python location?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I can find python version with python --version\nBut I cannot find the location of python executable. Is there a command like python --path? If not, is there a reason why?","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":37,"Q_Id":74102484,"Users Score":0,"Answer":"Use which python or which python3.\nWork on unix based OS.\nFor Windows, see other answers.","Q_Score":1,"Tags":"python,windows","A_Id":74102493,"CreationDate":"2022-10-17T19:48:00.000","Title":"Why is there no command line to find python location?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have an actor that uses the stub with a host and port to request a service from the server. I don't want to change the actor code. Is there a way where I use an instance of the Actor that takes the host and port and calls a service from a mock server? I don't want to create a server I just want to test my client. I looked at grpc_testing, but the documentation didn't really help me and I didn't find any examples. Pytest also doesn't seem to work for this, afaik. I'm a beginner regarding grpc. Can someone help me out?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":45,"Q_Id":74127618,"Users Score":0,"Answer":"Unfortunately gRPC Python don't provide the ability to create mock server, If you just want to test client side code, the closet thing to do is bring up a very simple (like helloworld) local server as a 'mock'.","Q_Score":0,"Tags":"python,mocking,grpc","A_Id":75214141,"CreationDate":"2022-10-19T14:57:00.000","Title":"Mock a server to service a grpc call in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a coded an AI Python program and now I want to implement it in a mobile application. How can I add the python program in the mobile application, and which programming language should I use for the application to implement the python program?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":23,"Q_Id":74137889,"Users Score":1,"Answer":"since python has no built-in mobile app development capability. But you can use other packages to create some sort of mobile application for this you can use packages like Kivy, PyQt, or even Beeware's Toga library.","Q_Score":1,"Tags":"python,mobile,artificial-intelligence","A_Id":74867763,"CreationDate":"2022-10-20T09:53:00.000","Title":"how can we add a python program to a mobile application?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed Pyenv using brew and set path using\necho 'eval \"$(pyenv init --path)\"' >> ~\/.zshrc\nNow I deleted it with brew, and I got .zshrc:1: command not found: pyenv every time I opened my terminal. I understand that I need to simply remove the pyenv init invocations from my shell startup configuration. But can someone give me the right command line to do so? Thanks\nI am on MacOS by the way","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":124,"Q_Id":74155774,"Users Score":0,"Answer":"Assuming you have Vim installed, you can use vim ~\/.zshrc to open the file and then edit it out.","Q_Score":1,"Tags":"python,pyenv","A_Id":74155817,"CreationDate":"2022-10-21T15:15:00.000","Title":"How to delete Pyenv","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Is there any way to reduce the time complexity of the factorial function below O(n), and what is the time complexity of its implementation in the math library in python?\nAlso, is any memorization done for some set of inputs (in Python 3), to further reduce its runtime?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":244,"Q_Id":74162668,"Users Score":2,"Answer":"If you do not mind floating point precision, math.lgamma(n+1) returns the natural logarithm of the factorial of n.","Q_Score":1,"Tags":"python,python-3.x,algorithm,caching,time-complexity","A_Id":74166723,"CreationDate":"2022-10-22T10:15:00.000","Title":"What is the time complexity of math.factorial() function in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Django on Ubuntu 18.04.\nI've got everything set up. And I type python manage.py run_huey in the server (through an SSH connection) to start huey, and it works.\nHowever this is done through the command line through SSH and it will shut off when I close the SSH connection.\nHow do I keep run_huey running so that it will stay active at all times? Furthermore, after a system reboot, how do I get run_huey to automatically start?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":74243241,"Users Score":0,"Answer":"You may explore supervisorctl utility for ubuntu, it keeps process running and can log into file and any other features. Google it.","Q_Score":0,"Tags":"python-huey","A_Id":74613571,"CreationDate":"2022-10-29T06:24:00.000","Title":"Using Huey with Django: How to keep run_huey command running?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am writing discord bot on python (discord.py). This bot for many servers and I want to make cooldown system. This looks like this:\nUser uses command on the first server and if he uses it again, bot will tell user that command on cooldown, but if user will go to the second server, command will work without cooldown that is on the first server.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":49,"Q_Id":74251511,"Users Score":0,"Answer":"You can use\n@commands.cooldown(1, 86400, commands.BucketType.user)\nFirst number is how many times someone can run the command without triggering the cooldown.\nSecond one is how long the cooldown is in seconds.\nBucketType tells the bot its per user, there are different bucket types, for example for roles, server and so on.\nRefer to the dpy docs.\nAs far as I know bucket type user is server dependent. So it should work fine.","Q_Score":0,"Tags":"python,discord,discord.py","A_Id":74258494,"CreationDate":"2022-10-30T08:23:00.000","Title":"Cooldown for users for many servers discord.py","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i am trying to hide a password in my deployment on Github, but neither .gitignore with a config.py file nor dotenv works when i try to deploy. Anyone who knows a solution?\nI connected my .gitignore to a config.py with my variable: APP_PASSWORD = \"blablabla\". However, it does not load when i run github through Heroku. Downloading dotenv and load_dotenv did not work either. It worked on my local environment, but not on github.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":77,"Q_Id":74263464,"Users Score":0,"Answer":"I faced a similar issue; I had worked on a Discord bot, and I was trying to deploy it through Heroku. Instead of dotenv, I went on my Heroku dyno \/ project, and under settings, I created a config var, with the key being \"TOKEN\" and the value being my bot token. I was able to access this in my main.py by saying os.environ[\"TOKEN\"] (after importing os and environ).","Q_Score":0,"Tags":"python,github,environment-variables,dotenv","A_Id":74264039,"CreationDate":"2022-10-31T12:43:00.000","Title":"How do i hide a variable in Github","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"import libtorrent\n\nImportError\nTraceback (most recent call last)\nInput In [2], in ()\n----> 1 import libtorrent\nImportError: DLL load failed while importing libtorrent: The specified module could not be found.\nI am getting this error while importing libtorrent.. plz someone help me to solve this issue","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":435,"Q_Id":74276726,"Users Score":0,"Answer":"You probably just need to install or reinstall libtorrent using pip.","Q_Score":0,"Tags":"python","A_Id":74277076,"CreationDate":"2022-11-01T13:30:00.000","Title":"DLL load failed while importing libtorrent: The specified module could not be found","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Kuka Iiwa 7 arm in the scene and I am interested in getting the current(real-time) 3D coordinates of the arm joints w.r.t world (or w.r.t robot base). I am able to get the current joint 1 DOF positions(thetas) but not the exact 3D coordinate representing the position of the joint in some frame(world or base).\nI tried adding Triad for each link and tried get_pose_in_world() method for RigidBody_[float] type object of the frame, but received an error that the method does not exist for RigidBody_[float] class.\nNote: I am using PyDrake for the project.\nWhat is the correct way to approach this problem?\nThanks,\nSarvesh","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":56,"Q_Id":74279453,"Users Score":1,"Answer":"When the parser creates a joint, it'll also crate a \"parent\" frame and a \"child\" frame. These two frames are then constrained by the joint such that in the \"zero configuration\" (say zero angle) the parent and child frames are coincident.\nIf you do happen to have the frame object, then you can call Frame::CalcPoseInWorld(). Now, to retrieve the frame, you need to know its name. For that you will call GetFrameByName().\nSay you want the pose of the parent frame. Here is the convention used to name frames:\n\nIf the pose of the parent frame in the body frame is the identity (either a default or explicitly provided) then the parent frame IS the body frame and you can retrieve it with the body's name.\nIf the pose is not the identity, then a new frame is created (offset by that pose) and its name is \"parent_[body_name]\", where body_name is the name of the parent body.","Q_Score":1,"Tags":"python,transformation,robot,drake","A_Id":74281479,"CreationDate":"2022-11-01T17:12:00.000","Title":"Getting joint location(3D pose) w.r.t world of Kuka Iiwa arm in Drake","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is a school challenge. Given an encrypted file (which is an audio file) I need to figure out how I can decrypt it. Don't have a key, of course.\nNow the clue is that I have a small part of the original plain audio file, but I do not know from which part of the encrypted file it is aligned to. I also know the byte size used for encryption is 16 bytes.\nSo my questions are, if you can give me the ideas:\n\nI believe trying to break the key by plaintext attack or bit flipping on the full encrypted file would be too much.\nHow can I compare the 16-byte blocks in the small plain file with the blocks in the encrypted file, to spot the pattern that can help me figure out the key used for encryption? How do I even get the key even if I know \"these 16-bytes in the plain file are these 16-bytes in the encrypted file\"? How does that even help? But there is some point to it otherwise the challenge would not have given it.\nIs there any other way to approach this?\nThank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":177,"Q_Id":74322399,"Users Score":1,"Answer":"Given a window of 20kb, break it into 16 chunks. If the 20kb of plaintext is not exactly a multiple of 16 bytes, truncate the end of it. Generate a vector of length 20kb\/16 = 1280 numbers as follows: assign 0 to the first block. Store it in a dictionary keyed by the block and whose value is the index 0. Move on to the next block. If it is the same as the first block -- assign 0 to it. Otherwise assign 1 to it and create a second dictionary entry. Iterate over the blocks. For each block you check if it is in the dictionary. If it is -- assign to it the value of this entry. Otherwise increment the last index used and create a new dictionary entry.\nThe result will look something like [0, 1, 2, 3, 1, 4, 2, 5, 6, 7, ...]. This can be thought of as a statistical profile of the plaintext.\nNow have a sliding window of width 20kb move over the ciphertext. For each window, compute its statistical profile (perhaps it can be updated rather that computed from scratch as the window slides). Eventually you will get a window with the same profile as the plaintext. You now know (with high probability) where the plaintext is within the ciphertext. This will give you up to 20kb of known plaintext-ciphertext blocks. Hopefully that will be enough.\nThe basic logic can be understood in the context of simple substitution ciphers. The word MISSISSIPPI would have profile 0 1 2 2 1 2 2 1 3 3 1. If it were encrypted with a substitution cipher it might map to e.g. XQTTQTTQKKQ -- which has exactly the same profile. If you knew that a given ciphertext contained an encryption of MISSISSIPPI, you could slide through the ciphertext in windows of width 11 until you found a window with the right profile. At that point you would know the ciphertext equivalents of MISP, which will give a partial break into the system. AES ECB is basically just a substitution cipher (albeit one on a much larger alphabet) so the same basic logic applies.","Q_Score":2,"Tags":"python,aes,ecb","A_Id":74323499,"CreationDate":"2022-11-04T20:02:00.000","Title":"Crypto attack on AES ECB","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have xyz axis for gyro and accelerometer data, and i want to detect between whether the travel path was circular or square\nHave not tried anything, want initial ideas","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":17,"Q_Id":74346346,"Users Score":-1,"Answer":"The way I would approach this would be:\nFirst compute some characteristics about my data such as:\n\ncentroid of my points\nmax distance between two points\n...\n\nThen create reference shapes with that data, for example a circle with its center being the computed centroid of my points, and its diameter being the max distance,...\nThen try to find how close to each reference shape is every point in my path to compute the standard deviation between each reference shape and my path. This might be more or less difficult depending on how complicated your reference shapes are.\nFinally I would just pick the shape with the smallest standard deviation.\nThis might not be very optimal though, since it involves quite a lot of computation, especially if you have a lot of point in your path.","Q_Score":0,"Tags":"python,matplotlib","A_Id":74346551,"CreationDate":"2022-11-07T12:08:00.000","Title":"How can i distinguish between square and circular shapes from accelerometer and gyroscope sensor data using python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"From what I understand, the pb2.py file is code from the protoc file and the pb2_grpc.py file is code generated by protoc from the .proto file. But I don't understand what that means. I am very confused, can someone please explain this to me.\nThank you\nI have tried to google the question, but I couldn't find anything that I could understand","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":128,"Q_Id":74351626,"Users Score":0,"Answer":"Both are generated by protoc or python -m grpc_tools.protoc (a Python module that wraps protoc).\nA pb2.py file contains the core Protocol Buffer (message) definitions and is created as a result of the --python_out flag being specified.\nA pb2_grpc.py file contains the service and rpc (method) definitions and is created as a result of the --grpc_python_out flag being specified.","Q_Score":0,"Tags":"protocol-buffers,grpc-python","A_Id":74355276,"CreationDate":"2022-11-07T19:02:00.000","Title":"WHat is the difference between the filename_pb2_grpc.py and the filename_pb2.py files?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I have a function that is quadratic complexity, i.e. the runtime is directly proportional to the square of the input size. How would I identify its best or worse case runtime, specifically how do I determine if the best and worst case are the same?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":54,"Q_Id":74356911,"Users Score":2,"Answer":"This really depends on your algorithm and your input data. For example\na search algorithm can have a typically runtime of O(x^2) but in certain situations this differs:\n\nTypically runtime is for statistically random data (normal case)\n\nIf the input data is already sorted (best case), then it depends on the algorithm if it still has normal runtime or is faster e.g. O(1)\n\nIf the input data is shaped explicitly in the worst order that there is possible for this specific algorithm (but not very likely), then it may have a bigger worst-case O-notation\n\n\nWhich algorithm you choose then depends on your use case:\n\nIf the data is most likely already sorted or partially sorted: You may go with an algorithm that has better best case runtime\nIf you want fastest results in most cases (with unsorted data): You go for best normal case\nIf your algorithm may kill someone if it takes to long (e.g. dealing with malicious user input): You will choose one which as equal normal\/worst case runtime","Q_Score":0,"Tags":"python,big-o,computer-science","A_Id":74357211,"CreationDate":"2022-11-08T07:14:00.000","Title":"Calculating best-case, worse-case Complexity","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm making an rpi based terminal in python and I want to run a powershell command on my computer. How can I send a command to a usb device","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":35,"Q_Id":74360724,"Users Score":0,"Answer":"You could run socat on your Windows PC to read from serial and execute whatever you receive - if you like big security holes\ud83d\ude09 Try adding socat tag to attract the right folk if that's an option.\nOr you could run a Python script that sits in a loop reading from serial and then using subprocess.run() to execute the commands it receives.","Q_Score":0,"Tags":"python,linux,windows,powershell","A_Id":74361649,"CreationDate":"2022-11-08T12:25:00.000","Title":"How to send powershell command to pc through usb with python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"According to the documentation, importlib.metadata.version should work on dist-info folders in ZIP files. However, if you run pip install -t foo jedi-language-server (though you can use any package), zip -r foo.zip foo, PYTHONPATH=foo.zip\/foo python -c \"from importlib.metadata import version; version('jedi-language-server')\", I get importlib.metadata.PackageNotFoundError: No package metadata was found for jedi-language-server","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":74380541,"Users Score":0,"Answer":"Apparently, it only works if the metadata is in the top-level directory; that is, you have to do (cd foo; zip -r foo.zip .). It does not support nested directories.","Q_Score":0,"Tags":"python,python-importlib","A_Id":74380572,"CreationDate":"2022-11-09T19:43:00.000","Title":"Why doesn't `importlib.metadata.version` work on zip files?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm programming a discord bot which should start some comands including a timer and two surveys every tuesday and thursday at 11.30 am.\nUnfortunately the documentary is outdated and older articles in stack overflow do not work anymore. How do I do that in Python or is this impossible? The single commands are already programmed and work without problems.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":74430312,"Users Score":0,"Answer":"I got my soultion. I worked with apscheduler and now I can time it for days and times.\nThis can be closed.","Q_Score":0,"Tags":"python,automation,discord,discord.py,bots","A_Id":74489847,"CreationDate":"2022-11-14T10:38:00.000","Title":"Automated Messages in discord.py (discord bot)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to get the distribution data BEFORE uploading. All there is is a magnet link or .torrent file. What do I need to do?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":31,"Q_Id":74448565,"Users Score":1,"Answer":"The question was incorrectly asked by me. I needed to find the size of all the files in the torrent. This is done using:\nhandle = lt.add_magnet_uri(ses, url, params)\nhandle.status().total_wanted","Q_Score":0,"Tags":"python,libtorrent","A_Id":74463744,"CreationDate":"2022-11-15T15:54:00.000","Title":"How to use LibTorrent for python to get information about the distribution?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I remove existing and future pycahce files from git repository in Windows? The commands I found online are not working for example when I send the command \"git rm -r --cached __pycache__\" I get the command \"pathspec '__pycache__' did not match any files\".","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":76,"Q_Id":74462238,"Users Score":0,"Answer":"Well, you don't need __pycache__ files in your git repositories and you'd better to ignore all related files to it by adding __pycache__\/ to your .gitignore file.","Q_Score":0,"Tags":"python,git,pyc","A_Id":74528490,"CreationDate":"2022-11-16T14:30:00.000","Title":"Removing pycache in git","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a ML model with fast api wrapper running on google cloud VM, it runs fine when ssh terminal is open. but once I close the terminal it runs for 10 more minutes maybe and then the api returns 502 bad gate way\nI'm using nginx with this config\n server{listen 80; server_name: public ip; location \/{proxy_pass http:\/\/127.0.0.1:8000;}}\nplease let me know if there is any way I can fix this problem.\nreran everything sill same error","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":20,"Q_Id":74481058,"Users Score":0,"Answer":"When you close the SSH terminal session, the applications that you started will be killed. Use a program such as tmux, screen, etc. to create sessions that you can attach to and detach from.\nHowever, since you are using Nginx, there are better methods of managing applications that are being proxied. For development, your current method is OK. For production, your proxied applications should be started and managed by the system as a service.","Q_Score":0,"Tags":"python,python-3.x,nginx,google-cloud-platform,fastapi","A_Id":74482469,"CreationDate":"2022-11-17T19:26:00.000","Title":"fast api stopping after a while on google cloud vm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have been doing a lot of search engine search for past 7 days on how to do FFI with python but most examples are on using C or Rust and one example on using go lang but I do not see anyone going with Python but it is widely used one.\nCan we use Python code to run via PHP FFI to process any data?\nIf yes, can you show a sample example of the same as I do not see a reference of it or presence of it only, this will be helpful of whoever else is searching on it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":153,"Q_Id":74496877,"Users Score":0,"Answer":"FFI enables you to run code from a shared library. As far as I know, you are not able to compile python code as a shared library, so no, you cannot use PHP FFI to run python scripts.","Q_Score":2,"Tags":"python,php,ffi,php-ffi","A_Id":76496859,"CreationDate":"2022-11-19T01:19:00.000","Title":"Can we use PHP FFI to run python scripts?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just wanted to make python and Arduino work together. I saw tutorial that showed that we need library called \"Pyfirmata\" to do it. when I type \"pip install pyfirmata\" in command prompt, it shows that the library is already installed. but when I type \"import pyfirmata\" in python it shows error that library does not exist. please help me if you can.\nwhen I type \"pip install pyfirmata\" in command prompt, it shows that the library is already installed. but when I type \"import pyfirmata\" in python it shows error that library does not exist. please help me if you can.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":23,"Q_Id":74509458,"Users Score":0,"Answer":"It works fine for me, check if your ide is using the same version of python you installed Pyfirmata with","Q_Score":0,"Tags":"python,arduino,pyfirmata","A_Id":74509532,"CreationDate":"2022-11-20T15:30:00.000","Title":"why does not pyfirmata import?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to setup a warning system for a moderation bot with discord.py. Is there some way I can make it so when I use a !warn [user] [reason] command, it is stored in some type of database, but the warning is removed automatically after 30 days.\nIs there also a way to make it so each warning has a specific case number, so that I can use a command to delete a specific warning, instead of deleting all of a user's warnings?\nAlso, I'm not sure what type of file to use to store all of that stuff, I've seen people use a bunch of different types. Not sure if it even changes anything.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":74510880,"Users Score":0,"Answer":"You could store all of the warns in a .json file then where there is a list of all the warns with reasons, user ids, time when warn was given and so much more. Then you can just make it so that when the !warn command is called, the bot removes any of the warns that have past 30 days using the date that is stored in the .json file.","Q_Score":0,"Tags":"python,discord,discord.py","A_Id":74511033,"CreationDate":"2022-11-20T18:38:00.000","Title":"How to make warnings expire? Discord.py","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I noticed something on my script. Sometimes it stops and when I press any keys on my keyboard it resumes. I didnt put any keypress command on my script. It's running on a windows vps.\nAny idea why is this happening?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":12,"Q_Id":74515555,"Users Score":0,"Answer":"I found the issue. When i clicked on the terminal the script pauses. To fix this go to terminal properties then uncheck the quick edit.","Q_Score":0,"Tags":"python-3.x","A_Id":74549894,"CreationDate":"2022-11-21T07:32:00.000","Title":"Why my python script sometimes stopping and waiting for keypress?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to test ES data without mocking, which is smart enough to figure out, what should be result at the top\nDid google, found most of the libraries are mocking data, but as we have evolving ES indices and logic changes day by day, what should be best practise to follow.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":10,"Q_Id":74522257,"Users Score":0,"Answer":"You could configure your local elasticsearch to connect production DB when it creates the index.","Q_Score":0,"Tags":"python,elasticsearch,testing,pytest","A_Id":74522287,"CreationDate":"2022-11-21T16:48:00.000","Title":"Elastic serach testing on Production Database (Read only ES usecase)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So as I understood, pytest-cov has an option to fail if total coverage is lower than some %. But can I output hole tablet only in case if total cov is lower then 90% and if it is upper it won't show anything?\nExample of command line code","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":49,"Q_Id":74522777,"Users Score":0,"Answer":"pytest-cov doesn't have this option, but you don't have to use pytest-cov to produce the report. Use the plugin to run coverage, then in a separate command, produce the report: coverage report. You can conditionally run that separate command based on whatever condition you want.","Q_Score":0,"Tags":"python,pytest,code-coverage,test-coverage,pytest-cov","A_Id":74531233,"CreationDate":"2022-11-21T17:30:00.000","Title":"How to get pytest-cov only if total coverage lower then 90%","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a more easy way to get this path when mocking functions?\n@mock.patch('folder1.folder2.file.class.get_some_information', side_effect=mocked_information)\nI would like to have the path for the function get_some_information generated automatically. Thanks!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":80,"Q_Id":74527960,"Users Score":1,"Answer":"Helper package to generate paths for mocking: github.com\/pksol\/mock_autogen#generating-the-arrange-section","Q_Score":0,"Tags":"python,mocking,patch","A_Id":74545432,"CreationDate":"2022-11-22T05:41:00.000","Title":"Mock patch path to function","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm developing a discord bot using nextcord.\nWhen i'm registering slash command and deleting it later, it's also staying at discord command list.\nWhat can I do to delete non-existent slash commands or sync actual bot's command list with discord?\nP.S. All of my commands are in different cogs\nI was waiting about 4 hours for registering and sync slash commands by discord but to no avail.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":504,"Q_Id":74582360,"Users Score":1,"Answer":"You should try kicking your bot and then inviting it back to your server. If this doesn't work, regenerate your bot's token. This should sync it back with Discord, and the command should be gone.","Q_Score":1,"Tags":"python,discord,nextcord","A_Id":74648165,"CreationDate":"2022-11-26T12:57:00.000","Title":"Slash commands don't disappearing (nextcord)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm not able to find the variable that holds the Message Type in event name, \"on_association_requested\" and \"on_association_released\" methods. If we give event.event.name it results in \"EVT_REQUESTED\" or \"EVT_RELEASED\".\nINCOMING DIMSE MESSAGE\nD: Message Type : C-ECHO RQ\nD: Presentation Context ID : 1\nD: Message ID : 1\nD: Data Set : None\nEND OF DIMSE MESSAGE\nI tried to get the Message Type, I was not able to find how.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":57,"Q_Id":74611115,"Users Score":0,"Answer":"There is no DIMSE message type during association request. Only after an association has already been through request and acceptance are DIMSE messages allowed to be sent.","Q_Score":0,"Tags":"python,pynetdicom","A_Id":74636655,"CreationDate":"2022-11-29T08:32:00.000","Title":"pynetdicom on_association_requested() get request type (C_FIND, C_ECHO etc)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am new in python programming and I was trying to create a Snapchat bot\nCan you help me create a request based Snapchat bot.\nI will be using this for marketing with my existing clients to help schedule posts. It will also be an auto responder to act as Thank you or Welcome messages.\nIf you got any ideas you can share your thoughts, thank you\nBasically I need a python script to handle message scheduling and auto response","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":165,"Q_Id":74665242,"Users Score":0,"Answer":"Snapchat now supports the web or browser. So you can take a look at the tutorials of pyautogui module in python. you can manipulate the keyboard and mouse events and respond to the messages with prewritten messages of yours. Your task can be done easily.","Q_Score":0,"Tags":"python","A_Id":74665259,"CreationDate":"2022-12-03T08:52:00.000","Title":"Creating a Snapchat bot in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When trying to make an animation in Ursina Engine you can call a frameanimation3d function but it requires an obj file for each frame.\nSo if there are 100 .obj files to load, the game will be slower. Is there maybe a way to load all these files faster?\n( Or maybe use panda3d actor function, but doesn't it support a certain type of file? )","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":44,"Q_Id":74671926,"Users Score":0,"Answer":"It is true, you can load animations faster with panda3d or ursina. If you are using panda3d, use their .egg file. You can improve performance by instancing and using LoD. Check the examples in Panda's Manual. Don't forget, ursina is built above panda3d, so you can use Panda's code in ursina.\nP.S.: I'm not sure if Panda's actor supports LoD.\nI wrote this in case if you are using the same model","Q_Score":1,"Tags":"python-3.x,animation,panda3d,ursina","A_Id":74782573,"CreationDate":"2022-12-04T00:21:00.000","Title":"Does anybody know how to load the frameanimation3d in ursina faster?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"So I want to know if it is possible, that a bot gets the content sent to it in a dm and send that in a specifyed channel on a server.\nSo basically you dm the bot the word \"test\" and the bots sends the word in a channel of a server","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":64,"Q_Id":74681161,"Users Score":1,"Answer":"Yes, it is possible for a bot to receive a direct message and then repost the message in a specified channel on a server. This can be done using the Discord API.\nYou can do the following:\n\nCreate a Discord bot and add it to your server. You can do this using the Discord developer portal.\n\nUse the Discord API to listen for messages sent to the bot in a DM. You can do this using the message event and the DMChannel class in the Discord API.\n\nWhen the bot receives a DM, use the Discord API to repost the message in the specified channel on the server. You can do this using the send method of the TextChannel class in the Discord API.","Q_Score":0,"Tags":"python,discord,discord.py","A_Id":74681428,"CreationDate":"2022-12-04T21:39:00.000","Title":"Getting content from a dm in discord.py","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm curious how many actual requests per second my service is getting while locust load test.\nIf it has 50 users and shows 6 RPS, does it mean I'm getting 50*6=300 requests per second?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":196,"Q_Id":74687220,"Users Score":0,"Answer":"If you are monitoring from locust UI 6 rps means 6 requests per second regardless of user count. Web UI shows the total rps generated from all workers.","Q_Score":0,"Tags":"python,performance,fastapi,load-testing,locust","A_Id":74687544,"CreationDate":"2022-12-05T11:10:00.000","Title":"What is true rps in locust","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an embedded linux system that I need to run a python script whenever it boots. The python script needs to have a terminal interface so the user can interact and see outputs. The script also spawns another process to transfer large amounts of data over SPI, this was written in C.\nI've managed to get the script to start on launch and have terminal access by adding\n@reboot \/usr\/bin\/screen -d -m python3 \/scripts\/my_script.py\nto the crontab. I can then do \"screen -r\" and interact with the script. However if launched in this way the script fails to start the external SPI script. In python I launch the script with subprocess.Popen\nproc=subprocess.Popen([\".\/spi_newpins,\"-o\",\"\/media\/SD\/\"+ latest_file\"])\nand this works perfectly whenever I manually launch the script, even within screen. Just not when it is launched by crontab. Does anyone have any ideas on how to get the spi subprocess to also work from crontab?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":20,"Q_Id":74731780,"Users Score":0,"Answer":"Fixed now, I had to add an absolute path to the spi_newpins function call\nproc=subprocess.Popen([\"\/scripts\/.\/spi_newpins\",\"-o\",\"\/media\/SD\/\"+ latest_file\"])","Q_Score":0,"Tags":"python,cron,embedded-linux","A_Id":74733159,"CreationDate":"2022-12-08T14:26:00.000","Title":"Embedded linux start python from crontab with terminal access and subprocess permissions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Recently, I was working on my HTML project and I wanted to add some functionality and I had already written code for that in Python. But, I faced a problem I couldn't add that Python code to my HTML code.\nSo, I wanted to know that how I can add my Python code to my HTML code.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":35,"Q_Id":74754499,"Users Score":0,"Answer":"you can use PyScript it is a new framework and It uses python in HTML code to develop apps.","Q_Score":0,"Tags":"python,html,python-3.x","A_Id":74754544,"CreationDate":"2022-12-10T16:05:00.000","Title":"How do I add Python in HTML?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"In several Lambda functions and Elastic Beanstalk instances for a project, they all use the same helper functions and constants.\nI am trying to follow the DRY method and not hard code these parameters into each Lambda\/EB application, but instead have the modules that contain them just import into each Lambda\/EB application.\nI was ideally hoping to\n\nput all these modules in a separate GitHub repo\ncreate a codepipeline to an S3 bucket\nimport them into EB\/Lambdas wherever needed\n\nI have the first 2 steps done, but can't figure out how to import the modules from S3.\nDoes anyone have any suggestions on how to do this?","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":159,"Q_Id":74755148,"Users Score":2,"Answer":"The best way to track changes in code is using a repo but if you need to use an s3 as a repo you can consider enabling versioning in the s3 bucket\/repo and define some s3 event source to trigger your pipeline.\nFor using those dependencies I think it's best to consider using layer for lambda functions or shared EFS volumes in instances for Beanstalk if these dependencies are very important in size.","Q_Score":2,"Tags":"python,amazon-web-services,amazon-s3,aws-lambda,amazon-elastic-beanstalk","A_Id":74818522,"CreationDate":"2022-12-10T17:32:00.000","Title":"How to share modules across multiple AWS Lambda and Elastic Beanstalk applications?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to replicate a login to a page with python and the requests module but I need a token bearer.\nThis site doesn't require a login password connection but just an event code (wooclap.com)\nI cannot find when the token is recovered by looking at header and json responses.\nIf you can help me\nThanks","AnswerCount":3,"Available Count":2,"Score":-0.1325487884,"is_accepted":false,"ViewCount":270,"Q_Id":74772283,"Users Score":-2,"Answer":"To send a GET request with a Bearer Token authorization header using Python, you need to make an HTTP GET request and provide your Bearer Token with the Authorization: Bearer {token} HTTP header","Q_Score":0,"Tags":"python,web,token","A_Id":74772334,"CreationDate":"2022-12-12T14:05:00.000","Title":"How get bearer token with requests from python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to replicate a login to a page with python and the requests module but I need a token bearer.\nThis site doesn't require a login password connection but just an event code (wooclap.com)\nI cannot find when the token is recovered by looking at header and json responses.\nIf you can help me\nThanks","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":270,"Q_Id":74772283,"Users Score":0,"Answer":"once you put in a event code check the network tab on you're chrome console there should be a request wich returns the token. either in the reponse header or the json,","Q_Score":0,"Tags":"python,web,token","A_Id":74772388,"CreationDate":"2022-12-12T14:05:00.000","Title":"How get bearer token with requests from python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I got a package that i am about to upload to a local devpi server. I got some issues with the package not being able to find the conf.py file for Sphinx which makes sense as it looks at the (package_name)\/docs folder instead of (package_name)\/docs\/source which i use and also has all the RST files in it. How do i in pyproject.toml configure Devpi to set sphinx source_dir to (package_name)\/docs\/source?\nIt could surely be resolved in some way using sys.path.append() and then changing the path of the config but I do wonder about the configuration of this and if it is supported.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":74773453,"Users Score":0,"Answer":"In devpi-client version 5.2.3 it should work.\nBecause the change:\n\"Use sphinx-build command instead of setup.py build_sphinx when building documentation.\" in version 6.0.0 the upload routine doesn't \"recognize\" your local dir structure.\nBut I haven't find out yet how you can propagate arguments to the sphinx-build to specify the docs source dir.","Q_Score":0,"Tags":"python,python-sphinx,devpi","A_Id":75015956,"CreationDate":"2022-12-12T15:29:00.000","Title":"Configuring source dir for Sphinx documentation conf.py file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to run PyTest using the Testing extension in VSCode, but it's failing.\nMy directory structure is as follows:\n\nconftest.py (empty)\nsrc\n\n__init__.py (has important_function that is imported in main.py)\nmain.py\n\n\ntest\n\n__init__.py (empty)\ntest_main.py\n\n\n\nBefore I had the src\/__init__.py, PyTest was able to find the tests without problems.\nBut now it says:\nImportError: cannot import name 'important_function' from '__init__' (\/Users\/ynusinovich\/.vscode\/extensions\/ms-python.python-2022.20.1\/pythonFiles\/testing_tools\/__init__.py)\nIt seems like VSCode decided to look for the function in its own __init__ folder, instead of in my src folder. Is there any way to direct it to the correct location?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":53,"Q_Id":74794487,"Users Score":0,"Answer":"Temporary solution:\nI renamed the __init__.py in the src folder to utils, and now VSCode's PyTest is no longer confused about where to look for important_function.","Q_Score":0,"Tags":"python,visual-studio-code,pytest","A_Id":74802444,"CreationDate":"2022-12-14T06:45:00.000","Title":"Error Collecting PyTests After __init__.py Added to src Folder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"maybe it is simple but I didn't find a satisfactory answer yet.\nI have a python application that collects data over CAN bus (temperature, weight, ...) and I want to visualize them over Angular.\nOn the one side, I wrote the Python application that cyclic read the CAN-bus data and writes them to the console and on the other hand I wrote a small Angular application that contains the first step a simple table.\nNow I want to fill in the table every 10 seconds with data from the Python application instead of printing them to the console.\nHow can I connect these both?\nMy first thought was a simple file where I save the values from Python and read them with Angular.\nThe second solution is a database, but I think this is too much for only a few values\nSo is there a direct way to access the Python data from Angular?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":93,"Q_Id":74820685,"Users Score":0,"Answer":"There are several ways you can access Python data from an Angular application:\n\nOne way is to use a REST API. You can create a REST API in Python\nusing a web framework like Flask or Django, and then use Angular's\nHTTP client to make requests to the API and retrieve the data.\n\nAnother option is to use WebSockets. You can use a Python library\nlike asyncio or websockets to set up a WebSocket server, and then\nuse Angular's WebSocket client to connect to the server and receive\nupdates in real-time.\n\nYou can also use a message queue like RabbitMQ or ZeroMQ to allow\nyour Python and Angular applications to communicate with each other\nasynchronously.\n\n\nOverall, the best approach will depend on your specific requirements and how you want to structure your application. A REST API is a good choice if you need to retrieve data from the Python application on demand, while WebSockets or a message queue can be used for real-time communication and updates.","Q_Score":0,"Tags":"python,angular,backend,web-frontend","A_Id":74839148,"CreationDate":"2022-12-16T05:54:00.000","Title":"How to fetch Python data with Angular","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"maybe it is simple but I didn't find a satisfactory answer yet.\nI have a python application that collects data over CAN bus (temperature, weight, ...) and I want to visualize them over Angular.\nOn the one side, I wrote the Python application that cyclic read the CAN-bus data and writes them to the console and on the other hand I wrote a small Angular application that contains the first step a simple table.\nNow I want to fill in the table every 10 seconds with data from the Python application instead of printing them to the console.\nHow can I connect these both?\nMy first thought was a simple file where I save the values from Python and read them with Angular.\nThe second solution is a database, but I think this is too much for only a few values\nSo is there a direct way to access the Python data from Angular?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":93,"Q_Id":74820685,"Users Score":0,"Answer":"Basic idea is to create an api in python and let angular consume that\nthen there is the question of weather you want to have backup data in python,\nif so then save it a db or file and use that as response for angular\nif you want to do some fancy real time stuff may be look into long polling or http event stream","Q_Score":0,"Tags":"python,angular,backend,web-frontend","A_Id":74838964,"CreationDate":"2022-12-16T05:54:00.000","Title":"How to fetch Python data with Angular","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to start a new chat in Telegram with a Python script but I know with neither Telegram's BOT nor its API it is possibile.\nI don't want the user starts the chat with a BOT before!\nHowever I was wandering if you can achieve this in anther way. I mean, when you create a new chat with Telegram application, there will be, somehow, and endpoint which handle this request.\nWhy is it impossibile to create a Python script which emulates this action?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":55,"Q_Id":74923330,"Users Score":0,"Answer":"I don't want the user starts the chat with a BOT before!\n\nThis is not possible. A Bot can never start a chat, that has to be done by the user him\/her self.\nAfter the user has started a conversation with the Bot, you can send anything to the user until the user stops the conversation.","Q_Score":0,"Tags":"python,telegram","A_Id":74931072,"CreationDate":"2022-12-26T19:12:00.000","Title":"Telegram start new chat with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any software that auto generates GUI wrappers around python scripts?\nMy specific scenario is that i wrote a simple script for my father in law to bulk download some stuff from a given url.\nNormally you just run the script via\npython my_script.py --url https:\/\/test.com --dir C:\\Downloads\nand it just downloads all the relevant files from test.com to the Downloads folder.\nI think he might be able to handle that but i am not sure and so i was thinking if there is any simple software out there that would allow me to take the script and turn it into an executable that just asks for all arguments and then has a simple run button to execute the script and download the things.\nIdeally this would mean that he doesnt have to install python but at the very least allow for easier handling for him.\nI am aware that there are libraries that allow for the creation of custom GUIs for python but thought that maybe there already exists something simpler and generic for my very simple and i also think fairly common use case.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":197,"Q_Id":74923647,"Users Score":0,"Answer":"I ended up using PyInstaller (thanks @Dexty) and rewriting the script to grab the arguments by asking for them via input.\nNot exactly a GUI but that still allows the user to just double click the .exe and go from there instead of having to proactively use a CLI.","Q_Score":1,"Tags":"python,user-interface,exe","A_Id":75357695,"CreationDate":"2022-12-26T20:05:00.000","Title":"Automatic GUI for python script with command line arguments?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have correctly got a microbit working with serial communication via COM port USB.\nMy aim is to use COM over bluetooth to do the same.\nSteps I have taken:\n\n(on windows 10) bluetooth settings -> more bluetooth settings -> COM ports -> add -> incoming\nin device manager changed the baud rate to match that of the microbit (115,200)\npaired and connected to the microbit\ntried to write to both the serial and uart bluetooth connection from the microbit to the PC (using a flashed python script)\nusing Tera Term, setup -> serial port... -> COM(number - in my case 4), with all necessary values (including 115,200 baud rate)\n\nAfter doing all of these, I see no incoming message on Tera Term. Have I missed anything?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":44,"Q_Id":74963246,"Users Score":1,"Answer":"This is not directly possible via BLE UART communication because it uses different protocols (as mentioned above by ukBaz).\nYou are able to, however, communicate via custom BLE libraries such as bleak.\nBleak has some good examples on its github repo of how to scan GATT characteristics and services to find the TX and RX characteristics of your BLE device.\nFrom there you're able to connect to the microbit directly over bluetooth and read and write to it's GATT table and not using the proprietary BLE protocols etc.\nI'll make a tutorial at some point and link it back here when it's done.","Q_Score":0,"Tags":"python,bluetooth,serial-port,bbc-microbit,spp","A_Id":75134319,"CreationDate":"2022-12-30T15:34:00.000","Title":"Using serial ports over bluetooth with micro bit","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using a python script that login to AWS account with an IAM user and MFA (multi-factor authentication) enabled. The script runs continuously and does some operations (IoT, fetching data from devices etc etc).\nAs mentioned, the account needs an MFA code while starting the script, and it does perfectly. But the problem is script fails after 36 hours because the token expires.\nCan we increase the session token expiration time or automate this task not to ask MFA code again and again?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":56,"Q_Id":74968390,"Users Score":0,"Answer":"Unfortunately not, the value can range from 900 seconds (15 minutes) to 129600 seconds (36 hours). If you are using root user credentials, then the range is from 900 seconds (15 minutes) to 3600 seconds (1 hour).","Q_Score":0,"Tags":"python-3.x,amazon-ec2,boto3,multi-factor-authentication","A_Id":74968968,"CreationDate":"2022-12-31T08:26:00.000","Title":"Increase aws session token expiration time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"In installing and utilizing cURL (specifically curl 7.86.0 (Windows) libcurl\/7.86.0; previously I said it was curl 7.83.1 (Windows) libcurl\/7.83.1 but I was mistaken) to download .htm files in conjunction with\/subordinate to a mass media-file downloading program called gallery-dl, I ran into a filenaming problem regarding how cURL deals with \"weird\" characters.\nBasically, it seems that at least for my version or install of cURL, when I try to use some kind of alternate version of a symbol such as Big Solidus \u29f8 slash instead of normal slash in the filenaming command, cURL will create the .htm file but will replace that alternate symbol with an underscore. I know this isn't a problem with cURL interpreting the Big Solidus as a normal slash, since when I try to instead use a Fullwidth Solidus \uff0f slash it errors out the same way it would with a normal \/ slash.\nAs a simple example, try running something like curl [url] -o C:\\dir\\ec\\to\\ry\\test\u29f8.htm or curl [url] -o \"test\u29f8.htm\" yourself. For me, it outputs test_.htm.\nIs there anything I can do, anything I can attach to the \"weird\" characters to get cURL to avoid changing them to underscores? Or is this something version-related?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":93,"Q_Id":74974252,"Users Score":0,"Answer":"Ok, so OP here, and I've since seemed to figure out a solution to this problem, although the actual nature of the solution I'm not really certain of. It was seeming like Linux versions of cURL were not having this problem of changing characters like alternate versions of functional characters (and other characters I had since discovered mine was also changing, like Japanese characters) into underscores, while multiple Windows versions were.\nMy friend decided to compile a Windows build of cURL himself from the current source code available on github to run a debugger, and for some reason this version just doesn't have the changing-\"odd\"-characters-to-underscores problem? It just.... doesn't have the problem at all. You ask it to create a file with Big Solidus \u29f8 or a Japanese character \u3042 or anything like that and it does it just fine.\nOur only guess is that it's down to a matter of slight differences created by different compilers, and the compiler used on the official Windows builds creates the problem while some other compilers don't.","Q_Score":0,"Tags":"python,windows,curl,encoding","A_Id":75159540,"CreationDate":"2023-01-01T11:04:00.000","Title":"cURL automatically replacing alternates to functional characters with underscore?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I change my Python scripts and simultaneously running bash script, without the bash script picking up on the new changes?\nFor example I run bash script.sh whose content is\n\npython train1.py\npython train2.py\n\nWhile train1.py is running, I edit train2.py. This means that train2.py will use the old code not the new one.\nHow to set up such that train2.py uses the old code?\nRunning and editing on two different PCs is not really a solution since I need the GPU to debug for editting. Merging them is also not a good idea because of the abstraction.\nSpecs:\nRemote Server\nUbuntu 20.04\nPython - Pytorch\nI imagine there is some git solution but have not found one.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":37,"Q_Id":75040517,"Users Score":0,"Answer":"Any changes done to train2.py, which are commited to disk before the bash script executes train2.py will be used by the script.\nThere is no avoiding that because contents of train2.py are not loaded into memory until the shell attempts to execute train2.py . That behaviour is the same regardless of the OS distro or release.\nKeep the \"master\" for train2.py in a sub-directory, then have the bash script remove train2.done at the start of the script, and touch train2.done when it has completed that step.\nThen have a routine that only \"copies\" train2.py from the subdir to the production dir if it sees the file train2.done is present, and wait for it if it missing.\nIf you are doing this constantly during repeated runs of the bash script, you probably want to have the script that copies train2.py touch train2.update before copying the file and remove that after successful copy of train2.py ... then have the bash script check for the presence of train2.update and if present, go into a loop for a short sleep, then check for the presence again, before continuing with the script ONLY if that file has been removed.","Q_Score":0,"Tags":"python,bash,deep-learning,version-control","A_Id":75044583,"CreationDate":"2023-01-07T12:58:00.000","Title":"Editing Python scripts while running bash script that contains the Python scripts","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to get a list of instagram followers for a daily statistical tracker. I was using InstaLoader and using the login credentials of a Instagram account, but for obvious reasons it keeps getting flagged for suspicious activity. I would like to completely remove logging into an account from the program but I have not found any alternatives","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":72,"Q_Id":75044048,"Users Score":0,"Answer":"Its a bit more hardware intense, but you can try to webscrape your follower number using something like selenium. If you use selenium-stealth or undetected_chromedriver I don't think you will get flagged. Im not sure but I hope this helps","Q_Score":0,"Tags":"python,instagram","A_Id":75044379,"CreationDate":"2023-01-07T21:57:00.000","Title":"Is there a way to be able to get a list of someones instagram followers without using InstaLoader in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to get a list of instagram followers for a daily statistical tracker. I was using InstaLoader and using the login credentials of a Instagram account, but for obvious reasons it keeps getting flagged for suspicious activity. I would like to completely remove logging into an account from the program but I have not found any alternatives","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":72,"Q_Id":75044048,"Users Score":0,"Answer":"For some reason instagram doesn't load all followers in web version - selenium may be not helpful for scraping. Check out chrome extension IG Exporter, it stores all followers to CSV. As for logging into\/out issue, check using Chrome profile with selenium - it will allow to leave user logged in (if it suits you in terms of security)","Q_Score":0,"Tags":"python,instagram","A_Id":75044601,"CreationDate":"2023-01-07T21:57:00.000","Title":"Is there a way to be able to get a list of someones instagram followers without using InstaLoader in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"im creating a discord bot in python and i would like to make my bot command the music bot to play music. for example i want my bot to write \/play prompet:[SONG_NAME] in a chat room and let it be recognized and played by the other music bot. if someone has an idea to make it work please help!\ni been trying to just write a string with my own bot \"\/play prompet:[SONG_NAME]\" but the other bot is not reacting.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":49,"Q_Id":75110954,"Users Score":0,"Answer":"You can't do this. Discord.py by default doesn't invoke commands on messages of other bots, unless you override on_message and call process_commands without checking the message author.\nConsequently, if the bot is not yours and you cannot control it, there's nothing you can do about it. If the other bot allows it then it will work without you having to do anything.\nInvoking slash commands from chat will never work, as they're not made to be called by bots.","Q_Score":0,"Tags":"python,discord,discord.py,bots","A_Id":75111110,"CreationDate":"2023-01-13T15:06:00.000","Title":"How to make a discord bot use other discord bot commands?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to login to IBM i System using Python without entering the username and password manually.\nI used py3270 library but it is not able to detect the Emulator wc3270. The emulator I use has .hod extension and opens with IBM i Launcher.\nCan anyone help me with this? what could be the possible solution for this?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":104,"Q_Id":75157007,"Users Score":1,"Answer":"os.system() is a blocking statement. That is, it blocks, or stops further Python code from being executed until whatever os.system() is doing has completed. This problem needs us to spawn a separate thread, so that the Windows process executing the ACS software runs at the same time the rest of the Python code runs. subprocess is one Python library that can handle this.\nHere is some code that opens an ACS 5250 terminal window and pushes the user and password onto that window. There's no error checking, and there are some setup details that my system assumes about ACS which your system may not.\n\n# the various print() statements are for looking behind the scenes \n\nimport sys\nimport time\nimport subprocess\nfrom pywinauto.application import Application\nimport pywinauto.keyboard as keyboard\n\nuserid = sys.argv[1]\npassword = sys.argv[2]\n\nprint(\"Starting ACS\")\ncmd = r\"C:\\Users\\Public\\IBM\\ClientSolutions\\Start_Programs\\Windows_x86-64\\acslaunch_win-64.exe\"\nsystem = r'\/system=\"your system name or IP goes here\"'\n# Popen requires the command to be separate from each of the parameters, so an array\nresult = subprocess.Popen([cmd, r\"\/plugin=5250\",system], shell=True)\nprint(result)\n\n# wait at least long enough for Windows to get past the splash screen\nprint(\"ACS starting - pausing\")\ntime.sleep(5)\n\nprint(\"connecting to Windows process\")\nACS = Application().connect(path=cmd)\nprint(ACS)\n\n# debugging\nwindows = ACS.windows()\nprint(windows)\n\ndialog = ACS['Signon to IBM i']\nprint(dialog)\n\nprint(\"sending keystrokes\")\nkeyboard.send_keys(userid)\nkeyboard.send_keys(\"{TAB}\") \nkeyboard.send_keys(password)\nkeyboard.send_keys(\"{ENTER}\")\n \nprint('Done.')","Q_Score":0,"Tags":"python,websphere,ibm-midrange","A_Id":75186995,"CreationDate":"2023-01-18T09:25:00.000","Title":"How can we automate login to IBM System using Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Refused to apply style from '' because its MIME type ('text\/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.\ni dont have any problem in vscode but when i hosted into pythonanywhere i cant even login into admin panel and the css from admin panel is not working","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":28,"Q_Id":75170423,"Users Score":1,"Answer":"You're probably getting that because it's a 404 page because your are not serving the file that you are trying to access. Search for \"static\" in the PythonAnywhere forums to find out how to configure static files.","Q_Score":0,"Tags":"python,django,admin","A_Id":75171290,"CreationDate":"2023-01-19T09:54:00.000","Title":"Refused to apply style from '' because its MIME type ('text\/html') pythonanywhere","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"We have a solution written in C#\/.NET Framework 4.7. It has a lot of infrastructure code related to environment configurations, database access, logging, exception handling etc.\nOur co-workers are eager to contribute to the project with Python code that makes a lot of special calculations. Ideally we want to pass configuration plus (big amount of) input data to their code and get back (big amount of) results without resorting to database integration. Is there a viable way to do so? Main goals are: 1) not to rewrite Python code to C# 2) not to duplicate configuration\/database related code in Python to make future maintenance easier","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":58,"Q_Id":75176798,"Users Score":-1,"Answer":"Yes this is exactly what Unix (e.g. Gnu\/Linux) dose. The Unix philosophy is about creating many (usually small) programs (that usually do one thing well), and connecting them to create a system that is greater than the parts. To do this we use inter-process communication, usually pipelines \/ streams.\nAn alternate approach is to compile the C# into a library, that can be called form the python.","Q_Score":0,"Tags":"python,c#,.net,integration","A_Id":75176886,"CreationDate":"2023-01-19T18:31:00.000","Title":"Is there a good way to use C# (.NET Framework) and Python code together?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am making an algorithm that performs certain edits to a PDF using the fitz module of PyMuPDF, more precisely inside widgets. The font size 0 has a weird behaviour, not fitting in the widget, so I thought of calculating the distance myself.\nBut searching how to do so only led me to innate\/library functions in other programming languages.\nIs there a way in PyMuPDF to get the optimal\/maximal font size given a rectangle, the text and the font?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":28,"Q_Id":75189505,"Users Score":1,"Answer":"As @Seon wrote, there is rc = page.insert_textbox(), which does nothing if the text does not fit. This is indicated by a negative float rc - the rectangle height deficite.\nIf positive however, the text has been written and it is too late for optimizing the font size.\nYou can of course create a Font object for your font and check text length beforehand using tl = font.text_length(text, fontsize=fs). Dividing tl \/ rect.width gives you an approximate number of lines in the rectangle, which you can compare with the rectangle height: rect.height \/ (fs * factor) in turn is a good estimate for the number of available lines in the rect.\nThe fontsize fs alone does not take the actual line height into account: the \"natural\" line height of a font is computed using its ascender and decender values lh = (font.ascender - font.descender) * fs. So the above computation should better be rect.height \/ lh for the number of fitting lines.\n.insert_textbox() has a lineheight parameter: a factor overriding the default (font.ascender - font.descender).\nDecent visual appearances can usually be achieved by setting lineheight=1.2.\nTo get a good fit for your text to fit in a rectangle in one line, choose fs = rect.width \/ font.text_length(text, fontsize=1) for the fontsize.\nAll this however is no guarantee for how a specific PDF viewer will react WRT text form fields. They have their own idea about necessary text borders, so you will need some experimenting.","Q_Score":0,"Tags":"python,pymupdf","A_Id":75191243,"CreationDate":"2023-01-20T21:32:00.000","Title":"PyMuPDF get optimal font size given a rectangle","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Are there tools for Python that minimize the size of the imports used in a Python package, something similar to esbuild for JavaScript? Having a tool that extracts only the used methods of imported packages, uglifying them, and putting them into a single file for efficiency purposes would be very useful. I need something like that to package my Python code into a Lambda. I am having trouble finding a tool that does so beyond linting.\nI tried tools like Black, flake8, and pyright, however none fulfill the purpose of minimizing the file\/package size.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":24,"Q_Id":75191124,"Users Score":0,"Answer":"A few tools are available to assist you in\u00a0packaging\u00a0your code for usage in a Lambda function and reducing\u00a0the size of Python imports.\nPipenv, a package manager that lets you manage dependencies and virtual environments for your Python applications, is one well-liked solution. You can deploy your project without relying on external dependencies by using pipenv to \"vendor\" your dependencies, which means that it will copy all the required packages into a vendor directory in your project.\nAnother tool that can help with this is pyinstaller. pyinstaller is a tool that can be used to package Python code into a standalone executable. It can also be used to package a Python script as a single executable file, which can be useful for deployment in environments like Lambda where you have limited control over the environment.","Q_Score":0,"Tags":"python,bundler,packaging","A_Id":75191149,"CreationDate":"2023-01-21T04:26:00.000","Title":"Are there Python tools that optimize for package size and performance?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"so the problem is that pypi.org hase been filtered by iranian government(yes , i know it's ridiculous!). i tried to install some python modules from Github downloaded files:\npip install moduleName\nbut every module has it's own dependencies and try to connect to pipy.org to reach them. then there will be an error during installation.\nis there any solution?\nyour help will be much appreciated.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":75211830,"Users Score":0,"Answer":"Try and use a VPN this will bypass any block on certain sites. Just google VPN for the top results.","Q_Score":1,"Tags":"python,installation,pip,module,pypi","A_Id":75211968,"CreationDate":"2023-01-23T15:49:00.000","Title":"how to install python modules where pipy.org is is not accessible from iran?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"so the problem is that pypi.org hase been filtered by iranian government(yes , i know it's ridiculous!). i tried to install some python modules from Github downloaded files:\npip install moduleName\nbut every module has it's own dependencies and try to connect to pipy.org to reach them. then there will be an error during installation.\nis there any solution?\nyour help will be much appreciated.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":48,"Q_Id":75211830,"Users Score":0,"Answer":"I live in a country that also blocks services, mostly streaming platforms. In theory, the way behind this is the same whether to watch Netflix or download python and its dependencies. That is you'll probably need to use a VPN.\nAs said by d-dutchveiws, there's tons of videos and resources on how to set up a VPN. If you do end up using a paid VPN service I would just like to add that I lived in the UAE for a while and I found that some VPN services were blocked by the country themselves. I know NordVPN did not work\/was blocked by the UAE so I ended up finding expressVPN and that worked. In other words, I'd be sure not to commit to any payment plan\/only use free trials because even the VPN services can be blocked. Hope I helped a bit!","Q_Score":1,"Tags":"python,installation,pip,module,pypi","A_Id":75212211,"CreationDate":"2023-01-23T15:49:00.000","Title":"how to install python modules where pipy.org is is not accessible from iran?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a team member which is developing autonomous fixed-wing. I am using ros to control fixed-wing.\nIn mission script there are callback functions which is giving latitude, longtitude, altitude, compass_angle, velocity, battery_level\nIn local computer I ve got a ground station which shows callback function values on indicator by using Tkinter and PIL\nI am getting values from firebase using firebase_admin but It is not real-time, values reach ground-computer 3-4 seconds late.\nSo I want to connect remote computer , reach mission_script.py and get values on callback functions. Is it possible to do if it is How can I do it?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":38,"Q_Id":75256781,"Users Score":1,"Answer":"Thanks to Alex's comment I used ZMQ and get real time data flow.","Q_Score":0,"Tags":"python,remote-access","A_Id":75262619,"CreationDate":"2023-01-27T10:25:00.000","Title":"Access values on remote python script from local python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to import PyPDF2 after successfully installing its latest version. And python 3.8.1 is also istalled on my enviornment. I get the following error:\nFile \/anaconda\/envs\/us_indust\/lib\/python3.8\/site-packages\/Crypto\/Cipher\/ARC4.py:119\n117 block_size = 1\n118 #: Size of a key (in bytes)\n--> 119 key_size = xrange(1,256+1)\nNameError: name 'xrange' is not defined\nI appreciate any help.\nThanks\nI installed the latest version of PyPDF2 which is 3.0.0. The same error happens again.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":27,"Q_Id":75290001,"Users Score":0,"Answer":"You installed a heavily outdated version of pyPdf or PyPDF2. xrange isn't in the library for a long time\nOr the error comes from an external dependeny, eg pycryptodome:\n\nCrypto\/Cipher\/ARC4.py\n\nUpdate that dependency","Q_Score":0,"Tags":"python,pypdf,pycryptodome","A_Id":75301385,"CreationDate":"2023-01-30T20:52:00.000","Title":"I received an error importing PyPDF2 library after I installed it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to install a lighter version of opencv on pi pico? If not, is there a way to install opencv library on an SD card and make pico to fetch those library files from that SD card?\nI am trying to record video using a OV7670 camera module and save the video it to SD card. Later I need to upload the video to a custom AWS server. I have the modules to capture images in micropython but can not find any modules or libraries to record video.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":25,"Q_Id":75300200,"Users Score":1,"Answer":"No. OpenCV is a huge library, with many moving parts. Even if there is a minimal version of OpenCV, I highly doubt that the 2MB of flash memory of the RP2040 will be enough for your use case. Coupling this alongside the limited number of cores, internal RAM, etc. of the CPU, you will probably end up with nothing. From what I know, you can use TinyML with MicroPython.","Q_Score":0,"Tags":"esp32,micropython,raspberry-pi-pico","A_Id":75300304,"CreationDate":"2023-01-31T16:31:00.000","Title":"Is there a way to install a lighter version of opencv?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'd like to display an embed with a picture using HTML, but I couldnt find anything online using python to do it. Is that even possible? if it is I would love an explanation.\nI tried searching, couldnt find anything about it.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":24,"Q_Id":75313745,"Users Score":1,"Answer":"Makes sense, sounded like a ChatGPT generated answer... AFAIK you can't get HTML embeds on Discord (which is a pain in the arse as it could make the experience much more enjoyable for bot users). One way you could tackle this though is by generating a picture of the content you want to be sent stored on a server you have access to and have the bot share said picture. Lots of cons here, but that's the best I figured out. Good luck.","Q_Score":0,"Tags":"python,html,discord","A_Id":75576248,"CreationDate":"2023-02-01T17:05:00.000","Title":"How can I display a HTML page in discord using a bot with python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I manually imported a certificate and key pair issued by a third party to certmanage in AWS and I am trying to programaticly export to a webserver and I get this error:\nbotocore.errorfactory.ValidationException: An error occurred (ValidationException) when calling the ExportCertificate operation: Certificate ARN: arn:aws:acm:us-east-1:x:certificatexxxxxxxx is not a private certificate\nCan I export a third party cert and private key from AWS certmanager?\npython -V\nPython 3.10.0\nI am trying to export a AWS managed certificate from certmanager and its failing.\nI've tried googleing the error code but come up with nothing.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":15,"Q_Id":75342534,"Users Score":1,"Answer":"AWS Certificate Manager (ACM) has two types of certificates. Public and Private.\nYou can't export any certificate when it is public. Even if you imported it.\nYou can associate your ACM certificate with ALB, for example, and put this ALB in front of your EC2 instance. But you can't export.\nAs you imported the certificate, it means you have the public and private parts of the certificate. You can just use it on your instance.\nOnly ACM privates ones can be exported.","Q_Score":0,"Tags":"python-3.x,amazon-web-services,boto3","A_Id":75345246,"CreationDate":"2023-02-04T02:16:00.000","Title":"Exporting Certificates from AWS Certmanager Boto3 Python310","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is there any difference between the infinities returned by the math module and cmath module?\nDoes the complex infinity have an imaginary component of 0?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":46,"Q_Id":75349427,"Users Score":2,"Answer":"Any difference?\nNo, there is no difference. According to the docs, both math.inf and cmath.inf are equivalent to float('inf'), or floating-point infinity.\nIf you want a truly complex infinity that has a real component of infinity and an imaginary component of 0, you have to build it yourself: complex(math.inf, 0)\nThere is, however, cmath.infj, if you want 0 as a real value and infinity as the imaginary component.\nConstructing imaginary infinity\nAs others have pointed out math.inf + 0j is a bit faster than complex(math.inf, 0). We're talking on the order of nanoseconds though.","Q_Score":1,"Tags":"python,python-3.x,complex-numbers,infinity,python-cmath","A_Id":75349428,"CreationDate":"2023-02-05T00:54:00.000","Title":"Is there a difference between math.inf and cmath.inf in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using aws codebuild to execute my testsuite. It says 'permission denied' when I try to run allure genrate in aws code build.\nPleas share the solution if anyone knows on how to generate allure report while working with aws code build.\nI am using pytest and the scenario is working fine in local. but failes in aws as aws build is not allowing me to run allure generate command.\non successful dev deployment -- > tetssuite execution -- > generate allure repors --> uploade them to s3 --> send the report via email using aws SNS with lambda.\nall above steps are working fine, but the 3rd step.(allure generate).\nPlease share the solution if anyone knows how to do it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":167,"Q_Id":75432923,"Users Score":0,"Answer":"I am able to fix this is by downloading allure package freshly outside of the $CODEBUILD_SRC_DIR and set the path for the same location .\n(Initially I made this part of test repository itself and add that location to PATH, which was not working)","Q_Score":1,"Tags":"python,amazon-web-services,pytest,allure","A_Id":75457422,"CreationDate":"2023-02-13T07:24:00.000","Title":"How to run allure generate command while using aws code build","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a Python\/Django code base in which strings are encapsulated in gettext calls. For legacy reasons, the strings in the Python files have been written in French and the English translations are inside a .po file.\nI now wish to make sure the Python files are in English, strings included. I would like to automatically switch the strings so that the English translations from the .po file end up in the Python files (instead of the French strings), while adding the French strings to a new .po file (matching the new \"original\" English string).\nSince I have a lot of strings, doing this manually would be extremely tedious. Is there any tool or library that could facilitate this process?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":75512982,"Users Score":0,"Answer":"There is no such tool.\nIf you don't write it yourself, you can use POEdit or Emacs as a helper. Both have a function that lets you jump to the source code line of a PO entry so that copy and paste is a little faster.","Q_Score":1,"Tags":"python,gettext","A_Id":75649833,"CreationDate":"2023-02-20T18:35:00.000","Title":"Automatically switch Python gettext strings with their translations from a .po file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"While implement Python unittest by subclassing IsolatedAsyncioTestCase, it only runs first test case successfully. For any subsequent test case it throws error that event loop is closed. This happens in both Windows and Mac. Could you please suggest how to make sure that event loop is running during the execution of test within each of the subsclasses of the IsolatedAsyncioTestCase that I have implemented.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":82,"Q_Id":75566800,"Users Score":1,"Answer":"I had the same problem when trying to run integration tests. The first test passed, but the second one got an \"Event loop is closed\" error. I'm using MognoDB with the async driver. The reason for this error was the way the database connection was opened. IsolatedAsyncioTestCase creates a new event loop at the start and closes it at the end for execution.\nSo, a driver connection was attached to the event loop of the first TestCase, and when the second TestCase starts, it throws an error because the event loop of the first TestCase is already closed, but the new connection in the new event loop is not created.\nThe solution is to create a new database connection in each IsolatedAsyncioTestCase.","Q_Score":1,"Tags":"python,python-asyncio,python-unittest","A_Id":76249506,"CreationDate":"2023-02-25T16:27:00.000","Title":"How to resolve error of Event loop is closed python unittest?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to build a python app sending reminder at certain time. It would have several subscribers. Each subscriber sets specific moment when they want to be notified. For example, John wants to have a reminder every days whereas Cassandra wants it every months.\nI see several ways to do it :\n\nUse a script running 24\/7 with a while loop and checks if it's time to do send the reminder.\nUse a cron tab that runs the script every minutes to check if there's reminder to send\nCreate a simple api (in Flask for example). It checks every minutes or so if there is a reminder to send to subscribers or even make a request to the api.\n\nWhat is the best way to build such application in Python for few subscribers (10) and for a larger amount(1000)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":50,"Q_Id":75776827,"Users Score":1,"Answer":"For a small amount of subscribers I would do a script that run all the times, it would continuously check the time and send reminders as needed, you can use time and datetime modules for that.\nFor a large amount of subscribers it would be an API that can manage multiple request simultaneously, you can use Flask or Django or FastAPI for that.\nFor the API how would it work is that subscribers would make POST request with all the informational notification ( date, time, what message they want to receive for example ) then the server store those informations in a database like if you are familiar with python Celery seem the best one but you have Airflow too, it will schedule a reminder to be executed at a certain time.\nThen when the reminder is executed it just retrieve the informations from the database, and send it via email for example","Q_Score":1,"Tags":"python,web-applications,architecture","A_Id":75777017,"CreationDate":"2023-03-18T15:28:00.000","Title":"Best way to build application triggering reminder at certain time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm making a python package where the main functionality is using a model that I've trained. I want it to be as easy as possible to access the model for end users so they can just use the main functions without needing to actively go find and download the model separately.\nI initially thought I would just include the model file in the package but it is on the large side (~95MB) and Github warns me about it so my feeling is I should try find an alternative way.\nI've tried compressing the model by zipping it but that doesn't make much of a dent in the file size. The model itself is fixed so I can't reduce the size by training an alternative version with different hyperparameters.\nMy solution at the moment is to not include the model and instead download it from s3 when the relevant class is used (this is an internal package, so everybody using it would hypothetically have access to the s3 bucket). However, I don't really like this solution because it requires users to have things set up to access AWS with a specific role, and even if I include examples \/ documentation \/ hints in error messaging, I can imagine the experience not being ideal. They also have the option of passing a file path if they have the model saved somewhere, but again that requires some initial setup.\nI've tried researching ways to access \/ package models but haven't come up with much.\nSo my questions are:\n\nIs there a way to include this model in the package?\nAre there other ways to access the model that I haven't thought about?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":33,"Q_Id":75800672,"Users Score":2,"Answer":"Is there a way to include this model in the package?\n\nYes, you can include any file\u2014no matter the size\u2014in a Python package.\n\nAre there other ways to access the model that I haven't thought about?\n\nIf the user is going to have to download it anyway, why not in the package?\nOne reason: if the model rarely changes, but the code around it does, the users will have to repeatedly download a large package.\nCould you have two Python packages? One that is just the model and the other that is the code? That way the user will only need to download the model again if a new version is available.","Q_Score":1,"Tags":"python,python-packaging","A_Id":75800745,"CreationDate":"2023-03-21T11:35:00.000","Title":"Accessing model when creating new python package","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"ERROR: Could not find a version that satisfies the requirement anymail (from versions: none)\nERROR: No matching distribution found for anymail\nCan anyone help me with this","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":72,"Q_Id":75885707,"Users Score":0,"Answer":"try upgrading your pip pip install --upgrade pip\nnote: you may need to check your other packages after the upgrade","Q_Score":1,"Tags":"python,django,django-anymail","A_Id":75889176,"CreationDate":"2023-03-30T08:17:00.000","Title":"Getting this error when tried to install using pip install anymail","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When using Facebook Messenger to send a chat message to my Chatbot, I don't get a reply. Checking the server logs show that I am receiving a GET request whereas it should be a POST request.\nThis is weird because the chatbot works when tested by running the file locally, whereas upon deploying it on Digital Ocean Droplet, it receives it as a GET request.\nThe deployed version works if i explicitly send a POST request via Postman (while simulating a facebook messaging request body)\nIs there any reason Facebook is sending \/ I am receiving it as a GET request instead of a POST?\nI tried to test the file locally and it works, and through simulating requests with Postman. It just doesn't work if the request is sent via a message on Facebook Messenger","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":75896833,"Users Score":0,"Answer":"Made a mistake before, it was indeed related to the redirections as stated by CBroe.\nPOST Endpoint was made for url with a trailing slash whereas the callback set on facebook developers was set to handle no trailing slash. Just had to fix that and redirection issue was resolved!","Q_Score":1,"Tags":"python,api,facebook,flask,request","A_Id":75900462,"CreationDate":"2023-03-31T09:25:00.000","Title":"Facebook API is sending a GET request instead of a POST to my Chatbot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Lets say I have a widely distributed\/used python package called foo that's designed to work with the following dependencies:\n\npandas>=1.3.0\u00a0\u00a0\u00a0\u00a0\npyarrow>=8.0\npython>=3.8\n\nHow do I make sure that my foo package is actually compatible with all those dependencies so that people have a seamless experience with using my package?\nOne idea that I had is to run my test suite against a whole bunch of environments with different versions of the dependent packages. For example, run the test suite 13 times under environments with the following dependency versions:\n\npandas=1.3.0, pyarrow=11.0, python=3.11.2\npandas=1.4.0, pyarrow=11.0, python=3.11.2\npandas=1.5.0, pyarrow=11.0, python=3.11.2\npandas=2.0.0, pyarrow=11.0, python=3.11.2\npyarrow=8.0, pandas=2.0.0, python=3.11.2\npyarrow=9.0, pandas=2.0.0, python=3.11.2\npyarrow=10.0, pandas=2.0.0, python=3.11.2\npyarrow=11.0, pandas=2.0.0, python=3.11.2\npython=3.8, pandas=2.0.0, pyarrow=11.0\npython=3.9, pandas=2.0.0, pyarrow=11.0\npython=3.10, pandas=2.0.0, pyarrow=11.0\npython=3.11, pandas=2.0.0, pyarrow=11.0\npython=3.11.2, pandas=2.0.0, pyarrow=11.0\n\nIs there a more robust way to do it? For example, what if my foo package doesn't work with pandas version 1.5.3. I don't think testing every major and minor release for all the dependent packages is feasible.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":111,"Q_Id":75924550,"Users Score":1,"Answer":"In general we may have significantly more than three deps,\nleading to combinatorial explosion.\nAnd mutual compatibility among the deps may be fragile,\nburdening you with tracking things like \"A cannot import B\nbetween breaking change X and bugfix Y\".\nImport renames will sometimes stir up trouble of that sort.\nTesting e.g. pandas 1.5.0 may be of limited interest\nonce we know the bugfixes of 1.5.3 are out.\n\nIs there a more robust way to do it?\n\nI recommend you adopt a \"point in time\" approach,\nso test configs resemble real user configs.\nFirst pick a budget of K tests, and an \"earliest\" date.\nWe will test between that date and current date,\nso initially we have 2 tests for those dates,\nwith K - 2 remaining in the budget.\nFor a given historic date, scan the deps for\ntheir release dates, compute min over them,\nand request installation of the corresponding\nversion number. Allow flexibility so that\nyou get e.g. pandas 1.4.4 installed (\"< 1.5\")\nrather than the less interesting 1.4.0.\nRun the test, watch it succeed.\nReport the test's corresponding date,\nwhich is max of dates for the installed dependencies.\nAt this point there's two ways you could go.\nYou might pick a single dep and constrain\nit (\">= 1.5\" or \">= 2.0\") to simulate a user\nwho wanted a certain released feature and\nupdated that specific package.\nLikely a better way for you to spend the test budget\nis to bisect a range of your \"reported\" dates,\nlocate when a dep bumped its minor version number,\nand adjust the constraints to pull that in.\nIt may affect a single dep,\nbut likely the install solver will uprev\nadditional deps, as well, and that's fine.\nReport the test result, lather, rinse, consume the budget.\nProudly publish the testing details on your website.\n\nGiven that everything takes a dependency on the cPython\ninterpreter, one way to do \"point in time\" is to\nsimply pick K interpreter releases and constrain\nthe install so it demands exact match on the release\nnumber, e.g. 3.10.8. Ratchet down the various minor version numbers\nas far as you can get away with, e.g. pandas \"< 1.5\" or \"< 1.4\".","Q_Score":3,"Tags":"python,continuous-integration,automated-tests,integration-testing","A_Id":75924682,"CreationDate":"2023-04-03T23:59:00.000","Title":"Testing Python Package Dependencies","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any command with squish runner or any option available in squish to run all the test suites in single run and generate report of complete project?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":51,"Q_Id":75969199,"Users Score":0,"Answer":"Nothing that is built into squishrunner, but if you specify the same \"html\" report folder for each execution, the suite reports will be stored in it and linked in the index.html page, to view them conveniently.\nExecuting one after the other via a shell script or batch file is simple, just add each squishrunner call into such a file.\nAs for reporting, please look into Squish Test Center, for which you should have 2 licenses per each Squish GUI Tester Tester license. This is because the HTML report format is deprecated and lacks features.","Q_Score":2,"Tags":"python,squish","A_Id":75975777,"CreationDate":"2023-04-09T07:07:00.000","Title":"Is there any possibility to run all test suites and generate report?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was trying to install the module ultralytics (for YOLOv8) in the bash of hosting service PythonAnywhere\nI tried:\npip install ultralytics\nBut get:\n\nERROR: Could not find a version that satisfies the requirement ultralytics (from versions: none)\nERROR: No matching distribution found for ultralytics\n\nI can install using the same method in my local machine , but having trouble in PythonAnywhere\nI upgraded pip, but no difference\nWhy is this happening?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":587,"Q_Id":76011471,"Users Score":0,"Answer":"Try to install a newer version of Python with version >= 3.7\nThen run python -m pip install --upgrade pip to upgrade your pip and install ultralytics again.","Q_Score":2,"Tags":"python,pip,pythonanywhere","A_Id":76387188,"CreationDate":"2023-04-14T03:52:00.000","Title":"Cannot install Ultralytics using pip in PythonAnywhere","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I try to build the mitsuba-msvc2010.sln using Visual Studio 2022. I fail to successfully build this solution; most probably due to some changes in SCons. This is the error I obtain\n\nAttributeError: 'SConsEnvironment' object has no attribute 'has_key':\n1> File \"SConstruct\", line 15: 1> env =\nSConscript('build\/SConscript.configure') 1> File \"C:\\Program Files\n(x86)\\Microsoft Visual\nStudio\\Shared\\Python39_64\\lib\\site-packages\\SCons\\Script\\SConscript.py\",\nline 662: 1> return method(*args, **kw) 1> File \"C:\\Program Files\n(x86)\\Microsoft Visual\nStudio\\Shared\\Python39_64\\lib\\site-packages\\SCons\\Script\\SConscript.py\",\nline 598: 1> return _SConscript(self.fs, *files, **subst_kw) 1>\nFile \"C:\\Program Files (x86)\\Microsoft Visual\nStudio\\Shared\\Python39_64\\lib\\site-packages\\SCons\\Script\\SConscript.py\",\nline 285: 1> exec(compile(scriptdata, scriptname, 'exec'),\ncall_stack[-1].globals) 1> File \"build\\SConscript.configure\", line\n111: 1> if env.has_key('BOOSTINCLUDE'):\n\nWas anybody able to build this and\/or knows how to fix this problem?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":45,"Q_Id":76068692,"Users Score":2,"Answer":"Python 3 dictionary objects no longer supports the has_key method, so that SConscript is out of date. The membership test \"in\" can be used instead, as in if 'BOOSTINCLUDE' in env:. There may be other things that need to be \"ported\" to use modern Python and SCons, usually not too complicated.","Q_Score":1,"Tags":"python,visual-studio-2022,scons","A_Id":76076529,"CreationDate":"2023-04-20T22:36:00.000","Title":"Compiling Mitsuba 2 on Visual Studio 2022 (SCons error)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I\u2019m trying to set up my Raspberry Pi, and blinka is not installing, and I have been backtracking to reinstall my setuptools since I have the error where the board is not importing. And I am receiving an error:\n\n13 permission denied \u2018\/usr\/local\/lib\/python3.9\/dist-packages\/_distutils_hack\/\u2018\n\nPlease I am losing my mind.\nI have tried deleting the files to see if I can get a fresh restart and it then denies permission from that same file.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":39,"Q_Id":76069351,"Users Score":1,"Answer":"I ended up factory restarting the raspberry pi cause I was worried I had corrupted something at some point, and it is working fine now.","Q_Score":1,"Tags":"python-3.x,raspberry-pi4,adafruit-circuitpython","A_Id":76137819,"CreationDate":"2023-04-21T01:50:00.000","Title":"Unable to uninstall setuptools to reinstall it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have several Python packages developed locally, which I often use in VSCode projects. For these projects, I create a new virtualenv and install these packages with pip install -e ..\/path\/to\/package. This succeeds, and I can use these packages in the project. However, VSCode underlines the package's import line in yellow, with this error:\n\nImport \"mypackage\" could not be resolved Pylance(reportMissingImports)\n\nAgain, mypackage works fine in the project, but VSCode reports that error, and I lose all autocomplete and type hint features when calling mypackage in the project.\nI ensured that the right Python interpreter is selected (the one from the project's virtualenv), but the error persists. The error and Pylance docs do not offer any other possible solutions.\nVSCode version: 1.78.0","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":295,"Q_Id":76213501,"Users Score":0,"Answer":"Usually, when you choose the correct interpreter, Pylance should take effect immediately. You can try adding \"python.analysis.extraPaths\": [\"path\/to\/your\/package\"] to your settings.json.\nYou can also try clicking on the install prompt in vscode to see which environment it will install the package in. I still believe that the problem was caused by incorrect selection of the interpreter.","Q_Score":2,"Tags":"python,visual-studio-code","A_Id":76214384,"CreationDate":"2023-05-09T21:31:00.000","Title":"Python packages imported in editable mode can't be resolved by pylance in VSCode","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Need to stop prometheus_client.http_server with Python code.\nI have external Python application that is to be unit-tested. It has method that starts prometheus_client with start_http_server(port). I need to unit-test it with several tests (indeed I don't test prometheus but other functionalities but can't take prometheus out of the code). As I need several tests so I need to start-stop method several times, but it exits after first attempt as Prometheus client is holding port and can't start again on the same port (OSError: [Errno 48] Address already in use).\nThe question: is there any way to stop prometheus_client.http_server with Python? Didn't find anything in prometheus_client docs about shutting it down...","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":79,"Q_Id":76222002,"Users Score":1,"Answer":"Well, it's not exact answer to my question but anyway: I decided to start_http_server = Mock(return_value=None) so that it's not starting in unit-tests.","Q_Score":1,"Tags":"python,prometheus","A_Id":76230873,"CreationDate":"2023-05-10T19:31:00.000","Title":"Stop Prometheus client in python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Fairly new to python-polars.\nHow does it compare to Rs {data.table} package in terms of memory usage?\nHow does it handle shallow copying?\nIs in-place\/by reference updating possible\/the default?\nAre there any recent benchmarks on memory efficiency of the big 4 in-mem data wrangling libs (polars vs data.table vs pandas vs dplyr)?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":170,"Q_Id":76400975,"Users Score":3,"Answer":"How does it handle shallow copying?\n\nPolars memory buffers are reference counted Copy on Write. That means you can never do a full data copy within polars.\n\nIs in-place\/by reference updating possible\/the default?\n\nNo, you must reassign the variable. Under the hood polars' may reuse memory buffers, but that is not visible to the users.\n\nAre there any recent benchmarks on memory efficiency\n\nThe question how it relates in memory usage is also not doing respect to design differences. Polars currently is developing an out-of-core engine. This engine doesn't process all data in memory, but will stream data from disk. The design philosophy of that engine is to use as much memory as needed without going OOM. Unused memory, is wasted potential.","Q_Score":3,"Tags":"python,r,data.table,python-polars","A_Id":76401263,"CreationDate":"2023-06-04T14:51:00.000","Title":"Polars memory usage as compared to {data.table}","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We manage a significant number of Python virtual code environments in our estate. We are moving to a more aggresive OS level patching schedule which means there is higher risk to break some Python virtual code environments due to some OS level dependencies changing or issues during installation. We are therefore looking at different options to try to mitigate this risk. Aside from recreating the virtual code environment after OS patching what else can we do to confirm the code environment it's working fine? Of course running the code\/app\/model that the code environment is meant to support would be ideal but this is not practical\/possible for various reasons that are not relevant to the question.\nI was thinking that perhaps I could look at the requirements.txt of each virtual code environment and attempt to import all packages that required to be installed in each virtual code environment. From previous experience the majority of virtual code environment issues happen either during the creation of the code environment (ie when packages are installed\/code env created) or when the required packages are imported in code. So this approach will cover most of the risk leaving only potential run time issues which should be a very small proportion.\nWhat's you view on this approach? Do you see any issues with it? One thing I know will be a challenge is that package names don't always match the \"import\" name used in code but I suspect we will be able to work around this problem building a dictionary of package names and import names.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":76435549,"Users Score":0,"Answer":"If you update Python, of course you might end up with versioning issues. if these are dev machines, I'd strongly suggest you enforce a policy to update, but not push it on the dev without their knowledge.\nIf you don't upgrade Python, the only things that may break are the packages that are not pure python and depend on those OS level packages. Even then, most of those will have been compiled at installation and unless they dynamically load OS libraries that changed APIs after patching, they would not be affected.\nSo you are left with identifying python packages that have dynamic OS-level library dependencies, and focus on those. There is likely only a few projects that would belong in that category, and they are usually the ones causing developers installation problems, so they should be easy to identify ;-)\nYou can use pip inspect to get a full description of the packages and the location of their metadata\nYou can go list files in the site_packages folders and find out which project were built from non-python source that may require OS level libraries, and focus on trying to install those after patching.\nIf you don't want to sweat it and automate this, a full pip freeze > requirements.txt will give you all of the packages in the environment, and a simple test would be to re-create the environment and pip install -r requirements.txt\nBeyond that, I'd assume developers will be in charge of making the code and dev environment work, and hopefully they use some reproducible environment for deployment (like containers) and local OS patching of their dev machine will be annoying but won't affect prod immediately.\nIf you're now talking about patching live servers that are not containerized, then definitely follow a pattern of patching in dev, then staging before pushing those changes to prod. Let the code base go through all the testing they normally do through on those patched OSs, and let the devs iron out the bugs for the environments. When and if it becomes more important that you push an OS patch immediately rather than to go through a full test cycle, then you can take that decision.","Q_Score":1,"Tags":"python,virtualenv,cicd,python-venv","A_Id":76436204,"CreationDate":"2023-06-08T20:41:00.000","Title":"How can I test Python virtual code environments programatically?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We manage a significant number of Python virtual code environments in our estate. We are moving to a more aggresive OS level patching schedule which means there is higher risk to break some Python virtual code environments due to some OS level dependencies changing or issues during installation. We are therefore looking at different options to try to mitigate this risk. Aside from recreating the virtual code environment after OS patching what else can we do to confirm the code environment it's working fine? Of course running the code\/app\/model that the code environment is meant to support would be ideal but this is not practical\/possible for various reasons that are not relevant to the question.\nI was thinking that perhaps I could look at the requirements.txt of each virtual code environment and attempt to import all packages that required to be installed in each virtual code environment. From previous experience the majority of virtual code environment issues happen either during the creation of the code environment (ie when packages are installed\/code env created) or when the required packages are imported in code. So this approach will cover most of the risk leaving only potential run time issues which should be a very small proportion.\nWhat's you view on this approach? Do you see any issues with it? One thing I know will be a challenge is that package names don't always match the \"import\" name used in code but I suspect we will be able to work around this problem building a dictionary of package names and import names.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":76435549,"Users Score":0,"Answer":"Process\nI believe this should be done in a two step procedure\n\nCreate environment for testing (OS \/ Python Version)\nRun a set of integration tests to determine pass state\n\nStep 1 ensures you can create a environment which accurately represents what will be used in production.\nStep 2 ensures you can test the environment and make sure it does what you expect.\nThen all you have to do is repeat this procedure for each environment, adding additional tests as you see fit.\nCreating an environment\nThis can be done in many ways:\n\nDocker containers\nVirtual machines using IaC provisioning\nManual config (not repeatable)\n\nManual config is not repeatable and would be slow.\nRunning Integration Tests\nThis is dependent on what you are testing but could be done with\n\nBash \/ Python Scripts\nWeb API calls\nFile discovery\nOther low level system calls","Q_Score":1,"Tags":"python,virtualenv,cicd,python-venv","A_Id":76435674,"CreationDate":"2023-06-08T20:41:00.000","Title":"How can I test Python virtual code environments programatically?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Consider you have a monorepo in github, whereas each folder represents a microservice.\nNow I want to be able to have a git tag for each microservice separately.\nSince we are sharing one repo, each tag for example v1.0.0 for microservice foo1 will capture this tag from being created for microservice foo2.\nInstead, we can create tags named foo1-v1.0.0 and foo2-v1.0.0 to solve this collision.\nMy question if we have some nice package or tool for doing precisely this convention- meaning semver with some prefix?\nThanks in advance","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":69,"Q_Id":76460690,"Users Score":0,"Answer":"If your package feed is fully SemVer compliant, you can use the build metatag:\n\nPackage the microservices separately.\nApply the commit hash from which they were built to the metatag in the package version string (v1.0.42+commitId)\nTag the commit hash with the package name and full version string (MicroserviceA v1.0.42+commitId).\n\nSadly, not all package services (NPM comes to mind) are SemVer compliant and often drop the metatag, arguing that it is not used for sorting. Also, not all version automation can do repo tagging with a prefix other than 'v'.","Q_Score":2,"Tags":"python-3.x,microservices,monorepo,semantic-versioning","A_Id":76536251,"CreationDate":"2023-06-12T22:29:00.000","Title":"Managing monorepo versioning using modified version of semver in a python project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0}]